如何修复斜杠命令在使用一次后消失
How to fix slash commands disappearing after one use
您好,我第一次在 js 中添加了斜线命令,并且喜欢在使用一次命令后消失,如下面的视频所示
// Slash Commands
const slashCommands = await globPromise(
`${process.cwd()}/SlashCommands/*/*.js`
);
const arrayOfSlashCommands = [];
slashCommands.map((value) => {
const file = require(value);
if (!file?.name) return;
client.slashCommands.set(file.name, file);
if (["MESSAGE", "USER"].includes(file.type)) delete file.description;
arrayOfSlashCommands.push(file);
});
client.on("ready", async () => {
// Register for a single guild
await client.guilds.cache
.get("900379296407896075")
.commands.set(arrayOfSlashCommands);
console.log('[Slash cmds] commands were loaded')
// Register for all the guilds the bot is in
// await client.application.commands.set(arrayOfSlashCommands);
});```
slash command handler that I use
您需要重新部署您的机器人,确保您已选择机器人和 application.commands,然后设置权限并使用底部的 link 将您的机器人 re-invite公会.
见下图:
您好,我第一次在 js 中添加了斜线命令,并且喜欢在使用一次命令后消失,如下面的视频所示
// Slash Commands
const slashCommands = await globPromise(
`${process.cwd()}/SlashCommands/*/*.js`
);
const arrayOfSlashCommands = [];
slashCommands.map((value) => {
const file = require(value);
if (!file?.name) return;
client.slashCommands.set(file.name, file);
if (["MESSAGE", "USER"].includes(file.type)) delete file.description;
arrayOfSlashCommands.push(file);
});
client.on("ready", async () => {
// Register for a single guild
await client.guilds.cache
.get("900379296407896075")
.commands.set(arrayOfSlashCommands);
console.log('[Slash cmds] commands were loaded')
// Register for all the guilds the bot is in
// await client.application.commands.set(arrayOfSlashCommands);
});```
slash command handler that I use
您需要重新部署您的机器人,确保您已选择机器人和 application.commands,然后设置权限并使用底部的 link 将您的机器人 re-invite公会.
见下图: