From 7470c0c68f83d524ccd0139107e56e43af725ff9 Mon Sep 17 00:00:00 2001 From: hwangsihu Date: Sun, 29 Sep 2024 09:10:04 +0900 Subject: [PATCH] Fix --- biome.json | 10 +++++++--- src/events/node/Connect.ts | 4 ++-- src/events/node/Destroy.ts | 4 ++-- src/utils/BotLog.ts | 36 +++++++++++++++++++----------------- 4 files changed, 30 insertions(+), 24 deletions(-) diff --git a/biome.json b/biome.json index 9f480c557..c18b72644 100644 --- a/biome.json +++ b/biome.json @@ -8,7 +8,7 @@ }, "files": { "ignoreUnknown": true, - "ignore": ["node_modules/", "dist", "package.json", "tsconfig.json", ".vscode"] + "ignore": [".vscode", "dist", "node_modules", "package.json", "tsconfig.json"] }, "formatter": { "enabled": true, @@ -24,11 +24,15 @@ "linter": { "enabled": true, "rules": { - "recommended": false, "all": true, "complexity": { "noBannedTypes": "off", - "noExcessiveCognitiveComplexity": "off", + "noExcessiveCognitiveComplexity": { + "level": "warn", + "options": { + "maxAllowedComplexity": 30 + } + }, "noForEach": "off", "noUselessConstructor": "off" }, diff --git a/src/events/node/Connect.ts b/src/events/node/Connect.ts index 40b1e4110..654f14b33 100644 --- a/src/events/node/Connect.ts +++ b/src/events/node/Connect.ts @@ -1,6 +1,6 @@ import type { LavalinkNode } from 'lavalink-client'; import { Event, type Lavamusic } from '../../structures/index'; -import BotLog from '../../utils/BotLog'; +import { sendLog } from '../../utils/BotLog'; export default class Connect extends Event { constructor(client: Lavamusic, file: string) { @@ -48,7 +48,7 @@ export default class Connect extends Event { }, index * 1000); }); - BotLog.send(this.client, `Node ${node.id} is ready!`, 'success'); + sendLog(this.client, `Node ${node.id} is ready!`, 'success'); } } diff --git a/src/events/node/Destroy.ts b/src/events/node/Destroy.ts index 1e80bccc9..bb13526ba 100644 --- a/src/events/node/Destroy.ts +++ b/src/events/node/Destroy.ts @@ -1,6 +1,6 @@ import type { DestroyReasonsType, LavalinkNode } from 'lavalink-client'; import { Event, type Lavamusic } from '../../structures/index'; -import BotLog from '../../utils/BotLog'; +import { sendLog } from '../../utils/BotLog'; export default class Destroy extends Event { constructor(client: Lavamusic, file: string) { @@ -11,7 +11,7 @@ export default class Destroy extends Event { public async run(node: LavalinkNode, destroyReason?: DestroyReasonsType): Promise { this.client.logger.success(`Node ${node.id} is destroyed!`); - BotLog.send(this.client, `Node ${node.id} is destroyed: ${destroyReason}`, 'warn'); + sendLog(this.client, `Node ${node.id} is destroyed: ${destroyReason}`, 'warn'); } } diff --git a/src/utils/BotLog.ts b/src/utils/BotLog.ts index c5a1f1ae6..96267ca76 100644 --- a/src/utils/BotLog.ts +++ b/src/utils/BotLog.ts @@ -1,27 +1,29 @@ import type { TextChannel } from 'discord.js'; import type { Lavamusic } from '../structures/index'; -export default class BotLog { - public static send(client: Lavamusic, message: string, type: 'error' | 'warn' | 'info' | 'success' = 'info'): void { - if (!client?.channels.cache && client.env.LOG_CHANNEL_ID) return; +export function sendLog( + client: Lavamusic, + message: string, + type: 'error' | 'warn' | 'info' | 'success' = 'info', +): void { + if (!client?.channels.cache && client.env.LOG_CHANNEL_ID) return; - const channel = client.channels.cache.get(client.env.LOG_CHANNEL_ID!) as TextChannel; - if (!channel) return; + const channel = client.channels.cache.get(client.env.LOG_CHANNEL_ID!) as TextChannel; + if (!channel) return; - const colors = { - error: 0xff0000, - warn: 0xffff00, - info: 0x00ff00, - success: 0x00ff00, - } as const; + const colors = { + error: 0xff0000, + warn: 0xffff00, + info: 0x00ff00, + success: 0x00ff00, + } as const; - const color = colors[type]; - const embed = client.embed().setColor(color).setDescription(message).setTimestamp(); + const color = colors[type]; + const embed = client.embed().setColor(color).setDescription(message).setTimestamp(); - channel.send({ embeds: [embed] }).catch(() => { - null; - }); - } + channel.send({ embeds: [embed] }).catch(() => { + null; + }); } /**