My one Guild commands Handler are stuck in refreshing
My one Guild commands Handler are stuck in refreshing and dont reloade what can i do there is no error in the Terminal. it stopped working from one day to the next and i wonder why
19 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 OPconst fs = require('fs');
const { REST, Routes } = require('discord.js');
const clientId = (process.env.DISCORD_APPLICATION_ID);
const guildId = ("809535850710302770");
module.exports = (client) => {
client.handleCommands = async (commandFolders, path) => {
client.commandArray = [];
for (folder of commandFolders) {
const commandFiles = fs.readdirSync(
const response = await rest.put( Routes.applicationGuildCommands(clientId, guildId), { body: client.commandArray }, );
console.log('Successfully reloaded application (/) commands:', response); } catch (error) { console.error('Error while reloading application (/) commands:', error); } })();
} }
${path}/${folder}
).filter(file => file.endsWith('.js'));
for (const file of commandFiles) {
const command = require(../commands/${folder}/${file}
);
// Set a new item in the Collection
// With the key as the command name and the value as the exported module
client.commands.set(command.data.name + -${guildId}
, command);
client.commandArray.push(command.data.toJSON());
}
}
const rest = new REST({version: '10'}).setToken(process.env.token);
(async () => {
try {
console.log('Started refreshing application (/) commands.');
const response = await rest.put( Routes.applicationGuildCommands(clientId, guildId), { body: client.commandArray }, );
console.log('Successfully reloaded application (/) commands:', response); } catch (error) { console.error('Error while reloading application (/) commands:', error); } })();
} }
do you run that code every time your bot starts?
Yes
yeah dont
The rest script is meant to be in a separate file
You dont need to deploy every time your bot restarts
Only when you make changes to your commands
but every time I restart I make changes and it has always worked for a year but suddenly it no longer works.
when yoy make changes to your slasg commands, not the code behind them
And define not working
Do you get any errors, what logs and what doesnt
Nothing its starts refrashing and dont reloaded
why are you doing it so many times?
Thats your issue right there
You're ratelimited
I have also tried to start only this one guild but it does not work for this guild.
Use global commands
Not guild commands if you're deploying them to every guild
But my bot manages so many guilds with many different commands.
so i removed a few guilds from the rest but still it won't reload that one guild
Then at the least deploy just when joining
Not on every start
Thats just plain api spam
also you set the same commands for every guild in the code you show
yes i know i will fix the ha later but i just have the problem with a guild
Probably ratelimited, maybe wait a while
but can there also only be one guild ratelimited because all the others are working?
Thanks for the tip anyway, then I have implemented it now.
Okay, thanks for the information, I'll wait 24 hours and if it works, I'll be very grateful to you and if not, I'll get back to you
Yes I will do that
Thanks for the help I waited a while and now it works again and I adjusted my code so that it doesn't refresh the commands every time.