简体   繁体   中英

Discord.js: Embed not sending

I'm trying to make a help embed command with reactions, but I keep getting this error I'm trying to make a help embed with reactions, but when I do,help? it doesnt send the embed???

I'm trying to make a help embed command with reactions, but I keep getting this error I'm trying to make a help embed with reactions, but when I do,help? it doesnt send the embed???

This is my code:

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.');
        });
    }
    }
}

You defined helpEmbed funcion but not called it.

try writing "helpEmbed()" after "execute(message, args){"

if still doesn't work: Check bot's permission Bot needs SEND_EMBED_LINKS Permission in that channel.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM