Skip to content
Merged
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
4 changes: 3 additions & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,6 @@ DEVELOPERSDUNGEON=
TOPGGTOKEN=
WEBHOOK=
WEBHOOKTOKEN=
WEBHOOKVOTE=
WEBHOOKVOTE=
WARNWEBHOOKURL=
ERRORWEBHOOKURL=
2 changes: 1 addition & 1 deletion src/events/ready.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ module.exports = async (client) => {
activities: [{ name: `${process.env.BOTSTATUS || 'Would you?'}` }],
status: 'dnd',
});
}, 15000);
}, 60 * 60 * 1000); // Do this not so often because everytime you set the presence the bot won't receive any events for some seconds

await require('../util/dailyMsgs')(client);
};
1 change: 1 addition & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ const client = new Client({
});

const wouldyouComponents = async () => {
require('./util/keepAlive')(client);
await require('./util/wouldyouClient')(client);
await require('./util/dbHandler');
await require('./util/voteLogs');
Expand Down
157 changes: 157 additions & 0 deletions src/util/keepAlive.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,157 @@
require('dotenv')
.config();

const {
WebhookClient,
MessageEmbed,
} = require('discord.js');

const { inspect } = require('util');

const warnWebhook = new WebhookClient({
url: process.env.WARNWEBHOOKURL,
});
const errorWebhook = new WebhookClient({
url: process.env.ERRORWEBHOOKURL,
});

module.exports = (client) => {
client.on('debug', (e) => {
if (!e.includes('ratelimit')) return;

console.log('[BOT] Watch-out Possible Rate-limit...\n', e);
const embed = new MessageEmbed()
.setTitle('Watch-out Possible Rate-limit...')
.addFields([{
name: 'Info',
value: `\`\`\`${inspect(e, { depth: 0 })}\`\`\``,
}])
.setTimestamp();

warnWebhook
.send({
embeds: [embed],
})
.catch((err) => {
});
});

client.on('error', (e) => {
console.log('[BOT] Bot got a error...\n\n', e);
const embed = new MessageEmbed()
.setTitle('Bot got a error...')
.addFields([{
name: 'Error',
value: `\`\`\`${inspect(e, { depth: 0 })}\`\`\``,
}])
.setTimestamp();

errorWebhook
.send({
embeds: [embed],
})
.catch((err) => {
});
});

client.on('warn', async (info) => {
console.log('[BOT] Bot got a warn...\n\n', info);
const embed = new MessageEmbed()
.setTitle('Bot got a warn...')
.addFields([{
name: 'Info',
value: `\`\`\`${inspect(info, { depth: 0 })}\`\`\``,
}])
.setTimestamp();

warnWebhook
.send({
embeds: [embed],
})
.catch((err) => {
});
});

process.on('unhandledRejection', async (reason, p) => {
console.log('[BOT | FATAL ERROR] Unhandled Rejection/Catch');
console.log(reason, p);

const embed = new MessageEmbed()
.setTitle('New Unhandled Rejection/Catch')
.setDescription(`\`\`\`${reason}\`\`\``)
.setColor('#4E5D94')
.addFields([
{
name: 'Reason',
value: `\`\`\`${inspect(reason, { depth: 0 })}\`\`\``,
},
{
name: 'Promise',
value: `\`\`\`${inspect(p, { depth: 0 })}\`\`\``,
},
])
.setTimestamp();

errorWebhook
.send({
embeds: [embed],
})
.catch((err) => {
});
});

process.on('uncaughtException', async (err, origin) => {
console.log('[BOT | FATAL ERROR] Uncaught Exception/Catch');
console.log(err, origin);

const embed = new MessageEmbed()
.setTitle('New uncaughtException')
.setDescription(`\`\`\`${err}\`\`\``)
.setColor('#4E5D94')
.addFields([
{
name: 'Error',
value: `\`\`\`${inspect(err, { depth: 0 })}\`\`\``,
},
{
name: 'Origin',
value: `\`\`\`${inspect(origin, { depth: 0 })}\`\`\``,
},
])
.setTimestamp();

errorWebhook
.send({
embeds: [embed],
})
.catch((err) => {
});
});
process.on('uncaughtExceptionMonitor', async (err, origin) => {
console.log('[BOT | FATAL ERROR] Uncaught Exception/Catch (MONITOR)');
console.log(err, origin);

const embed = new MessageEmbed()
.setTitle('New uncaughtExceptionMonitor' + `${global?.CustomBot ? ' (Custom Bot)' : ''}`)
.setDescription(`\`\`\`${err}\`\`\``)
.setColor('#4E5D94')
.addFields([
{
name: 'Error',
value: `\`\`\`${inspect(err, { depth: 0 })}\`\`\``,
},
{
name: 'Origin',
value: `\`\`\`${inspect(origin, { depth: 0 })}\`\`\``,
},
])
.setTimestamp();

errorWebhook
.send({
embeds: [embed],
})
.catch((err) => {
});
});
};
6 changes: 3 additions & 3 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -260,9 +260,9 @@ axios@^0.27.2:
form-data "^4.0.0"

axios@^0.27.3:
version "1.1.2"
resolved "https://registry.yarnpkg.com/axios/-/axios-1.1.2.tgz#8b6f6c540abf44ab98d9904e8daf55351ca4a331"
integrity sha512-bznQyETwElsXl2RK7HLLwb5GPpOLlycxHCtrpDR/4RqqBzjARaOTo3jz4IgtntWUYee7Ne4S8UHd92VCuzPaWA==
version "1.2.1"
resolved "https://registry.yarnpkg.com/axios/-/axios-1.2.1.tgz#44cf04a3c9f0c2252ebd85975361c026cb9f864a"
integrity sha512-I88cFiGu9ryt/tfVEi4kX2SITsvDddTajXTOFmt2uK1ZVA8LytjtdeyefdQWEf5PU8w+4SSJDoYnggflB5tW4A==
dependencies:
follow-redirects "^1.15.0"
form-data "^4.0.0"
Expand Down