mirror of
https://github.com/veganhacktivists/arabot.git
synced 2025-07-07 11:11:00 +02: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",
|
||||
"@sapphire/discord.js-utilities": "^6.0.0",
|
||||
"@sapphire/framework": "^4.0.1",
|
||||
"@sapphire/plugin-logger": "^3.0.1",
|
||||
"@sapphire/plugin-scheduled-tasks": "^4.0.0",
|
||||
"@sapphire/plugin-subcommands": "^4.0.0",
|
||||
"@sapphire/stopwatch": "^1.4.1",
|
||||
@ -427,6 +428,20 @@
|
||||
"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": {
|
||||
"version": "4.0.1",
|
||||
"resolved": "https://registry.npmjs.org/@sapphire/plugin-scheduled-tasks/-/plugin-scheduled-tasks-4.0.1.tgz",
|
||||
@ -518,6 +533,15 @@
|
||||
"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": {
|
||||
"version": "3.3.4",
|
||||
"resolved": "https://registry.npmjs.org/@sapphire/ts-config/-/ts-config-3.3.4.tgz",
|
||||
@ -1067,6 +1091,11 @@
|
||||
"integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==",
|
||||
"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": {
|
||||
"version": "0.0.1",
|
||||
"resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz",
|
||||
@ -4081,6 +4110,16 @@
|
||||
"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": {
|
||||
"version": "4.0.1",
|
||||
"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",
|
||||
"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": {
|
||||
"version": "3.3.4",
|
||||
"resolved": "https://registry.npmjs.org/@sapphire/ts-config/-/ts-config-3.3.4.tgz",
|
||||
@ -4517,6 +4561,11 @@
|
||||
"integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==",
|
||||
"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": {
|
||||
"version": "0.0.1",
|
||||
"resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz",
|
||||
|
@ -32,6 +32,7 @@
|
||||
"@prisma/client": "^4.0.0",
|
||||
"@sapphire/discord.js-utilities": "^6.0.0",
|
||||
"@sapphire/framework": "^4.0.1",
|
||||
"@sapphire/plugin-logger": "^3.0.1",
|
||||
"@sapphire/plugin-scheduled-tasks": "^4.0.0",
|
||||
"@sapphire/plugin-subcommands": "^4.0.0",
|
||||
"@sapphire/stopwatch": "^1.4.1",
|
||||
|
@ -139,7 +139,7 @@ export class BanCommand extends Command {
|
||||
logChannel = await guild.channels
|
||||
.fetch(IDs.channels.logs.restricted) as TextChannel | 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;
|
||||
}
|
||||
}
|
||||
@ -241,7 +241,7 @@ export class BanCommand extends Command {
|
||||
logChannel = await guild.channels
|
||||
.fetch(IDs.channels.logs.restricted) as TextChannel | 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;
|
||||
}
|
||||
}
|
||||
|
@ -138,7 +138,7 @@ export class UnbanCommand extends Command {
|
||||
modRestrict = await guild.channels
|
||||
.fetch(IDs.channels.restricted.moderators) as TextChannel | 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;
|
||||
}
|
||||
}
|
||||
@ -230,7 +230,7 @@ export class UnbanCommand extends Command {
|
||||
modRestrict = await guild.channels
|
||||
.fetch(IDs.channels.restricted.moderators) as TextChannel | 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;
|
||||
}
|
||||
}
|
||||
|
@ -23,6 +23,8 @@
|
||||
import { GatewayIntentBits } from 'discord.js';
|
||||
import { LogLevel, SapphireClient } from '@sapphire/framework';
|
||||
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();
|
||||
|
||||
|
@ -71,7 +71,7 @@ export class VerificationJoinVCListener extends Listener {
|
||||
const guild = client.guilds.cache.get(newState.guild.id);
|
||||
|
||||
if (channel === null || member === null || guild === undefined) {
|
||||
console.error('Verification channel not found');
|
||||
this.container.logger.error('Verification channel not found');
|
||||
return;
|
||||
}
|
||||
|
||||
@ -79,7 +79,7 @@ export class VerificationJoinVCListener extends Listener {
|
||||
const categoryGuild = guild.channels.cache.get(IDs.categories.verification);
|
||||
const currentChannelGuild = guild.channels.cache.get(channel.id);
|
||||
if (currentChannelGuild === undefined || categoryGuild === undefined) {
|
||||
console.error('Verification channel not found');
|
||||
this.container.logger.error('Verification channel not found');
|
||||
return;
|
||||
}
|
||||
const currentChannel = currentChannelGuild as VoiceChannel;
|
||||
@ -530,7 +530,7 @@ export class VerificationJoinVCListener extends Listener {
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
console.error('Button clicked out of range');
|
||||
this.container.logger.error('Button clicked out of range');
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -739,7 +739,7 @@ export class VerificationJoinVCListener extends Listener {
|
||||
}) {
|
||||
// Send a DM with when their verification is finished
|
||||
await this.finishDM(user, roles)
|
||||
.catch(() => console.error('Verification: Closed DMs'));
|
||||
.catch(() => this.container.logger.error('Verification: Closed DMs'));
|
||||
|
||||
// Not vegan
|
||||
if (!roles.vegan) {
|
||||
|
@ -52,14 +52,14 @@ export class VerificationLeaveVCListener extends Listener {
|
||||
const { guild } = newState;
|
||||
|
||||
if (channel === null || guild === undefined) {
|
||||
console.error('Verification channel not found');
|
||||
this.container.logger.error('Verification channel not found');
|
||||
return;
|
||||
}
|
||||
|
||||
// Get the category
|
||||
const categoryGuild = guild.channels.cache.get(IDs.categories.verification);
|
||||
if (categoryGuild === null) {
|
||||
console.error('Verification channel not found');
|
||||
this.container.logger.error('Verification channel not found');
|
||||
return;
|
||||
}
|
||||
const category = categoryGuild as CategoryChannel;
|
||||
@ -81,7 +81,7 @@ export class VerificationLeaveVCListener extends Listener {
|
||||
const roles = await fetchRoles(user.id);
|
||||
roles.push(IDs.roles.verifyBlock);
|
||||
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
|
||||
// Counts the recent times they have incomplete verifications
|
||||
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'
|
||||
+ `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;
|
||||
|
||||
if (verification === undefined) {
|
||||
console.error('Verification: Verification channel not found.');
|
||||
this.container.logger.error('Verification: Verification channel not found.');
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -44,7 +44,7 @@ export class VerificationReady extends Listener {
|
||||
category = await client.channels
|
||||
.fetch(IDs.categories.verification) as CategoryChannel | undefined;
|
||||
if (category === undefined) {
|
||||
console.error('verifyStart: Channel not found');
|
||||
this.container.logger.error('verifyStart: Channel not found');
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -41,7 +41,7 @@ export class VerificationReady extends Listener {
|
||||
if (welcome === undefined) {
|
||||
welcome = await client.channels.fetch(IDs.channels.welcome) as TextChannel | undefined;
|
||||
if (welcome === undefined) {
|
||||
console.error('verifyStart: Welcome not found');
|
||||
this.container.logger.error('verifyStart: Welcome not found');
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -33,7 +33,7 @@ export class VerifyTimeout extends ScheduledTask {
|
||||
channel = await this.container.client.channels
|
||||
.fetch(payload.channelId) as VoiceChannel | undefined;
|
||||
if (channel === undefined) {
|
||||
console.error('verifyTimeout: Channel not found!');
|
||||
this.container.logger.error('verifyTimeout: Channel not found!');
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -41,7 +41,7 @@ export class VerifyTimeout extends ScheduledTask {
|
||||
if (channel.members.size < 2 && channel.members.has(payload.userId)) {
|
||||
const user = channel.members.get(payload.userId);
|
||||
if (user === undefined) {
|
||||
console.error('verifyTimeout: GuildMember not found!');
|
||||
this.container.logger.error('verifyTimeout: GuildMember not found!');
|
||||
return;
|
||||
}
|
||||
await user.voice.disconnect();
|
||||
|
@ -31,7 +31,7 @@ export class VerifyUnblock extends ScheduledTask {
|
||||
if (guild === undefined) {
|
||||
guild = await this.container.client.guilds.fetch(payload.guildId);
|
||||
if (guild === undefined) {
|
||||
console.error('verifyUnblock: Guild not found!');
|
||||
this.container.logger.error('verifyUnblock: Guild not found!');
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -41,7 +41,7 @@ export class VerifyUnblock extends ScheduledTask {
|
||||
if (user === undefined) {
|
||||
user = await guild.members.fetch(payload.userId);
|
||||
if (user === undefined) {
|
||||
console.error('verifyUnblock: GuildMember not found!');
|
||||
this.container.logger.error('verifyUnblock: GuildMember not found!');
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user