bot.on('guildMemberAdd', member => {
const welcomeembed = new Discord.RichEmbed()
.setColor(0xfcdb03)
.setTitle("Welcome")
.addField("Welcome " + member + "** to our Discord Server!**", "Please verify yourself in " + message.guild.channels.get('723965000062074990'))
member.guild.channels.get('723240170329079870').sendEmbed(welcomeembed);
});
当我使用常规消息时,机器人不会崩溃。也许我只是错误地使用了嵌入消息。
Object.defineProperty(this, 'client', { value: message.client });
^
TypeError: Cannot read property 'client' of undefined
at new MessageEmbed (C:\Users\456899754\Desktop\node_modules\discord.js\src\structures\MessageEmbed.js:13:60)
at Client.<anonymous> (C:\Users\456899754\Desktop\botfolder\bot.js:30:24)
at Client.emit (events.js:310:20)
at Guild._addMember (C:\Users\456899754\Desktop\node_modules\discord.js\src\structures\Guild.js:938:19)
at GuildMemberAddHandler.handle (C:\Users\456899754\Desktop\node_modules\discord.js\src\client\websocket\packets\handlers\GuildMemberAdd.js:12:13)
at WebSocketPacketManager.handle (C:\Users\456899754\Desktop\node_modules\discord.js\src\client\websocket\packets\WebSocketPacketManager.js:102:65)
at WebSocketConnection.onPacket (C:\Users\456899754\Desktop\node_modules\discord.js\src\client\websocket\WebSocketConnection.js:325:35)
at WebSocketConnection.onMessage (C:\Users\456899754\Desktop\node_modules\discord.js\src\client\websocket\WebSocketConnection.js:288:17)
at WebSocket.onMessage (C:\Users\456899754\Desktop\node_modules\ws\lib\EventTarget.js:103:16)
at WebSocket.emit (events.js:310:20)```
答案 0 :(得分:1)
您需要设置环境,以便可以看到错误。否则,您如何期望能够解决遇到的任何问题?如果您要使用批处理文件或类似文件启动bot,请对其进行编辑并在新行上添加PAUSE
,以在过程终止后强制窗口保持打开状态。否则,您可以尝试将节点进程输出到文件-查找实现此目的的方法。
该问题很可能引用了message.guild.channels.get('723965000062074990')
。没有message
,您正在guildMemberAdd
事件中。请改用member.guild
。
bot.on('guildMemberAdd', member => {
const welcomeembed = new Discord.RichEmbed()
.setColor(0xfcdb03)
.setTitle("Welcome")
.addField("Welcome " + member + "** to our Discord Server!**", "Please verify yourself in " + member.guild.channels.get('723965000062074990'))
member.guild.channels.get('723240170329079870').sendEmbed(welcomeembed);
});