zudsniper / go-offline

(discord.js v9 -- updating) mini-discord bot to allow users to set usage limits for text channel messages.
1 stars 0 forks source link

[CRITICAL] Crash when registering commands #1

Open zudsniper opened 1 year ago

zudsniper commented 1 year ago

VERSIONS

node: 18.15.1

ADDED STEPS

I required using dotenv-cli package to wrap the execution of node handle-commands.js to populate environment variables correctly. I imagine this is due to my WSL install.

This is easily accomplished via npm i dotenv-cli -g, then running the command listed below.

PROBLEM

dotenv node handle-commands.js fails

CRASH DUMP

jason@pc2strong:~/discord-bot/go-offline$ dotenv node deploy-commands.js 
Started refreshing application (/) commands.
DiscordAPIError[50035]: Invalid Form Body
application_id[NUMBER_TYPE_COERCE]: Value "undefined" is not snowflake.
    at handleErrors (/home/jason/discord-bot/go-offline/node_modules/@discordjs/rest/dist/index.js:640:13)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async SequentialHandler.runRequest (/home/jason/discord-bot/go-offline/node_modules/@discordjs/rest/dist/index.js:1021:23) 
    at async SequentialHandler.queueRequest (/home/jason/discord-bot/go-offline/node_modules/@discordjs/rest/dist/index.js:862:14)
    at async REST.request (/home/jason/discord-bot/go-offline/node_modules/@discordjs/rest/dist/index.js:1387:22)
    at async /home/jason/discord-bot/go-offline/deploy-commands.js:39:9 {
  requestBody: { files: undefined, json: [ [Object], [Object], [Object] ] },
  rawError: {
    code: 50035,
    errors: { application_id: [Object] },
    message: 'Invalid Form Body'
  },
  code: 50035,
  status: 400,
  method: 'PUT',
  url: 'https://discord.com/api/v9/applications/undefined/commands'
}

POSSIBLE SOLUTION

Upgrade handle-commands.js to new Slash Command Registration system.

@laralove143 would this fix the issue?

Thank you!

laralove143 commented 1 year ago

unless your application's name is undefined, something goes wrong in getting/passing the application, upgrade whatever discord lib ur using anyway