最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

TypeError: component.setDisabled 不是函数

网站源码admin35浏览0评论

TypeError: component.setDisabled 不是函数

TypeError: component.setDisabled 不是函数

尝试禁用 discord.js 14 中的消息按钮,当我按下其中一个按钮并且不起作用时。我得到这个错误:TypeError: component.setDisabled is not a function

代码:

module.exports = 
{
    id: "paper",
    async execute(interaction) 
    {        
        for (let row of interaction.messageponents) 
        {
            for (let component of rowponents) 
            {
                if (component.type === 2 && (
                    component.customId === "rock" ||
                    component.customId === "paper" ||
                    component.customId === "scissors"
                )) 
                {
                    console.log(component.customId);
                    component.setDisabled(true);
                }
            }
        }

        await interaction.message.edit({ components: interaction.messageponents });

        await interaction.reply("Tried to disable the message");
    }
}

我正在尝试使用不和谐的机器人和我在消息中放置的一些按钮来创建剪刀石头布射击游戏。我期望的是当我按下其中一个按钮时禁用消息的所有按钮。 (我很确定只有那个错误不起作用,因为交互正确回复了消息并且

customId
打印正确。

回答如下:
发布评论

评论列表(0)

  1. 暂无评论