命令的 ID"/>
Bot 获取 Slash 命令的 ID
我在尝试获取 Discord 中的 Slash 命令 ID 时遇到问题
但我一遍又一遍地犯同样的错误
ReferenceError: applicationId is not defined
请告诉我我做错了什么
我的代码:
const axios = require('axios');
const applicationId = 'APPLICATION_ID'; // Replace with your application ID
const guildId = 'GUILD_ID'; // Replace with your guild ID
const commandName = 'COMMAND_NAME'; // Replace with the name of the command
const headers = {
Authorization: `Bot YOUR_BOT_TOKEN`,
'Content-Type': 'application/json'
};
axios.get(`/${applicationId}/guilds/${guildId}/commands`, { headers })
.then(response => {
const command = response.data.find(cmd => cmd.name === commandName);
if (command) {
console.log(`ID of ${commandName}: ${command.id}`);
} else {
console.log(`Command "${commandName}" not found`);
}
})
.catch(error => {
console.error(error);
});
回答如下:
更多推荐
Bot 获取 Slash 命令的 ID
发布评论