black
black
DIAdiscord.js - Imagine a boo! 👻
Created by black on 4/8/2024 in #djs-questions
About slash command deploy
What do I have to change in the slash command to be considered deploying to the discord API? and what can I change without needing to deploy
3 replies
DIAdiscord.js - Imagine a boo! 👻
Created by black on 4/2/2024 in #djs-questions
Unknown interaction, sometimes
The problem is that sometimes it works and sometimes it generates an error, and I've already tried it without using defer, same result. How my Main class register commands
export default class MyClient extends Client {
constructor(options) {
super(options);

this.slashCommandsArray = [];
this.loadEvents();
this.loadSlashCommands();
};

async registerCommands() {
await this.application.commands.set(this.slashCommandsArray, "guild_id");
};
}
export default class MyClient extends Client {
constructor(options) {
super(options);

this.slashCommandsArray = [];
this.loadEvents();
this.loadSlashCommands();
};

async registerCommands() {
await this.application.commands.set(this.slashCommandsArray, "guild_id");
};
}
My interactionCreate Class
export default class InteractionCreate extends ReadyClient {
constructor(client) {
super(client, {
name: "interactionCreate"
})
}
execute = async(interaction) => {
const commandName = interaction.commandName;
const command = this.client.slashCommandsArray.find(cmd => cmd.name === commandName);

if(!command) return;

await interaction.deferReply();
await command.execute(interaction);
}
}
export default class InteractionCreate extends ReadyClient {
constructor(client) {
super(client, {
name: "interactionCreate"
})
}
execute = async(interaction) => {
const commandName = interaction.commandName;
const command = this.client.slashCommandsArray.find(cmd => cmd.name === commandName);

if(!command) return;

await interaction.deferReply();
await command.execute(interaction);
}
}
my test command
export default class Ping extends SlashCommands {
constructor(client) {
super(client, {
data: new SlashCommandBuilder()
.setName("ping")
.setDescription("Reply with pong")
});
};
execute = async(interaction) => {
await interaction.editReply("Pong!");
};
};
export default class Ping extends SlashCommands {
constructor(client) {
super(client, {
data: new SlashCommandBuilder()
.setName("ping")
.setDescription("Reply with pong")
});
};
execute = async(interaction) => {
await interaction.editReply("Pong!");
};
};
20 replies
DIAdiscord.js - Imagine a boo! 👻
Created by black on 4/1/2024 in #djs-questions
How this method works?
How client.application.commands.set() works to deploy commands? and is an alternative for this? https://discordjs.guide/creating-your-bot/command-deployment.html#command-registration
7 replies