Embedded errors

Hi! I'm having a problem with my robot! I don't know why, but the robot crashes when a member fails to join the trigger (I'm a newbie and I've tried everything, but the problem is still there) This provides me with the Code // 載入env變量 require("dotenv").config(); // Discord const BDB = require("./baseJS/BaseDiscordBot.js"); // js const CatchF = require("./baseJS/CatchF.js"); const slashM = require("./manager/slashManager/slashM.js"); const messageM = require("./manager/messageManager/messageM.js"); const messageUpdateM = require("./manager/messageManager/messageUpdateM.js"); const buttonM = require("./manager/buttonManager/buttonM.js"); const selectMenuM = require("./manager/selectMenuManager/selectMenuM.js"); const myKiritoM = require("./manager/mykiritoManager/myKiritoM.js"); const { Client, MessageEmbed } = require('discord.js'); //測試模塊 // json const configJson = require("./baseJS/Config.json"); // 健康狀態 const cornTask = require('./baseJS/CronTask.js'); //#endregion //#region 參數 //#region 音樂模組相關 global.isPlaying = new Map(); // 是否正在播放音樂 /** * let listData = { id: musicId, name: musicName, url: musicUrl }; */ global.songList = new Map(); // 歌單 global.connection = new Map(); // https://discord.js.org/#/docs/voice/main/class/VoiceConnection global.dispatcher = new Map(); // https://discord.js.org/#/docs/voice/main/class/AudioPlayer //#endregion //#region myKirito 相關 // 如果沒辦法下載資料就不會提供攻略組功能 global.isMykirito = false; // 轉生點 global.mkLevel = undefined; // 角色情報 global.mkSkill = undefined; // 樓層 global.mkBoss = undefined; // 掃地 global.ninePeople = new Map(); //#endregion //#endregion //#region Discord宣告 //#region 基本行為 let client; DoStart(); async function DoStart() { client = await BDB.Login(process.env.TOKEN); BDB.On(client, "ready", DiscordReady); BDB.On(client, "message", messageM.Start); // BDB.On(client, "messageUpdate", messageUpdateM.Start); BDB.On(client, "slash", slashM.Start); BDB.On(client, "button", buttonM.Start); BDB.On(client, "selectMenu", selectMenuM.Start); } //#endregion //#region 基本方法 async function DiscordReady(client) { // 定時自我呼叫 callMyself(); initGlobal(); // 註冊斜線命令 await slashM.InsertSlash(client); // 綁定菜單命令 await selectMenuM.InsertSelectMenu(client); // 綁定按鈕命令 await buttonM.InsertButton(client); // 下載攻略組資料 await myKiritoM.DoInsertMyKirito(client); // 設定狀態消息 BDB.CSetStatus(configJson?.status); // 系統訊息 CatchF.LogDo(Logged in as ${client.user.tag}!); //測試模塊 client.on('guildMemberAdd', (member) => { const welcomeChannel = member.guild.channels.cache.find(channel => channel.name === 'welcome-to-test');
const embed = new MessageEmbed() .setTitle('新成员加入') .setDescription(欢迎 ${member.user.tag} 加入我们的服务器!) .addField('用户名:', member.user.username) .addField('加入日期:', member.joinedAt.toLocaleString()) .setColor('#00FF00') .setTimestamp();
welcomeChannel.send({ embeds: [embed] }); });
client.on('guildMemberRemove', (member) => { const goodbyeChannel = member.guild.channels.cache.find(channel => channel.name === 'welcome-to-test');
const embed = new MessageEmbed() .setTitle('成员退出') .setDescription(${member.user.tag} 已离开服务器。) .addField('用户名:', member.user.username) .setColor('#FF0000') .setTimestamp();
goodbyeChannel.send({ embeds: [embed] }); }); }
discord.js
discord.js
discord.js is a powerful Node.js module that allows you to interact with the Discord API very easily. It takes a much more object-oriented approach than most other JS Discord libraries, making your bot's code significantly tidier and easier to comprehend.
5 Replies
d.js toolkit
d.js toolkit12mo ago
• What's your exact discord.js npm list discord.js and node node -v version? • Post the full error stack trace, not just the top part! • Show your code! • Explain what exactly your issue is. • Not a discord.js issue? Check out #useful-servers.
d.js docs
d.js docs12mo ago
To share long code snippets use a service like gist, sourcebin, starbin, or similar instead of posting them as large code blocks.
treble/luna
treble/luna12mo ago
and what errors do you get and the code doesnt look to be v14 but rather v13
FuLin.
FuLin.12mo ago
I got this error
C:\Users\Alice\Desktop\Alice v1.1 Test bot\alice.js:94
const embed = new MessageEmbed()
^

