Bot no register slash commands

Tried: reinviting the bot with scopes enabled, testing with ping command in docs example(it worked), using applicationGuildCommand() as well, but to no avail.
13 Replies
d.js toolkit
d.js toolkitā€¢15mo ago
- 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!
treble/luna
treble/lunaā€¢15mo ago
How do you deploy your commands, its applicationGuildCommands aswell And are you sure the guild id is correct
MegalodonšŸŒŠ
MegalodonšŸŒŠā€¢15mo ago
Ummm command handler? I take al the commands from the file, turn it into json, export it to another file, the add that deployment variable to the body Ah yea, typo 100% checked it multiple times
treble/luna
treble/lunaā€¢15mo ago
And did you redeploy after inviting the bot
MegalodonšŸŒŠ
MegalodonšŸŒŠā€¢15mo ago
yes
treble/luna
treble/lunaā€¢15mo ago
Show your deploy file
MegalodonšŸŒŠ
MegalodonšŸŒŠā€¢15mo ago
RegisterSlash.js:
const { REST, Routes } = require('discord.js')
const { client_id } = require("../configuration/config.json")

module.exports = async (bot) => {

/*const commands = [
{
name: 'ping',
aliases: [],
description: 'Replies with Pong!',
usage: "s!ping",
},
];*/
//registering slash commands
const rest = new REST({ version: '10' }).setToken(process.env.token);
try {

const commands = await bot.command;
if (!commands || commands === undefined) return;

console.log('Started refreshing application (/) commands.');

/*await rest.delete(Routes.applicationGuildCommand(client_id, "702812667957739611", '1137312625068347482'))
.then(() => console.log('Successfully deleted guild command'))
.catch(console.error);*/

/*await rest.delete(Routes.applicationCommand(client_id, '1136006267668791408'))
.then(() => console.log('Successfully deleted guild command'))
.catch(console.error);*/

await rest.put(Routes.applicationGuildCommands(client_id, "702812667957739611"), { body: commands });

console.log('Successfully reloaded application (/) commands.');
} catch (error) {
console.error(error);
}
};
const { REST, Routes } = require('discord.js')
const { client_id } = require("../configuration/config.json")

