From 46c2168f39cab04f1b2a437ce4be953c17e12fc5 Mon Sep 17 00:00:00 2001 From: Ducker Date: Sun, 9 May 2021 12:31:04 -0700 Subject: [PATCH] Fixed functionality for Discord.js v12 Now compatible with new Discord.js v12, also cleaned up config to make it more user friendly --- Discord Bot/bot.js | 30 +++++------------------------- Discord Bot/config.json | 12 +++++++++++- 2 files changed, 16 insertions(+), 26 deletions(-) diff --git a/Discord Bot/bot.js b/Discord Bot/bot.js index 0a09461..148045a 100644 --- a/Discord Bot/bot.js +++ b/Discord Bot/bot.js @@ -43,26 +43,6 @@ const LOG_LEVELS = { 'SPAM': 0 } -const BOT_CONFIG = { - 'apiRequestMethod': 'sequential', - 'messageCacheMaxSize': 50, - 'messageCacheLifetime': 0, - 'messageSweepInterval': 0, - 'fetchAllMembers': false, - 'disableEveryone': true, - 'sync': false, - 'restWsBridgeTimeout': 5000, // check these - 'restTimeOffset': 300, - 'disabledEvents': [ - 'CHANNEL_PINS_UPDATE', - 'TYPING_START' - ], - 'ws': { - 'large_threshold': 100, - 'compress': true - } -} - const USER_AGENT = `Roofstad bot ${require('./package.json').version} , Node ${process.version} (${process.platform}${process.arch})`; exports.start = function(SETUP) { @@ -124,7 +104,7 @@ exports.start = function(SETUP) { }); }; - const bot = new Discord.Client(BOT_CONFIG); + const bot = new Discord.Client(); const sendOrUpdate = function(embed) { if (MESSAGE !== undefined) { @@ -134,7 +114,7 @@ exports.start = function(SETUP) { log(LOG_LEVELS.ERROR,'Update failed'); }) } else { - let channel = bot.channels.get(CHANNEL_ID); + let channel = bot.channels.cache.get(CHANNEL_ID); if (channel !== undefined) { channel.fetchMessage(MESSAGE_ID).then((message) => { MESSAGE = message; @@ -346,7 +326,7 @@ exports.start = function(SETUP) { STATUS = status; embed.setDescription(`New message:\n\`\`\`${STATUS}\`\`\``); } - bot.channels.get(LOG_CHANNEL).send(embed); + bot.channels.cache.get(LOG_CHANNEL).send(embed); return log(LOG_LEVELS.INFO,`${message.author.username} updated status`); } } @@ -381,7 +361,7 @@ exports.start = function(SETUP) { .setDescription(message.content) .setTimestamp(new Date()); message.channel.send(embedUser).then(null).catch(console.error); - bot.channels.get(BUG_LOG_CHANNEL).send(embedStaff).then(null).catch(console.error); + bot.channels.cache.get(BUG_LOG_CHANNEL).send(embedStaff).then(null).catch(console.error); return message.delete(); } } @@ -390,7 +370,7 @@ exports.start = function(SETUP) { bot.login(BOT_TOKEN).then(null).catch(() => { log(LOG_LEVELS.ERROR,'Unable to login check your login token'); - console.error(e); + console.log(e); process.exit(1); }); diff --git a/Discord Bot/config.json b/Discord Bot/config.json index 36bc5bd..bf59616 100644 --- a/Discord Bot/config.json +++ b/Discord Bot/config.json @@ -1 +1,11 @@ -{"URL_SERVER":"http://37.59.54.107:30120","LOG_LEVEL":"2","BOT_TOKEN":"","CHANNEL_ID":"580073961287843891","MESSAGE_ID":"582584054038134787","SUGGESTION_CHANNEL":"580074129773035530","BUG_CHANNEL":"580074137268256778","BUG_LOG_CHANNEL":"582583366398771220","LOG_CHANNEL":"582583448636489738"} \ No newline at end of file +{ + "URL_SERVER":"", + "LOG_LEVEL":"2", + "BOT_TOKEN":"", + "CHANNEL_ID":"", + "MESSAGE_ID":"", + "SUGGESTION_CHANNEL":"", + "BUG_CHANNEL":"", + "BUG_LOG_CHANNEL":"", + "LOG_CHANNEL":"" + } \ No newline at end of file