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(
const embed = new MessageEmbed() .setTitle('新成员加入') .setDescription(
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(
goodbyeChannel.send({ embeds: [embed] }); }); }
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
• 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.and what errors do you get
and the code doesnt look to be v14 but rather v13
I got this error
"discord.js": "^14.11.0"