module.exports = async (bot) => {

/*const commands = [
{
name: 'ping',
aliases: [],
description: 'Replies with Pong!',
usage: "s!ping",
},
];*/
//registering slash commands
const rest = new REST({ version: '10' }).setToken(process.env.token);
try {

const commands = await bot.command;
if (!commands || commands === undefined) return;

console.log('Started refreshing application (/) commands.');

/*await rest.delete(Routes.applicationGuildCommand(client_id, "702812667957739611", '1137312625068347482'))
.then(() => console.log('Successfully deleted guild command'))
.catch(console.error);*/

/*await rest.delete(Routes.applicationCommand(client_id, '1136006267668791408'))
.then(() => console.log('Successfully deleted guild command'))
.catch(console.error);*/

await rest.put(Routes.applicationGuildCommands(client_id, "702812667957739611"), { body: commands });

console.log('Successfully reloaded application (/) commands.');
} catch (error) {
console.error(error);
}
};
treble/luna
treble/lunaā€¢15mo ago
first of all commands do not have an alias or usage property Also you might be ratelimited because you make 3 requests
MegalodonšŸŒŠ
MegalodonšŸŒŠā€¢15mo ago
yea I was testing if it worked with that property there, and it does work.
treble/luna
treble/lunaā€¢15mo ago
You should only make one and if you want multiple guilds use global commands
MegalodonšŸŒŠ
MegalodonšŸŒŠā€¢15mo ago
No no, I make only 1 request the other two are commented out I have only one guild for testing Help pls, I've been trying to get the slash commands to register for the past 3 days ;-; console.log(commands) does show me the json format of my comands. I did try it and the console shows me nothing when running the deployment, just shows that it started refreshing slash comands and after that it shows my bot is ready from the bot.ready thingy and for the next9 hours, literally nothing Okay so, I've tried it like 10 times in like 10 minutes ig? That was before Around 16 hours ago I tried it once, just now, spat an error, fixed it and ran it again for the seond time in 16 hours, and same behaviour But I will try and add the rate limited thing, that might actually help, thank you I tried rest.on('rateLimited', console.log) nothing happened, but when I changed it to rest.on('rateLimited', console.log("being rate limited") I got this error:
Started refreshing application (/) commands.
being rate limited
TypeError [ERR_INVALID_ARG_TYPE]: The "listener" argument must be of type function. Received undefined
at checkListener (node:events:267:3)
at _addListener (node:events:547:3)
at REST.addListener (node:events:606:10)
at module.exports (C:\Users\joy4e\Documents\GitHub\sharky\util\RegisterSlash.js:31:10)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
code: 'ERR_INVALID_ARG_TYPE'
}
Sharky is ready
Started refreshing application (/) commands.
being rate limited
TypeError [ERR_INVALID_ARG_TYPE]: The "listener" argument must be of type function. Received undefined
at checkListener (node:events:267:3)
at _addListener (node:events:547:3)
at REST.addListener (node:events:606:10)
at module.exports (C:\Users\joy4e\Documents\GitHub\sharky\util\RegisterSlash.js:31:10)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
code: 'ERR_INVALID_ARG_TYPE'
}
Sharky is ready
I did this:
rest.on('rateLimited', function(rateLimitInfo) {
console.log("Initiated")
console.log(rateLimitInfo)
console.log("Completed")
})
rest.on('rateLimited', function(rateLimitInfo) {
console.log("Initiated")
console.log(rateLimitInfo)
console.log("Completed")
})
and got:
[nodemon] restarting due to changes...
[nodemon] starting `node .`
Started refreshing application (/) commands.
{ remaining: 120, resetAt: 1691324564590 }
Initiated
{
timeToReset: 46093,
limit: 2,
method: 'PUT',
hash: 'Global(PUT:/applications/:id/guilds/:id/commands)',
url: 'https://discord.com/api/v10/applications/762887460405379122/guilds/702812667957739611/commands',
route: '/applications/:id/guilds/:id/commands',
majorParameter: 'global',
global: false
}
Completed
Sharky is ready
[nodemon] restarting due to changes...
[nodemon] starting `node .`
Started refreshing application (/) commands.
{ remaining: 120, resetAt: 1691324564590 }
Initiated
{
timeToReset: 46093,
limit: 2,
method: 'PUT',
hash: 'Global(PUT:/applications/:id/guilds/:id/commands)',
url: 'https://discord.com/api/v10/applications/762887460405379122/guilds/702812667957739611/commands',
route: '/applications/:id/guilds/:id/commands',
majorParameter: 'global',
global: false
}
Completed
Sharky is ready
I truly am not being rate limited rn because This is my code:
const { REST, Routes, getInitialSendRateLimitState } = require('discord.js')
const { client_id } = require("../configuration/config.json")

module.exports = async (bot) => {

/*const commands = [
{
name: 'ping',
aliases: [],
description: 'Replies with Pong!',
usage: "s!ping",
},
];*/
//registering slash commands
const rest = new REST({ version: '10' }).setToken(process.env.token);
try {

const commands = await bot.command;
if (!commands || commands === undefined) return;

console.log('Started refreshing application (/) commands.');

/*await rest.delete(Routes.applicationGuildCommand(client_id, "702812667957739611", '1137312625068347482'))
.then(() => console.log('Successfully deleted guild command'))
.catch(console.error);*/

/*await rest.delete(Routes.applicationCommand(client_id, '1136006267668791408'))
.then(() => console.log('Successfully deleted guild command'))
.catch(console.error);*/

rest.on('rateLimited', function(rateLimitInfo) {
console.log("Initiated")
console.log(rateLimitInfo)
console.log("Completed")
})

console.log(getInitialSendRateLimitState())

await rest.put(Routes.applicationGuildCommands(client_id, "702812667957739611"), { body: commands }).then((d) => console.log(d))

console.log('Successfully reloaded application (/) commands.');
} catch (error) {
console.error(error);
}
};
const { REST, Routes, getInitialSendRateLimitState } = require('discord.js')
const { client_id } = require("../configuration/config.json")

