beginner d.js
const TOKEN = "ggggg"
const clientId = "1169295307490742333"
const guildId = "1169296221278576670"
const Discord = require("discord.js")
const Routes = Discord.Routes
const Rest = require("@discordjs/rest")
const rest = new Rest.REST(
{
version: "10",
}
).setToken(TOKEN)
const client = new Discord.Client({
intents: [
"Guilds",
"GuildMessages",
"MessageContent"
]
})
client.login(TOKEN)
client.on("ready", () => {
console.log(`Ready as ${client.user.displayName} ${client.user.discriminator}`)
})
client.on("messageCreate", (message) => {
message.reply("Yo yo")
})
client.on("interactionCreate", (interaction) => {
if (interaction.isChatInputCommand()) {
console.log(interaction.options.getString("food"))
interaction.reply({
content: "Heyy!!!!"
})
}
})
async function slashCmd() {
const commands = [
{
name: "purge",
description: "Mass delete discord messages on a channel",
options: [
{
name: "Amount",
description: "Amount of numbers to delete",
type: 4,
required: true
}
]
}
]
try {
console.log('Started refreshing application (/) commands.')
await rest.put(Routes.applicationGuildCommands(clientId, guildId), {
body: commands,
})
} catch (err) {
console.log(err)
}
}
slashCmd()
const TOKEN = "ggggg"
const clientId = "1169295307490742333"
const guildId = "1169296221278576670"
const Discord = require("discord.js")
const Routes = Discord.Routes
const Rest = require("@discordjs/rest")
const rest = new Rest.REST(
{
version: "10",
}
).setToken(TOKEN)
const client = new Discord.Client({
intents: [
"Guilds",
"GuildMessages",
"MessageContent"
]
})
client.login(TOKEN)
client.on("ready", () => {
console.log(`Ready as ${client.user.displayName} ${client.user.discriminator}`)
})
client.on("messageCreate", (message) => {
message.reply("Yo yo")
})
client.on("interactionCreate", (interaction) => {
if (interaction.isChatInputCommand()) {
console.log(interaction.options.getString("food"))
interaction.reply({
content: "Heyy!!!!"
})
}
})
async function slashCmd() {
const commands = [
{
name: "purge",
description: "Mass delete discord messages on a channel",
options: [
{
name: "Amount",
description: "Amount of numbers to delete",
type: 4,
required: true
}
]
}
]
try {
console.log('Started refreshing application (/) commands.')
await rest.put(Routes.applicationGuildCommands(clientId, guildId), {
body: commands,
})
} catch (err) {
console.log(err)
}
}
slashCmd()
7 Replies
- What's your exact discord.js
npm list discord.js
and node node -v
version?
- Not a discord.js issue? Check out #other-js-ts.
- Consider reading #how-to-get-help to improve your question!
- Explain what exactly your issue is.
- Post the full error stack trace, not just the top part!
- Show your code!
- Issue solved? Press the button!
- ✅
Marked as resolved by OPyou know
showing the error would be somewhat helpful
DiscordAPIError[50035]: Invalid Form Body
0.options[0].name[APPLICATION_COMMAND_INVALID_NAME]: Command name is invalid
at handleErrors (C:\Users\yusuf\OneDrive\Documents\Programming Projects\first d.js\node_modules\@discordjs\rest\dist\index.js:687:13)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async SequentialHandler.runRequest (C:\Users\yusuf\OneDrive\Documents\Programming Projects\first d.js\node_modules\@discordjs\rest\dist\index.js:1072:23)
at async SequentialHandler.queueRequest (C:\Users\yusuf\OneDrive\Documents\Programming Projects\first d.js\node_modules\@discordjs\rest\dist\index.js:913:14)
at async _REST.request (C:\Users\yusuf\OneDrive\Documents\Programming Projects\first d.js\node_modules\@discordjs\rest\dist\index.js:1218:22)
at async slashCmd (C:\Users\yusuf\OneDrive\Documents\Programming Projects\first d.js\src\index.js:63:9) {
requestBody: { files: undefined, json: [ [Object] ] },
rawError: {
message: 'Invalid Form Body',
code: 50035,
errors: { '0': [Object] }
},
code: 50035,
status: 400,
method: 'PUT',
url: 'https://discord.com/api/v10/applications/1169295307490742333/guilds/1169296221278576670/commands'
}
DiscordAPIError[50035]: Invalid Form Body
0.options[0].name[APPLICATION_COMMAND_INVALID_NAME]: Command name is invalid
at handleErrors (C:\Users\yusuf\OneDrive\Documents\Programming Projects\first d.js\node_modules\@discordjs\rest\dist\index.js:687:13)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async SequentialHandler.runRequest (C:\Users\yusuf\OneDrive\Documents\Programming Projects\first d.js\node_modules\@discordjs\rest\dist\index.js:1072:23)
at async SequentialHandler.queueRequest (C:\Users\yusuf\OneDrive\Documents\Programming Projects\first d.js\node_modules\@discordjs\rest\dist\index.js:913:14)
at async _REST.request (C:\Users\yusuf\OneDrive\Documents\Programming Projects\first d.js\node_modules\@discordjs\rest\dist\index.js:1218:22)
at async slashCmd (C:\Users\yusuf\OneDrive\Documents\Programming Projects\first d.js\src\index.js:63:9) {
requestBody: { files: undefined, json: [ [Object] ] },
rawError: {
message: 'Invalid Form Body',
code: 50035,
errors: { '0': [Object] }
},
code: 50035,
status: 400,
method: 'PUT',
url: 'https://discord.com/api/v10/applications/1169295307490742333/guilds/1169296221278576670/commands'
}
option names should be lower case
ohhhh
Thank you
oop