Skip to content
This repository was archived by the owner on Mar 14, 2024. It is now read-only.

Fixed functionality for Discord.js v12 #40

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 5 additions & 25 deletions Discord Bot/bot.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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) {
Expand All @@ -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;
Expand Down Expand Up @@ -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`);
}
}
Expand Down Expand Up @@ -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();
}
}
Expand All @@ -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);
});

Expand Down
12 changes: 11 additions & 1 deletion Discord Bot/config.json
Original file line number Diff line number Diff line change
@@ -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"}
{
"URL_SERVER":"",
"LOG_LEVEL":"2",
"BOT_TOKEN":"",
"CHANNEL_ID":"",
"MESSAGE_ID":"",
"SUGGESTION_CHANNEL":"",
"BUG_CHANNEL":"",
"BUG_LOG_CHANNEL":"",
"LOG_CHANNEL":""
}