module.exports = async (bot) => {

/*const commands = [
{
name: 'ping',
aliases: [],
description: 'Replies with Pong!',
usage: "s!ping",
},
];*/
//registering slash commands
const rest = new REST({ version: '10' }).setToken(process.env.token);
try {

const commands = await bot.command;
if (!commands || commands === undefined) return;

console.log('Started refreshing application (/) commands.');

/*await rest.delete(Routes.applicationGuildCommand(client_id, "702812667957739611", '1137312625068347482'))
.then(() => console.log('Successfully deleted guild command'))
.catch(console.error);*/

/*await rest.delete(Routes.applicationCommand(client_id, '1136006267668791408'))
.then(() => console.log('Successfully deleted guild command'))
.catch(console.error);*/

rest.on('rateLimited', function(rateLimitInfo) {
console.log("Initiated")
console.log(rateLimitInfo)
console.log("Completed")
})

console.log(getInitialSendRateLimitState())

await rest.put(Routes.applicationGuildCommands(client_id, "702812667957739611"), { body: commands }).then((d) => console.log(d))

console.log('Successfully reloaded application (/) commands.');
} catch (error) {
console.error(error);
}
};
and this is my output:
[nodemon] starting `node .`
Started refreshing application (/) commands.
{ remaining: 120, resetAt: 1691327013119 }
Sharky is ready
[nodemon] starting `node .`
Started refreshing application (/) commands.
{ remaining: 120, resetAt: 1691327013119 }
Sharky is ready
But it still isn't being registered wdym? it catches only if there is an errror, but there is no error idk what the error console is from vscode like powershell terminal no it shows everything in one terminal even if there is an error sure
MegalodonšŸŒŠ
MegalodonšŸŒŠā€¢15mo ago
MegalodonšŸŒŠ
MegalodonšŸŒŠā€¢15mo ago
Here, see? I don't exactly call it, it goes to the bot directly, it is awaited bot is my Client ajshdkad forgive me, I'm stil kinda learning, in uni rn, anyway, I think it's called when the bot is logged on Cuz it worked when I gave it only a single command to register It's called in my index.js, right before the bot.login function code:
//load command handler
loadcommands(bot);

//load slash command regitry
require("./util/RegisterSlash")(bot);
//load command handler
loadcommands(bot);

//load slash command regitry
require("./util/RegisterSlash")(bot);
loadcommands is declared: const loadcommands = require("./util/commandHandler") how do I await it Nah I use a command handler, so all of it is stored in different files Oh right did that, and now the bot isn't logging in either ;-; //load slash command regitry require("./util/RegisterSlash")(bot).then(() => bot.login(process.env.token)) do I try it after I console.log the ratelimit or before? Yea I got that Started refreshing application (/) commands. { remaining: 120, resetAt: 1691330981093 } [REST Global(PUT:/applications/:id/guilds/:id/commands):global] Received bucket hash update Old Hash : Global(PUT:/applications/:id/guilds/:id/commands) New Hash : a3b974ef6eb1c925dd4ceb42f4db26fd [REST Global(PUT:/applications/:id/guilds/:id/commands):global] Encountered unexpected 429 rate limit Global : false Method : PUT URL : https://discord.com/api/v10/applications/762887460405379122/guilds/702812667957739611/commands Bucket : /applications/:id/guilds/:id/commands Major parameter: global Hash : Global(PUT:/applications/:id/guilds/:id/commands) Limit : 2 Retry After : 30050ms Sublimit : 30050ms So I am getting rate limited huh It says to retry after 30 seconds tho yea? It says I'm rate limited by ther restDebug but the rest.on('rateLimited', console.log) does not show up in my terminal at all?????? I'm actually trying to just test it ;-; But yea, I'll keep that in mind, I'm sorry output:
Collection(0) [Map] {}
Collection(0) [Map] {}
on my computer not at all but my isp's routing is truly, pure trash oki, thanks wait, I tried running the code on a hosting webiste and it spits me the same goddamn error?! I can 100% tell you that I've deployed it only 14 times today Cuz within 24 hours, I've run this bot only like 20 times, out of which, a few times without running the registering command nodemon Ik it restarts the bot every time I make a change. That's why I'm using nodemon. Otherwise I was just using node. Cuz I didn't edit it and save more than 14 times, duh Dude, this doesn't make sense to me at all. The rate limit says retry after 30050 ms, the sublimit shows the same amount of time and the limit is two. The last time I tried registering commands was at 1:40 am last night, 12 hours later(rn) I get the same unexpected 429 rate limit error. How does that compute?
Want results from more Discord servers?
Add your server