You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Discord新成员加入时触发DiscordAPIError[50006]报错求助

解决Discord新成员加入时报错DiscordAPIError[50006]: Cannot send an empty message

这个报错的核心原因是你发送Embed的方式不符合Discord.js v14及以上版本的API规范。新版本中,channel.send()不再直接接受Embed实例作为参数,必须将Embed放入embeds数组,通过配置对象传递。

修正后的代码

Client.on('ready', () => {
    console.log(`Logged in as ${Client.user.tag}!`);
});

Client.on('guildMemberAdd', member => {
    const welcomeChannel = member.guild.channels.cache.find(channel => channel.name === 'général');

    if (welcomeChannel) {
        const avatar = member.user.displayAvatarURL({ format: 'png', dynamic: true, size: 128 });
        const welcomeEmbed = new Discord.EmbedBuilder()
            .setColor('#00ff00')
            .setTitle(`Welcome to the server, ${member.user.tag}!`)
            .setDescription('We are glad to have you here.')
            .setImage(avatar);

        // 关键修改:将Embed包装在embeds数组中传递
        welcomeChannel.send({ embeds: [welcomeEmbed] })
            .catch(err => console.error('发送欢迎消息失败:', err)); // 建议添加错误捕获排查问题
    }
});

额外检查项

  • 确认已正确导入EmbedBuilder:const { EmbedBuilder } = require('discord.js');
  • 检查Bot是否拥有目标频道的发送消息和嵌入链接权限
  • 验证频道名称général的拼写(区分大小写、特殊字符)完全匹配

内容的提问来源于stack exchange,提问作者Kirito

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.15 22:22:05