【问题标题】:Discord.js: Embed not sendingDiscord.js:嵌入不发送
【发布时间】:2021-03-14 13:38:09
【问题描述】:

我正在尝试创建一个带有反应的帮助嵌入命令,但我不断收到此错误 我正在尝试使用反应嵌入帮助,但是当我执行 !help 时,它不会发送嵌入???

我正在尝试制作带有反应的帮助嵌入命令,但我不断收到此错误我正在尝试制作带有反应的帮助嵌入,但是当我这样做!帮助时,它不会发送嵌入??? /p>

这是我的代码:

const Discord = require('discord.js')

module.exports = {
    name: 'help',
    description: "Help command",
    execute(message, args){
        async function helpEmbed(message, args) { 
            const helpEmbed = new Discord.MessageEmbed()
                .setTitle('Help!')
                .setDescription(`**React with one of the circles to get help with a category!**`)
                .addFields(
                    { name: 'Moderation', value: ':blue_circle:'},
                    { name: 'Fun', value: ':green_circle:'},
                    { name: 'Misc', value: ':purple_circle:'},
                )
                .setColor(4627199)
            message.channel.send({embed: helpEmbed}).then(embedMessage => {
                embedMessage.react('????')
                embedMessage.react('????')
                embedMessage.react('????')
            })
            const msg = await sendReact()
            const userReactions = message.reactions.cache.filter(reaction => reaction.users.cache.has(userId));
            const filter = (reaction, user) =>{
                return ['????', '????', '????'].includes(reaction.emoji.name) && user.id === message.author.id;
            }
            
            msg.awaitReactions(filter, { max: 1, time: 10000, errors: ['time'] })
        .then(collected => {
            const reaction = collected.first();

            if (reaction.emoji.name === '????') {
                try {
                    for (const reaction of userReactions.values()) {
                        reaction.users.remove(userId)
                    }
                } catch (error) {
                    console.error('Failed to remove reactions.')
                }

                message.channel.send('Moderation');
            } else if (reaction.emoji.name === '????') {
                try {
                    for (const reaction of userReactions.values()) {
                        reaction.users.remove(userId)
                    }
                } catch (error) {
                    console.error('Failed to remove reactions.')
                }
                message.channel.send('Fun');
            } else if (reaction.emoji.name === '????') {
                try {
                    for (const reaction of userReactions.values()) {
                        reaction.users.remove(userId)
                    }
                } catch (error) {
                    console.error('Failed to remove reactions.')
                }
                message.channel.send('Misc')
            }
        })
        .catch(collected => {
            message.reply('you reacted with neither a thumbs up, nor a thumbs down.');
        });
    }
    }
}

【问题讨论】:

  • 不确定这是否会有所帮助,但请尝试在第 6 行显示“execute()”。尝试不带引号的“执行:函数()”
  • @MsonC 它修复了错误,但它不发送嵌入
  • @MsonC 它什么也没做,错误消失了,但嵌入不发送
  • 请尝试设置“;”后面.setColor(4627199)
  • @GillesHeinesch 仍然不起作用

标签: javascript discord.js referenceerror


【解决方案1】:

你定义了 helpEmbed 函数但没有调用它。

尝试在“execute(message, args){”之后编写“helpEmbed()”

如果还是不行: 检查机器人的权限 机器人需要在该频道中SEND_EMBED_LINKS权限。

【讨论】:

    猜你喜欢
    • 2021-08-22
    • 1970-01-01
    • 2020-10-17
    • 2020-10-09
    • 1970-01-01
    • 2021-05-08
    • 2022-06-29
    • 2017-10-31
    • 2021-12-12
    相关资源
    最近更新 更多