diff --git a/.github/ISSUE_TEMPLATE/bug_report.yaml b/.github/ISSUE_TEMPLATE/bug_report.yaml index fc85263e1..2e04496e6 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.yaml +++ b/.github/ISSUE_TEMPLATE/bug_report.yaml @@ -32,7 +32,7 @@ body: attributes: label: "Operating System" description: "Which operating system and version are you using?" - placeholder: "e.g., Windows 10, macOS 13, Ubuntu 20.04" + placeholder: "e.g., Windows 11 24H2, macOS 15.1, Ubuntu 20.04" validations: required: true @@ -48,10 +48,10 @@ body: id: java-version attributes: label: "java version" - description: "Specify the version of Java that you are using." + description: "Specify the version of Java that you are using. If you are not self-hosting a Lavalink server, you can leave this blank." placeholder: "e.g., 17" validations: - required: true + required: false - type: input id: app-version diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 5cdd9b492..d528eddd6 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -1,19 +1,19 @@ version: 2 updates: - package-ecosystem: npm - directory: "/" + directory: / schedule: interval: daily - time: "00:00" + time: 00:00 allow: - dependency-type: all open-pull-requests-limit: 10 rebase-strategy: auto - package-ecosystem: github-actions - directory: "/" + directory: / schedule: - interval: "daily" - time: "00:00" + interval: daily + time: 00:00 allow: - dependency-type: all open-pull-requests-limit: 10 diff --git a/Lavalink/example.application.yml b/Lavalink/example.application.yml index 7b309cbcd..4083dbb46 100644 --- a/Lavalink/example.application.yml +++ b/Lavalink/example.application.yml @@ -34,11 +34,13 @@ plugins: yandexmusic: false # Enable Yandex Music source flowerytts: false # Enable Flowery TTS source youtube: true # Enable YouTube search source (https://github.com/topi314/LavaSearch) + vkmusic: false # Enable Vk Music source lyrics-sources: spotify: false # Enable Spotify lyrics source deezer: false # Enable Deezer lyrics source youtube: false # Enable YouTube lyrics source yandexmusic: false # Enable Yandex Music lyrics source + vkmusic: false # Enable Vk Music lyrics source spotify: clientId: "your client id" clientSecret: "your client secret" @@ -46,6 +48,7 @@ plugins: countryCode: "US" # the country code you want to use for filtering the artists top tracks. See https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2 playlistLoadLimit: 6 # The number of pages at 100 tracks each albumLoadLimit: 6 # The number of pages at 50 tracks each + resolveArtistsInSearch: true # Whether to resolve artists in track search results (can be slow) localFiles: false # Enable local files support with Spotify playlists. Please note `uri` & `isrc` will be `null` & `identifier` will be `"local"` applemusic: countryCode: "US" # the country code you want to use for filtering the artists top tracks and language. See https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2 @@ -61,6 +64,8 @@ plugins: albumLoadLimit: 6 # The number of pages at 300 tracks each deezer: masterDecryptionKey: "your master decryption key" # the master key used for decrypting the deezer tracks. (yes this is not here you need to get it from somewhere else) + # arl: "your deezer arl" # the arl cookie used for accessing the deezer api this is optional but required for formats above MP3_128 + formats: [ "FLAC", "MP3_320", "MP3_256", "MP3_128", "MP3_64", "AAC_64" ] # the formats you want to use for the deezer tracks. "FLAC", "MP3_320", "MP3_256" & "AAC_64" are only available for premium users and require a valid arl yandexmusic: accessToken: "your access token" # the token used for accessing the yandex music api. See https://github.com/TopiSenpai/LavaSrc#yandex-music playlistLoadLimit: 1 # The number of pages at 100 tracks each @@ -74,6 +79,11 @@ plugins: audioFormat: "mp3" # supported formats are: mp3, ogg_opus, ogg_vorbis, aac, wav, and flac. Default format is mp3 youtube: countryCode: "US" # the country code you want to use for searching lyrics via ISRC. See https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2 + vkmusic: + userToken: "your user token" # This token is needed for authorization in the api. Guide: https://github.com/topi314/LavaSrc#vk-music + playlistLoadLimit: 1 # The number of pages at 50 tracks each + artistLoadLimit: 1 # The number of pages at 10 tracks each + recommendationsLoadLimit: 10 # Number of tracks youtube: enabled: true # Whether this source can be used. allowSearch: true # Whether "ytsearch:" and "ytmsearch:" can be used. @@ -85,8 +95,8 @@ plugins: - MUSIC - WEB - ANDROID_TESTSUITE - - ANDROID_MUSIC - TVHTML5EMBEDDED + - ANDROID_MUSIC - ANDROID_LITE - MEDIA_CONNECT - IOS @@ -104,11 +114,11 @@ lavalink: snapshot: false # set to true if you want to use snapshot builds - dependency: "com.github.topi314.lavasearch:lavasearch-plugin:1.0.0" snapshot: false # set to true if you want to use snapshot builds - - dependency: "com.github.topi314.lavasrc:lavasrc-plugin:4.2.0" + - dependency: "com.github.topi314.lavasrc:lavasrc-plugin:4.3.0" snapshot: false # set to true if you want to use snapshot builds - dependency: "com.github.topi314.sponsorblock:sponsorblock-plugin:3.0.1" snapshot: false # set to true if you want to use snapshot builds - - dependency: "dev.lavalink.youtube:youtube-plugin:1.8.0" + - dependency: "dev.lavalink.youtube:youtube-plugin:1.8.3" snapshot: false # set to true if you want to use snapshot builds pluginsDir: './plugins' server: diff --git a/locales/Korean.json b/locales/Korean.json index ca1dd509f..0ff651474 100644 --- a/locales/Korean.json +++ b/locales/Korean.json @@ -36,7 +36,7 @@ "content": "안녕하세요! 저는 [Lavamusic](https://github.com/appujet/lavamusic)와 Discord.js로 만들어진 음악 봇, {bot}이에요. 명령어에 대한 자세한 정보를 얻고 싶다면 `{prefix}help <명령어>`를 사용해보세요.", "title": "도움말 메뉴", "not_found": "`{cmdName}` 명령어는 존재하지 않아요.", - "help_cmd": "**설명:** {description}\n**사용 방법:** {usage}\n**예시:** {examples}\n**줄인 명령어:** {aliases}\n**카테고리:** {category}\n**쿨다운:** {cooldown}초\n**필요한 권한:** {premUser}\n**봇에게 필요한 권한:** {premBot}\n**개발자 전용:** {dev}\n**빗금 명령어 사용 가능:** {slash}\n**인수 필요:** {args}\n**노래 재생 중에만 사용 가능:** {player}\n**DJ만 사용 가능:** {dj}\n**DJ에게 필요한 권한:** {djPerm}\n**음성 채널 접속 중에만 사용 가능:** {voice}", + "help_cmd": "**설명:** {description}\n**사용 방법:** {usage}\n**예시:** {examples}\n**명령어 별칭:** {aliases}\n**카테고리:** {category}\n**쿨다운:** {cooldown}초\n**필요한 권한:** {premUser}\n**봇에게 필요한 권한:** {premBot}\n**개발자 전용:** {dev}\n**빗금 명령어 사용 가능:** {slash}\n**인수 필요:** {args}\n**노래 재생 중에만 사용 가능:** {player}\n**DJ만 사용 가능:** {dj}\n**DJ에게 필요한 권한:** {djPerm}\n**음성 채널 접속 중에만 사용 가능:** {voice}", "footer": "명령어에 대한 자세한 내용을 보려면 {prefix}help 를 사용하세요." }, "botinfo": { @@ -460,9 +460,9 @@ } }, "list": { - "description": "사용자의 모든 플레이리스트를 알려줘요", + "description": "사용자의 모든 플레이리스트를 확인해요", "options": { - "user": "플레이리스트 목록을 가져올 사용자" + "user": "플레이리스트 목록을 확인할 사용자" }, "messages": { "no_playlists": "플레이리스트가 없어요.", @@ -507,7 +507,7 @@ "provide_playlist": "플레이리스트를 지정해주세요.", "provide_user": "유저를 지정해주세요.", "playlist_not_exist": "그 플레이리스트는 존재하지 않아요.", - "playlist_stolen": "`{playlist}`를 {user}에게서 가져왔어요.", + "playlist_stolen": "`{playlist}` 플레이리스트를 {user}님에게서 가져왔어요.", "error_occurred": "플레이리스트를 가져오는 도중 오류가 발생했어요." } } @@ -636,12 +636,12 @@ "forward_limit": "더 이상 빨리감기할 수 없어요.", "forwarded": "노래를 빨리감기했어요.", "forward_footer": "{displayName}님에 의해 빨리감기됨", - "button_not_available": "이 버튼은 사용할 수 없어요.", + "button_not_available": "사용할 수 없는 버튼이에요.", "no_music_playing": "현재 재생 중인 노래가 없어요." } }, "Evaluate code": "코드를 실행해요", - "Leave a guild": "서버를 떠나요", - "List all guilds the bot is in": "봇이 들어가 있는 서버를 알려줘요", + "Leave a guild": "봇을 서버에서 퇴장시켜요", + "List all guilds the bot is in": "봇이 들어가 있는 서버를 확인해요", "Restart the bot": "봇을 재시작해요" } diff --git a/prisma/example.mongodb.schema.prisma b/prisma/example.mongodb.schema.prisma index d3ff94d23..791376379 100644 --- a/prisma/example.mongodb.schema.prisma +++ b/prisma/example.mongodb.schema.prisma @@ -15,53 +15,53 @@ datasource db { } model Bot { - botId String @id @map("_id") - totalPlaySong Int + botId String @id @map("_id") + totalPlaySong Int } model Guild { - guildId String @id @map("_id") - prefix String - language String? @default("EnglishUS") - stay Stay? - dj Dj? - roles Role[] - setup Setup? + guildId String @id @map("_id") + prefix String + language String? @default("EnglishUS") + stay Stay? + dj Dj? + roles Role[] + setup Setup? } model Stay { - guildId String @id @map("_id") - textId String - voiceId String - Guild Guild @relation(fields: [guildId], references: [guildId]) + guildId String @id @map("_id") + textId String + voiceId String + Guild Guild @relation(fields: [guildId], references: [guildId]) } model Dj { - guildId String @id @map("_id") - mode Boolean - Guild Guild @relation(fields: [guildId], references: [guildId]) + guildId String @id @map("_id") + mode Boolean + Guild Guild @relation(fields: [guildId], references: [guildId]) } model Role { - guildId String @id @map("_id") - roleId String - Guild Guild @relation(fields: [guildId], references: [guildId]) + guildId String @id @map("_id") + roleId String + Guild Guild @relation(fields: [guildId], references: [guildId]) - @@unique([guildId, roleId]) + @@unique([guildId, roleId]) } model Playlist { - id String @id @default(uuid()) @map("_id") - userId String - name String - tracks String? // Store the array of encoded tracks as a JSON string + id String @id @default(uuid()) @map("_id") + userId String + name String + tracks String? // Store the array of encoded tracks as a JSON string - @@unique([userId, name]) + @@unique([userId, name]) } model Setup { - guildId String @id @map("_id") - textId String - messageId String - Guild Guild @relation(fields: [guildId], references: [guildId]) -} \ No newline at end of file + guildId String @id @map("_id") + textId String + messageId String + Guild Guild @relation(fields: [guildId], references: [guildId]) +} diff --git a/prisma/example.postgresql.schema.prisma b/prisma/example.postgresql.schema.prisma index a2f5f8307..df0e8f1ac 100644 --- a/prisma/example.postgresql.schema.prisma +++ b/prisma/example.postgresql.schema.prisma @@ -5,63 +5,63 @@ // Try Prisma Accelerate: https://pris.ly/cli/accelerate-init generator client { - provider = "prisma-client-js" - binaryTargets = ["native", "debian-openssl-3.0.x"] + provider = "prisma-client-js" + binaryTargets = ["native", "debian-openssl-3.0.x"] } datasource db { - provider = "postgresql" - url = env("DATABASE_URL") + provider = "postgresql" + url = env("DATABASE_URL") } model Bot { - botId String @unique - totalPlaySong Int + botId String @unique + totalPlaySong Int } model Guild { - guildId String @id - prefix String - language String? @default("EnglishUS") - stay Stay? - dj Dj? - roles Role[] - setup Setup? + guildId String @id + prefix String + language String? @default("EnglishUS") + stay Stay? + dj Dj? + roles Role[] + setup Setup? } model Stay { - guildId String @id - textId String - voiceId String - Guild Guild @relation(fields: [guildId], references: [guildId]) + guildId String @id + textId String + voiceId String + Guild Guild @relation(fields: [guildId], references: [guildId]) } model Dj { - guildId String @id - mode Boolean - Guild Guild @relation(fields: [guildId], references: [guildId]) + guildId String @id + mode Boolean + Guild Guild @relation(fields: [guildId], references: [guildId]) } model Role { - guildId String - roleId String - Guild Guild @relation(fields: [guildId], references: [guildId]) + guildId String + roleId String + Guild Guild @relation(fields: [guildId], references: [guildId]) - @@unique([guildId, roleId]) + @@unique([guildId, roleId]) } model Playlist { - id String @id @default(uuid()) - userId String - name String - tracks String? // Store the array of encoded tracks as a JSON string + id String @id @default(uuid()) + userId String + name String + tracks String? // Store the array of encoded tracks as a JSON string - @@unique([userId, name]) + @@unique([userId, name]) } model Setup { - guildId String @id - textId String - messageId String - Guild Guild @relation(fields: [guildId], references: [guildId]) -} \ No newline at end of file + guildId String @id + textId String + messageId String + Guild Guild @relation(fields: [guildId], references: [guildId]) +} diff --git a/prisma/schema.prisma b/prisma/schema.prisma index 2187ca2dd..98d73c2b3 100644 --- a/prisma/schema.prisma +++ b/prisma/schema.prisma @@ -5,63 +5,63 @@ // Try Prisma Accelerate: https://pris.ly/cli/accelerate-init generator client { - provider = "prisma-client-js" - binaryTargets = ["native", "debian-openssl-3.0.x"] + provider = "prisma-client-js" + binaryTargets = ["native", "debian-openssl-3.0.x"] } datasource db { - provider = "sqlite" - url = "file:./lavamusic.db" + provider = "sqlite" + url = "file:./lavamusic.db" } model Bot { - botId String @unique - totalPlaySong Int + botId String @unique + totalPlaySong Int } model Guild { - guildId String @id - prefix String - language String? @default("EnglishUS") - stay Stay? - dj Dj? - roles Role[] - setup Setup? + guildId String @id + prefix String + language String? @default("EnglishUS") + stay Stay? + dj Dj? + roles Role[] + setup Setup? } model Stay { - guildId String @id - textId String - voiceId String - Guild Guild @relation(fields: [guildId], references: [guildId]) + guildId String @id + textId String + voiceId String + Guild Guild @relation(fields: [guildId], references: [guildId]) } model Dj { - guildId String @id - mode Boolean - Guild Guild @relation(fields: [guildId], references: [guildId]) + guildId String @id + mode Boolean + Guild Guild @relation(fields: [guildId], references: [guildId]) } model Role { - guildId String - roleId String - Guild Guild @relation(fields: [guildId], references: [guildId]) + guildId String + roleId String + Guild Guild @relation(fields: [guildId], references: [guildId]) - @@unique([guildId, roleId]) + @@unique([guildId, roleId]) } model Playlist { - id String @id @default(uuid()) - userId String - name String - tracks String? // Store the array of encoded tracks as a JSON string + id String @id @default(uuid()) + userId String + name String + tracks String? // Store the array of encoded tracks as a JSON string - @@unique([userId, name]) + @@unique([userId, name]) } model Setup { - guildId String @id - textId String - messageId String - Guild Guild @relation(fields: [guildId], references: [guildId]) -} \ No newline at end of file + guildId String @id + textId String + messageId String + Guild Guild @relation(fields: [guildId], references: [guildId]) +} diff --git a/src/commands/config/247.ts b/src/commands/config/247.ts index 1bbe2f759..bb14fb48a 100644 --- a/src/commands/config/247.ts +++ b/src/commands/config/247.ts @@ -64,7 +64,7 @@ export default class _247 extends Command { embeds: [embed.setDescription(ctx.locale('cmd.247.messages.enabled')).setColor(this.client.color.main)], }); } catch (error) { - console.error('Error in 247 command:', error); + client.logger.error('Error in 247 command:', error); return await ctx.sendMessage({ embeds: [embed.setDescription(ctx.locale('cmd.247.errors.generic')).setColor(client.color.red)], }); diff --git a/src/commands/config/Language.ts b/src/commands/config/Language.ts index f19f553bd..e9e5f4ff0 100644 --- a/src/commands/config/Language.ts +++ b/src/commands/config/Language.ts @@ -1,4 +1,5 @@ import type { AutocompleteInteraction } from 'discord.js'; +import { env } from '../../env'; import { Command, type Context, type Lavamusic } from '../../structures/index'; import { Language, LocaleFlags } from '../../types'; @@ -60,10 +61,13 @@ export default class LanguageCommand extends Command { } else { subCommand = args.shift(); } + + const defaultLanguage = env.DEFAULT_LANGUAGE || Language.EnglishUS; + if (subCommand === 'set') { const embed = client.embed().setColor(this.client.color.main); - const locale = await client.db.getLanguage(ctx.guild!.id); + const locale = (await client.db.getLanguage(ctx.guild!.id)) || defaultLanguage; let lang: string; @@ -123,8 +127,8 @@ export default class LanguageCommand extends Command { }); } - await client.db.updateLanguage(ctx.guild!.id, Language.EnglishUS); - ctx.guildLocale = Language.EnglishUS; + await client.db.updateLanguage(ctx.guild!.id, defaultLanguage); + ctx.guildLocale = defaultLanguage; return ctx.sendMessage({ embeds: [embed.setDescription(ctx.locale('cmd.language.reset'))], diff --git a/src/commands/dev/Deploy.ts b/src/commands/dev/Deploy.ts index b8da8c881..e94253300 100644 --- a/src/commands/dev/Deploy.ts +++ b/src/commands/dev/Deploy.ts @@ -51,7 +51,7 @@ export default class Deploy extends Command { components: [row], }); } catch (error) { - console.error('Failed to send the initial message:', error); + client.logger.error('Failed to send the initial message:', error); return; } @@ -62,7 +62,7 @@ export default class Deploy extends Command { content: "You can't interact with this message", ephemeral: true, }) - .catch(console.error); + .catch(client.logger.error); return false; } return true; @@ -90,7 +90,7 @@ export default class Deploy extends Command { }); } } catch (error) { - console.error('Failed to handle interaction:', error); + client.logger.error('Failed to handle interaction:', error); } }); @@ -99,7 +99,7 @@ export default class Deploy extends Command { try { await msg.delete(); } catch (error) { - console.error('Failed to delete the message:', error); + client.logger.error('Failed to delete the message:', error); } } }); diff --git a/src/commands/playlist/List.ts b/src/commands/playlist/List.ts index 842438e56..959951389 100644 --- a/src/commands/playlist/List.ts +++ b/src/commands/playlist/List.ts @@ -112,7 +112,7 @@ export default class GetPlaylists extends Command { ], }); } catch (error) { - console.error(error); + client.logger.error(error); return await ctx.sendMessage({ embeds: [ { diff --git a/src/commands/playlist/Steal.ts b/src/commands/playlist/Steal.ts index eef61c6ae..0be469705 100644 --- a/src/commands/playlist/Steal.ts +++ b/src/commands/playlist/Steal.ts @@ -144,7 +144,7 @@ export default class StealPlaylist extends Command { ], }); } catch (error) { - console.error(error); + client.logger.error(error); return await ctx.sendMessage({ embeds: [ { diff --git a/src/events/client/InteractionCreate.ts b/src/events/client/InteractionCreate.ts index ca7213ea7..3a1abdd50 100644 --- a/src/events/client/InteractionCreate.ts +++ b/src/events/client/InteractionCreate.ts @@ -265,7 +265,7 @@ export default class InteractionCreate extends Event { try { await command.autocomplete(interaction); } catch (error) { - console.error(error); + this.client.logger.error(error); } } } diff --git a/src/events/client/Raw.ts b/src/events/client/Raw.ts index 3123c99be..c941a461a 100644 --- a/src/events/client/Raw.ts +++ b/src/events/client/Raw.ts @@ -1,10 +1,13 @@ -import { Event, type Lavamusic } from '../../structures/index.js'; +import { Event, type Lavamusic } from '../../structures/index'; export default class Raw extends Event { + client: Lavamusic; + constructor(client: Lavamusic, file: string) { super(client, file, { name: 'raw', }); + this.client = client; } public async run(d: any): Promise { diff --git a/src/events/client/Ready.ts b/src/events/client/Ready.ts index 7bd1ef8f7..18e67100d 100644 --- a/src/events/client/Ready.ts +++ b/src/events/client/Ready.ts @@ -1,6 +1,6 @@ import { AutoPoster } from 'topgg-autoposter'; -import { env } from '../../env.js'; -import { Event, type Lavamusic } from '../../structures/index.js'; +import { env } from '../../env'; +import { Event, type Lavamusic } from '../../structures/index'; export default class Ready extends Event { constructor(client: Lavamusic, file: string) { 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/structures/Context.ts b/src/structures/Context.ts index 02bae690f..0bb045dab 100644 --- a/src/structures/Context.ts +++ b/src/structures/Context.ts @@ -15,6 +15,7 @@ import { type TextChannel, type User, } from 'discord.js'; +import { env } from '../env'; import { T } from './I18n'; import type { Lavamusic } from './index'; @@ -54,7 +55,8 @@ export default class Context { } private async setUpLocale(): Promise { - this.guildLocale = this.guild ? await this.client.db.getLanguage(this.guild.id) : 'en'; + const defaultLanguage = env.DEFAULT_LANGUAGE || 'EnglishUS'; + this.guildLocale = this.guild ? await this.client.db.getLanguage(this.guild.id) : defaultLanguage; } public get isInteraction(): boolean { @@ -105,7 +107,7 @@ export default class Context { } public locale(key: string, ...args: any) { - if (!this.guildLocale) this.guildLocale = 'EnglishUs'; + if (!this.guildLocale) this.guildLocale = env.DEFAULT_LANGUAGE || 'EnglishUS'; return T(this.guildLocale, key, ...args); } @@ -124,6 +126,7 @@ export default class Context { public get deferred(): boolean | undefined { return this.isInteraction ? this.interaction?.deferred : !!this.msg; } + options = { getRole: (name: string, required = true) => { return this.interaction?.options.get(name, required)?.role; 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; + }); } /**