嵌入不发送不和谐js

时间:2021-06-21 22:05:43

标签: node.js discord discord.js

出于某种原因,下面的代码没有将嵌入发送到报告频道,我尝试了我可以修复的方法,但不会发送尝试过的 client.channels.cache.get(Channel).send(embed);这给了我一个错误尝试了多极方式,它仍然不会发送

const Discord = require("discord.js");

module.exports = {
    name: 'report',
    usage: '%report <reason>',
    description: 'reports a person',

    async execute(client, message, args) {
        let user = message.mentions.users.first() || await message.guild.members.cache.get(args[0])

        if (!user) return message.reply(`Please mention a user to report`)

        let reason = args.slice(1).join(" ")
        if (!reason) return message.reply(`Please enter a reason`)

        let Avatar = user.displayAvatarURL();
        let Channel = client.channels.cache.find(c => c.name == 'reports')
        if (!Channel) return message.reply(`Thier is no Valid channel to send a report please contact a staff member`)

        const embed = new Discord.MessageEmbed()
            .setTitle('New Report')
            .setDescription(`The member ${message.author.tag} has reported ${user.tag}`)
            .setColor("RED")
            .setThumbnail(Avatar)
            .addFields({
                name: "Member ID,",
                value: `${message.author.id}`,
                inline: true
            }, {
                name: "Member Tag,",
                value: `${message.author.tag}`,
                inline: true
            }, {
                name: "Reported ID,",
                value: `${user.id}`,
                inline: true
            }, {
                name: "Reported Tag,",
                value: `${user.tag}`,
                inline: true
            }, {
                name: "Reason,",
                value: `${reason}`,
                inline: true
            })



        client.channels.cache.get(Channel);
        message.channel.send(`Successfully sent the report!`)
    }
}

function findChannel(client, channelName) {
    var channelId = client.channels.cache.find(c => c.name.toLowerCase().includes(channelName.toLowerCase())).id;
}

1 个答案:

答案 0 :(得分:2)

试试

let Channel = message.guild.channels.cache.find(c => c.name == 'reports')

if (!Channel) return message.reply(`Thier is no Valid channel to send a report please contact a staff member`)

Channel.send(embed)

message.channel.send(`Successfully sent the report!`)