error when deploying discord bot

DiscordAPIError[20012]: You are not authorized to perform this action on this application
at handleErrors (/app/node_modules/@discordjs/rest/dist/index.js:640:13)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async SequentialHandler.runRequest (/app/node_modules/@discordjs/rest/dist/index.js:1021:23)
at async SequentialHandler.queueRequest (/app/node_modules/@discordjs/rest/dist/index.js:862:14)
at async REST.request (/app/node_modules/@discordjs/rest/dist/index.js:1387:22)
at async /app/src/functions/handelCommands.js:28:17 {
requestBody: {
files: undefined,
json: [ [Object], [Object], [Object], [Object], [Object] ]
},
rawError: {
message: 'You are not authorized to perform this action on this application',
code: 20012
},
code: 20012,
status: 403,
method: 'PUT',
url: 'https://discord.com/api/v9/applications/1127094913746612304/commands';
}
DiscordAPIError[20012]: You are not authorized to perform this action on this application
at handleErrors (/app/node_modules/@discordjs/rest/dist/index.js:640:13)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async SequentialHandler.runRequest (/app/node_modules/@discordjs/rest/dist/index.js:1021:23)
at async SequentialHandler.queueRequest (/app/node_modules/@discordjs/rest/dist/index.js:862:14)
at async REST.request (/app/node_modules/@discordjs/rest/dist/index.js:1387:22)
at async /app/src/functions/handelCommands.js:28:17 {
requestBody: {
files: undefined,
json: [ [Object], [Object], [Object], [Object], [Object] ]
},
rawError: {
message: 'You are not authorized to perform this action on this application',
code: 20012
},
code: 20012,
status: 403,
method: 'PUT',
url: 'https://discord.com/api/v9/applications/1127094913746612304/commands';
}
ive made a token variable. am i supposed to make another?
22 Replies
Percy
Percy13mo ago
Project ID: N/A
MantisInABox
MantisInABox13mo ago
You are using your token environment variable to login as the bot, correct?
Jitty2Litty
Jitty2Litty13mo ago
yes
MantisInABox
MantisInABox13mo ago
Are you trying to access privileges intents with your bot?
Jitty2Litty
Jitty2Litty13mo ago
client.login(process.env.token); im trying to host the bot
MantisInABox
MantisInABox13mo ago
I understand, but that error is from the Discord api, not railway
Brody
Brody13mo ago
and do you have a token service variable in railway?
Jitty2Litty
Jitty2Litty13mo ago
yes
Brody
Brody13mo ago
can you show us
Jitty2Litty
Jitty2Litty13mo ago
in my .env
token=<bot_token>
token=<bot_token>
Brody
Brody13mo ago
that is not a railway service variable
MantisInABox
MantisInABox13mo ago
It’s best practice not to use .env files You want to add it to the service through the dashboard on railway
Jitty2Litty
Jitty2Litty13mo ago
oh mb one sec
MantisInABox
MantisInABox13mo ago
But the error you are receiving is not related to your token. It is related to something you are trying to do
Brody
Brody13mo ago
true
MantisInABox
MantisInABox13mo ago
The issue is in your handleCommands.js file You must be trying to access privileges intents but don’t have them turned on in your discord developer dashboard for your bot
Jitty2Litty
Jitty2Litty13mo ago
could it be the clientId? i have all 3 turned on
MantisInABox
MantisInABox13mo ago
Can you share the handleCommands file?
Jitty2Litty
Jitty2Litty13mo ago
sure one sec lemme put in sourcebin
MantisInABox
MantisInABox13mo ago
The issue seems to be with you trying to use a put. There is something else going on there. It’s hard to debug, with just the one file, but you are not allowed to do what you are trying to do, and discord is blocking it
Jitty2Litty
Jitty2Litty13mo ago
damn so no fix?
MantisInABox
MantisInABox13mo ago
I would review the discord.js docs and see if you can find a solution. But you should not need to make api calls to register your slash commands