TypeError: component.setDisabled 不是函数

编程入门 行业动态 更新时间:2024-10-03 21:25:49

TypeError: component.setDisabled 不是<a href=https://www.elefans.com/category/jswz/34/1771370.html style=函数"/>

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
打印正确。

回答如下:

更多推荐

TypeError: component.setDisabled 不是函数

本文发布于:2024-05-31 04:27:41,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1771271.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:函数   TypeError   component   setDisabled

发布评论

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

>www.elefans.com

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