TypeError: MessageEmbed is not a constructor
at Client.<anonymous> (C:\Users\Alice\Desktop\Alice v1.1 Test bot\alice.js:94:17)
at Client.emit (node:events:513:28)
at module.exports [as GUILD_MEMBER_ADD] (C:\Users\Alice\Desktop\Alice v1.1 Test bot\node_modules\discord.js\src\client\websocket\handlers\GUILD_MEMBER_ADD.js:17:14)
at WebSocketManager.handlePacket (C:\Users\Alice\Desktop\Alice v1.1 Test bot\node_modules\discord.js\src\client\websocket\WebSocketManager.js:354:31)
at WebSocketManager.<anonymous> (C:\Users\Alice\Desktop\Alice v1.1 Test bot\node_modules\discord.js\src\client\websocket\WebSocketManager.js:238:12)
at WebSocketManager.emit (C:\Users\Alice\Desktop\Alice v1.1 Test bot\node_modules\@vladfrangu\async_event_emitter\dist\index.js:282:31)
at WebSocketShard.<anonymous> (C:\Users\Alice\Desktop\Alice v1.1 Test bot\node_modules\@discordjs\ws\dist\index.js:1103:51)
at WebSocketShard.emit (C:\Users\Alice\Desktop\Alice v1.1 Test bot\node_modules\@vladfrangu\async_event_emitter\dist\index.js:282:31)
at WebSocketShard.onMessage (C:\Users\Alice\Desktop\Alice v1.1 Test bot\node_modules\@discordjs\ws\dist\index.js:938:14)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

Node.js v18.16.1
C:\Users\Alice\Desktop\Alice v1.1 Test bot\alice.js:94
const embed = new MessageEmbed()
^

TypeError: MessageEmbed is not a constructor
at Client.<anonymous> (C:\Users\Alice\Desktop\Alice v1.1 Test bot\alice.js:94:17)
at Client.emit (node:events:513:28)
at module.exports [as GUILD_MEMBER_ADD] (C:\Users\Alice\Desktop\Alice v1.1 Test bot\node_modules\discord.js\src\client\websocket\handlers\GUILD_MEMBER_ADD.js:17:14)
at WebSocketManager.handlePacket (C:\Users\Alice\Desktop\Alice v1.1 Test bot\node_modules\discord.js\src\client\websocket\WebSocketManager.js:354:31)
at WebSocketManager.<anonymous> (C:\Users\Alice\Desktop\Alice v1.1 Test bot\node_modules\discord.js\src\client\websocket\WebSocketManager.js:238:12)
at WebSocketManager.emit (C:\Users\Alice\Desktop\Alice v1.1 Test bot\node_modules\@vladfrangu\async_event_emitter\dist\index.js:282:31)
at WebSocketShard.<anonymous> (C:\Users\Alice\Desktop\Alice v1.1 Test bot\node_modules\@discordjs\ws\dist\index.js:1103:51)
at WebSocketShard.emit (C:\Users\Alice\Desktop\Alice v1.1 Test bot\node_modules\@vladfrangu\async_event_emitter\dist\index.js:282:31)
at WebSocketShard.onMessage (C:\Users\Alice\Desktop\Alice v1.1 Test bot\node_modules\@discordjs\ws\dist\index.js:938:14)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

Node.js v18.16.1
"discord.js": "^14.11.0"
d.js docs
d.js docs12mo ago
guide Additional Information: Breaking Changes - MessageEmbed read more