mirror of
https://github.com/veganhacktivists/arabot.git
synced 2025-11-03 15:49:50 +01:00
refactor(arabot): change console to sapphire-logger
This commit is contained in:
parent
8e7ed8442c
commit
f728e14163
49
package-lock.json
generated
49
package-lock.json
generated
@ -12,6 +12,7 @@
|
|||||||
"@prisma/client": "^4.0.0",
|
"@prisma/client": "^4.0.0",
|
||||||
"@sapphire/discord.js-utilities": "^6.0.0",
|
"@sapphire/discord.js-utilities": "^6.0.0",
|
||||||
"@sapphire/framework": "^4.0.1",
|
"@sapphire/framework": "^4.0.1",
|
||||||
|
"@sapphire/plugin-logger": "^3.0.1",
|
||||||
"@sapphire/plugin-scheduled-tasks": "^4.0.0",
|
"@sapphire/plugin-scheduled-tasks": "^4.0.0",
|
||||||
"@sapphire/plugin-subcommands": "^4.0.0",
|
"@sapphire/plugin-subcommands": "^4.0.0",
|
||||||
"@sapphire/stopwatch": "^1.4.1",
|
"@sapphire/stopwatch": "^1.4.1",
|
||||||
@ -427,6 +428,20 @@
|
|||||||
"npm": ">=7.0.0"
|
"npm": ">=7.0.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/@sapphire/plugin-logger": {
|
||||||
|
"version": "3.0.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/@sapphire/plugin-logger/-/plugin-logger-3.0.1.tgz",
|
||||||
|
"integrity": "sha512-sGAYL16bIe8SrUk8k+HOFGVWppSYi8T0F4T+hVCfYw9eiqTvqy5wPQcrzmd5hkvGINb8Ob8INNEl0In7PxXT6Q==",
|
||||||
|
"dependencies": {
|
||||||
|
"@sapphire/timestamp": "^1.0.0",
|
||||||
|
"colorette": "^2.0.19",
|
||||||
|
"tslib": "^2.4.0"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=v14.0.0",
|
||||||
|
"npm": ">=7.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/@sapphire/plugin-scheduled-tasks": {
|
"node_modules/@sapphire/plugin-scheduled-tasks": {
|
||||||
"version": "4.0.1",
|
"version": "4.0.1",
|
||||||
"resolved": "https://registry.npmjs.org/@sapphire/plugin-scheduled-tasks/-/plugin-scheduled-tasks-4.0.1.tgz",
|
"resolved": "https://registry.npmjs.org/@sapphire/plugin-scheduled-tasks/-/plugin-scheduled-tasks-4.0.1.tgz",
|
||||||
@ -518,6 +533,15 @@
|
|||||||
"npm": ">=7.0.0"
|
"npm": ">=7.0.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/@sapphire/timestamp": {
|
||||||
|
"version": "1.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/@sapphire/timestamp/-/timestamp-1.0.0.tgz",
|
||||||
|
"integrity": "sha512-80g0xYP4zxsgNizMO0HVf+LcM1mD/jxke4feSytDzw8u1pEPr1APfIz3Ix7JB9VI113p0KjLBMywl+ceaN7jrw==",
|
||||||
|
"engines": {
|
||||||
|
"node": ">=v14.0.0",
|
||||||
|
"npm": ">=7.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/@sapphire/ts-config": {
|
"node_modules/@sapphire/ts-config": {
|
||||||
"version": "3.3.4",
|
"version": "3.3.4",
|
||||||
"resolved": "https://registry.npmjs.org/@sapphire/ts-config/-/ts-config-3.3.4.tgz",
|
"resolved": "https://registry.npmjs.org/@sapphire/ts-config/-/ts-config-3.3.4.tgz",
|
||||||
@ -1067,6 +1091,11 @@
|
|||||||
"integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==",
|
"integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
|
"node_modules/colorette": {
|
||||||
|
"version": "2.0.19",
|
||||||
|
"resolved": "https://registry.npmjs.org/colorette/-/colorette-2.0.19.tgz",
|
||||||
|
"integrity": "sha512-3tlv/dIP7FWvj3BsbHrGLJ6l/oKh1O3TcgBqMn+yyCagOxc23fyzDS6HypQbgxWbkpDnf52p1LuR4eWDQ/K9WQ=="
|
||||||
|
},
|
||||||
"node_modules/concat-map": {
|
"node_modules/concat-map": {
|
||||||
"version": "0.0.1",
|
"version": "0.0.1",
|
||||||
"resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz",
|
"resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz",
|
||||||
@ -4081,6 +4110,16 @@
|
|||||||
"tslib": "^2.4.0"
|
"tslib": "^2.4.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"@sapphire/plugin-logger": {
|
||||||
|
"version": "3.0.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/@sapphire/plugin-logger/-/plugin-logger-3.0.1.tgz",
|
||||||
|
"integrity": "sha512-sGAYL16bIe8SrUk8k+HOFGVWppSYi8T0F4T+hVCfYw9eiqTvqy5wPQcrzmd5hkvGINb8Ob8INNEl0In7PxXT6Q==",
|
||||||
|
"requires": {
|
||||||
|
"@sapphire/timestamp": "^1.0.0",
|
||||||
|
"colorette": "^2.0.19",
|
||||||
|
"tslib": "^2.4.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
"@sapphire/plugin-scheduled-tasks": {
|
"@sapphire/plugin-scheduled-tasks": {
|
||||||
"version": "4.0.1",
|
"version": "4.0.1",
|
||||||
"resolved": "https://registry.npmjs.org/@sapphire/plugin-scheduled-tasks/-/plugin-scheduled-tasks-4.0.1.tgz",
|
"resolved": "https://registry.npmjs.org/@sapphire/plugin-scheduled-tasks/-/plugin-scheduled-tasks-4.0.1.tgz",
|
||||||
@ -4140,6 +4179,11 @@
|
|||||||
"resolved": "https://registry.npmjs.org/@sapphire/timer-manager/-/timer-manager-1.0.0.tgz",
|
"resolved": "https://registry.npmjs.org/@sapphire/timer-manager/-/timer-manager-1.0.0.tgz",
|
||||||
"integrity": "sha512-vxxnv75QPMGKt6IB6nL2xRJfwzcUQ9DBGzJLg6G8eS5O4u7j3IR/yr/GQsa4gIpjw6kQOgn8lUdnSTlpnERTbQ=="
|
"integrity": "sha512-vxxnv75QPMGKt6IB6nL2xRJfwzcUQ9DBGzJLg6G8eS5O4u7j3IR/yr/GQsa4gIpjw6kQOgn8lUdnSTlpnERTbQ=="
|
||||||
},
|
},
|
||||||
|
"@sapphire/timestamp": {
|
||||||
|
"version": "1.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/@sapphire/timestamp/-/timestamp-1.0.0.tgz",
|
||||||
|
"integrity": "sha512-80g0xYP4zxsgNizMO0HVf+LcM1mD/jxke4feSytDzw8u1pEPr1APfIz3Ix7JB9VI113p0KjLBMywl+ceaN7jrw=="
|
||||||
|
},
|
||||||
"@sapphire/ts-config": {
|
"@sapphire/ts-config": {
|
||||||
"version": "3.3.4",
|
"version": "3.3.4",
|
||||||
"resolved": "https://registry.npmjs.org/@sapphire/ts-config/-/ts-config-3.3.4.tgz",
|
"resolved": "https://registry.npmjs.org/@sapphire/ts-config/-/ts-config-3.3.4.tgz",
|
||||||
@ -4517,6 +4561,11 @@
|
|||||||
"integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==",
|
"integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
|
"colorette": {
|
||||||
|
"version": "2.0.19",
|
||||||
|
"resolved": "https://registry.npmjs.org/colorette/-/colorette-2.0.19.tgz",
|
||||||
|
"integrity": "sha512-3tlv/dIP7FWvj3BsbHrGLJ6l/oKh1O3TcgBqMn+yyCagOxc23fyzDS6HypQbgxWbkpDnf52p1LuR4eWDQ/K9WQ=="
|
||||||
|
},
|
||||||
"concat-map": {
|
"concat-map": {
|
||||||
"version": "0.0.1",
|
"version": "0.0.1",
|
||||||
"resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz",
|
"resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz",
|
||||||
|
|||||||
@ -32,6 +32,7 @@
|
|||||||
"@prisma/client": "^4.0.0",
|
"@prisma/client": "^4.0.0",
|
||||||
"@sapphire/discord.js-utilities": "^6.0.0",
|
"@sapphire/discord.js-utilities": "^6.0.0",
|
||||||
"@sapphire/framework": "^4.0.1",
|
"@sapphire/framework": "^4.0.1",
|
||||||
|
"@sapphire/plugin-logger": "^3.0.1",
|
||||||
"@sapphire/plugin-scheduled-tasks": "^4.0.0",
|
"@sapphire/plugin-scheduled-tasks": "^4.0.0",
|
||||||
"@sapphire/plugin-subcommands": "^4.0.0",
|
"@sapphire/plugin-subcommands": "^4.0.0",
|
||||||
"@sapphire/stopwatch": "^1.4.1",
|
"@sapphire/stopwatch": "^1.4.1",
|
||||||
|
|||||||
@ -139,7 +139,7 @@ export class BanCommand extends Command {
|
|||||||
logChannel = await guild.channels
|
logChannel = await guild.channels
|
||||||
.fetch(IDs.channels.logs.restricted) as TextChannel | undefined;
|
.fetch(IDs.channels.logs.restricted) as TextChannel | undefined;
|
||||||
if (logChannel === undefined) {
|
if (logChannel === undefined) {
|
||||||
console.error('Ban Error: Could not fetch log channel');
|
this.container.logger.error('Ban Error: Could not fetch log channel');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -241,7 +241,7 @@ export class BanCommand extends Command {
|
|||||||
logChannel = await guild.channels
|
logChannel = await guild.channels
|
||||||
.fetch(IDs.channels.logs.restricted) as TextChannel | undefined;
|
.fetch(IDs.channels.logs.restricted) as TextChannel | undefined;
|
||||||
if (logChannel === undefined) {
|
if (logChannel === undefined) {
|
||||||
console.error('Ban Error: Could not fetch log channel');
|
this.container.logger.error('Ban Error: Could not fetch log channel');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -138,7 +138,7 @@ export class UnbanCommand extends Command {
|
|||||||
modRestrict = await guild.channels
|
modRestrict = await guild.channels
|
||||||
.fetch(IDs.channels.restricted.moderators) as TextChannel | undefined;
|
.fetch(IDs.channels.restricted.moderators) as TextChannel | undefined;
|
||||||
if (modRestrict === undefined) {
|
if (modRestrict === undefined) {
|
||||||
console.error('Unban Error: Could not fetch mod channel');
|
this.container.logger.error('Unban Error: Could not fetch mod channel');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -230,7 +230,7 @@ export class UnbanCommand extends Command {
|
|||||||
modRestrict = await guild.channels
|
modRestrict = await guild.channels
|
||||||
.fetch(IDs.channels.restricted.moderators) as TextChannel | undefined;
|
.fetch(IDs.channels.restricted.moderators) as TextChannel | undefined;
|
||||||
if (modRestrict === undefined) {
|
if (modRestrict === undefined) {
|
||||||
console.error('Unban Error: Could not fetch mod channel');
|
this.container.logger.error('Unban Error: Could not fetch mod channel');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -23,6 +23,8 @@
|
|||||||
import { GatewayIntentBits } from 'discord.js';
|
import { GatewayIntentBits } from 'discord.js';
|
||||||
import { LogLevel, SapphireClient } from '@sapphire/framework';
|
import { LogLevel, SapphireClient } from '@sapphire/framework';
|
||||||
import { ScheduledTaskRedisStrategy } from '@sapphire/plugin-scheduled-tasks/register-redis';
|
import { ScheduledTaskRedisStrategy } from '@sapphire/plugin-scheduled-tasks/register-redis';
|
||||||
|
// eslint-disable-next-line import/no-extraneous-dependencies
|
||||||
|
import '@sapphire/plugin-logger/register';
|
||||||
|
|
||||||
require('dotenv').config();
|
require('dotenv').config();
|
||||||
|
|
||||||
|
|||||||
@ -71,7 +71,7 @@ export class VerificationJoinVCListener extends Listener {
|
|||||||
const guild = client.guilds.cache.get(newState.guild.id);
|
const guild = client.guilds.cache.get(newState.guild.id);
|
||||||
|
|
||||||
if (channel === null || member === null || guild === undefined) {
|
if (channel === null || member === null || guild === undefined) {
|
||||||
console.error('Verification channel not found');
|
this.container.logger.error('Verification channel not found');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -79,7 +79,7 @@ export class VerificationJoinVCListener extends Listener {
|
|||||||
const categoryGuild = guild.channels.cache.get(IDs.categories.verification);
|
const categoryGuild = guild.channels.cache.get(IDs.categories.verification);
|
||||||
const currentChannelGuild = guild.channels.cache.get(channel.id);
|
const currentChannelGuild = guild.channels.cache.get(channel.id);
|
||||||
if (currentChannelGuild === undefined || categoryGuild === undefined) {
|
if (currentChannelGuild === undefined || categoryGuild === undefined) {
|
||||||
console.error('Verification channel not found');
|
this.container.logger.error('Verification channel not found');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const currentChannel = currentChannelGuild as VoiceChannel;
|
const currentChannel = currentChannelGuild as VoiceChannel;
|
||||||
@ -530,7 +530,7 @@ export class VerificationJoinVCListener extends Listener {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default: {
|
default: {
|
||||||
console.error('Button clicked out of range');
|
this.container.logger.error('Button clicked out of range');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -739,7 +739,7 @@ export class VerificationJoinVCListener extends Listener {
|
|||||||
}) {
|
}) {
|
||||||
// Send a DM with when their verification is finished
|
// Send a DM with when their verification is finished
|
||||||
await this.finishDM(user, roles)
|
await this.finishDM(user, roles)
|
||||||
.catch(() => console.error('Verification: Closed DMs'));
|
.catch(() => this.container.logger.error('Verification: Closed DMs'));
|
||||||
|
|
||||||
// Not vegan
|
// Not vegan
|
||||||
if (!roles.vegan) {
|
if (!roles.vegan) {
|
||||||
|
|||||||
@ -52,14 +52,14 @@ export class VerificationLeaveVCListener extends Listener {
|
|||||||
const { guild } = newState;
|
const { guild } = newState;
|
||||||
|
|
||||||
if (channel === null || guild === undefined) {
|
if (channel === null || guild === undefined) {
|
||||||
console.error('Verification channel not found');
|
this.container.logger.error('Verification channel not found');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get the category
|
// Get the category
|
||||||
const categoryGuild = guild.channels.cache.get(IDs.categories.verification);
|
const categoryGuild = guild.channels.cache.get(IDs.categories.verification);
|
||||||
if (categoryGuild === null) {
|
if (categoryGuild === null) {
|
||||||
console.error('Verification channel not found');
|
this.container.logger.error('Verification channel not found');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const category = categoryGuild as CategoryChannel;
|
const category = categoryGuild as CategoryChannel;
|
||||||
@ -81,7 +81,7 @@ export class VerificationLeaveVCListener extends Listener {
|
|||||||
const roles = await fetchRoles(user.id);
|
const roles = await fetchRoles(user.id);
|
||||||
roles.push(IDs.roles.verifyBlock);
|
roles.push(IDs.roles.verifyBlock);
|
||||||
await user.roles.add(roles)
|
await user.roles.add(roles)
|
||||||
.catch(() => console.error('Verification: User left but bot still tried to add roles'));
|
.catch(() => this.container.logger.error('Verification: User left but bot still tried to add roles'));
|
||||||
// Create timeout block for user
|
// Create timeout block for user
|
||||||
// Counts the recent times they have incomplete verifications
|
// Counts the recent times they have incomplete verifications
|
||||||
const incompleteCount = await countIncomplete(user.id) % (leaveBan + 1);
|
const incompleteCount = await countIncomplete(user.id) % (leaveBan + 1);
|
||||||
@ -96,7 +96,7 @@ export class VerificationLeaveVCListener extends Listener {
|
|||||||
|
|
||||||
await user.user.send('You have been timed out as a verifier had not joined for 15 minutes or you disconnected from verification.\n\n'
|
await user.user.send('You have been timed out as a verifier had not joined for 15 minutes or you disconnected from verification.\n\n'
|
||||||
+ `You can verify again at: ${time(Math.round(Date.now() / 1000) + (banLength / 1000))}`)
|
+ `You can verify again at: ${time(Math.round(Date.now() / 1000) + (banLength / 1000))}`)
|
||||||
.catch(() => console.error('Verification: Closed DMs'));
|
.catch(() => this.container.logger.error('Verification: Closed DMs'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -183,7 +183,7 @@ export class VerificationLeaveVCListener extends Listener {
|
|||||||
const verification = listVoiceChannels.last() as VoiceChannel | undefined;
|
const verification = listVoiceChannels.last() as VoiceChannel | undefined;
|
||||||
|
|
||||||
if (verification === undefined) {
|
if (verification === undefined) {
|
||||||
console.error('Verification: Verification channel not found.');
|
this.container.logger.error('Verification: Verification channel not found.');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -44,7 +44,7 @@ export class VerificationReady extends Listener {
|
|||||||
category = await client.channels
|
category = await client.channels
|
||||||
.fetch(IDs.categories.verification) as CategoryChannel | undefined;
|
.fetch(IDs.categories.verification) as CategoryChannel | undefined;
|
||||||
if (category === undefined) {
|
if (category === undefined) {
|
||||||
console.error('verifyStart: Channel not found');
|
this.container.logger.error('verifyStart: Channel not found');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -41,7 +41,7 @@ export class VerificationReady extends Listener {
|
|||||||
if (welcome === undefined) {
|
if (welcome === undefined) {
|
||||||
welcome = await client.channels.fetch(IDs.channels.welcome) as TextChannel | undefined;
|
welcome = await client.channels.fetch(IDs.channels.welcome) as TextChannel | undefined;
|
||||||
if (welcome === undefined) {
|
if (welcome === undefined) {
|
||||||
console.error('verifyStart: Welcome not found');
|
this.container.logger.error('verifyStart: Welcome not found');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -33,7 +33,7 @@ export class VerifyTimeout extends ScheduledTask {
|
|||||||
channel = await this.container.client.channels
|
channel = await this.container.client.channels
|
||||||
.fetch(payload.channelId) as VoiceChannel | undefined;
|
.fetch(payload.channelId) as VoiceChannel | undefined;
|
||||||
if (channel === undefined) {
|
if (channel === undefined) {
|
||||||
console.error('verifyTimeout: Channel not found!');
|
this.container.logger.error('verifyTimeout: Channel not found!');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -41,7 +41,7 @@ export class VerifyTimeout extends ScheduledTask {
|
|||||||
if (channel.members.size < 2 && channel.members.has(payload.userId)) {
|
if (channel.members.size < 2 && channel.members.has(payload.userId)) {
|
||||||
const user = channel.members.get(payload.userId);
|
const user = channel.members.get(payload.userId);
|
||||||
if (user === undefined) {
|
if (user === undefined) {
|
||||||
console.error('verifyTimeout: GuildMember not found!');
|
this.container.logger.error('verifyTimeout: GuildMember not found!');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
await user.voice.disconnect();
|
await user.voice.disconnect();
|
||||||
|
|||||||
@ -31,7 +31,7 @@ export class VerifyUnblock extends ScheduledTask {
|
|||||||
if (guild === undefined) {
|
if (guild === undefined) {
|
||||||
guild = await this.container.client.guilds.fetch(payload.guildId);
|
guild = await this.container.client.guilds.fetch(payload.guildId);
|
||||||
if (guild === undefined) {
|
if (guild === undefined) {
|
||||||
console.error('verifyUnblock: Guild not found!');
|
this.container.logger.error('verifyUnblock: Guild not found!');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -41,7 +41,7 @@ export class VerifyUnblock extends ScheduledTask {
|
|||||||
if (user === undefined) {
|
if (user === undefined) {
|
||||||
user = await guild.members.fetch(payload.userId);
|
user = await guild.members.fetch(payload.userId);
|
||||||
if (user === undefined) {
|
if (user === undefined) {
|
||||||
console.error('verifyUnblock: GuildMember not found!');
|
this.container.logger.error('verifyUnblock: GuildMember not found!');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user