You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Discord.js中Interaction.followUp()无法生效,交互一直处于思考状态的问题求助

Discord.js中Interaction.followUp()无法生效,交互一直处于思考状态的问题求助

我最近在开发Discord机器人的一个查询角色成员的命令,碰到了个棘手的问题:interaction.deferReply()能正常触发,机器人显示“正在思考”,但后续调用interaction.followUp(...)完全没反应,交互就一直卡在“--- Bot is thinking...”的状态,而且控制台连错误提示都没有!

我用console.log一步步调试,日志显示代码从头到尾都执行完了——角色能正常获取,成员列表也能生成,可就是看不到机器人的后续回复。实在摸不着头脑,把相关代码贴出来求助大家:

依赖引入部分

const { SlashCommandBuilder, EmbedBuilder, ButtonBuilder, ButtonStyle, ActionRowBuilder, MessageButton } = require('@discordjs/builders')
const Data = require('../../data/data.json') // 数据存储,这个命令里没用到

命令定义代码(原代码存在截断,补全了合理逻辑)

module.exports = {
    data: new SlashCommandBuilder()
        .setName('inrole')
        .setDescription('Retrieve members of a role.')
        .addRoleOption(option => 
            option.setName("role")
                .setDescription("选择要查询的目标角色")
                .setRequired(true)),
    async execute(interaction) {
        // 先发送延迟回复,这一步正常
        await interaction.deferReply();
        
        // 获取用户选择的角色
        const targetRole = interaction.options.getRole('role');
        console.log(`当前查询角色:${targetRole.name},ID:${targetRole.id}`);
        
        // 生成成员列表字符串
        const memberList = targetRole.members.map(member => member.user.tag).join('\n') || '该角色暂无成员';
        console.log(`成员列表生成完成:\n${memberList}`);
        
        // 这里的followUp完全没反应
        await interaction.followUp({
            content: `角色 **${targetRole.name}** 的成员列表:\n${memberList}`
        });
    }
}

我自己排查了几个方向,但都没找到问题:

  • 权限方面:机器人有读取成员、发送消息的权限,而且deferReply能正常执行,应该不是权限的锅?
  • 异步处理:所有异步操作都加了await,日志也显示代码走到了followUp这一步
  • 参数格式:试过用普通文本、Embed、ActionRow,结果都一样没反应

有没有大佬遇到过类似的情况?或者能帮我看看哪里可能出问题了?真的卡在这里好久了😭

备注:内容来源于stack exchange,提问作者stacks

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.16 08:23:04