Bot 获取 Slash 命令的 ID

编程入门 行业动态 更新时间:2024-10-05 19:11:44

Bot 获取 Slash <a href=https://www.elefans.com/category/jswz/34/1771323.html style=命令的 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

本文发布于:2024-05-30 20:06:40,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1770872.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:命令   Bot   Slash   ID

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!