From 93016f7d9d71e8038cda26f5d6c96e9cd6605a60 Mon Sep 17 00:00:00 2001 From: hwangsihu Date: Thu, 18 Jul 2024 21:03:55 +0900 Subject: [PATCH] . --- src/commands/info/Help.ts | 7 +++- src/commands/info/Invite.ts | 7 +--- src/commands/info/LavaLink.ts | 1 - src/config.ts | 2 +- src/database/server.ts | 2 +- src/events/client/InteractionCreate.ts | 6 ++- src/structures/Context.ts | 2 +- src/structures/I18n.ts | 12 +++--- src/structures/Lavamusic.ts | 14 ++++--- src/types.ts | 52 +++++++++++++------------- 10 files changed, 54 insertions(+), 51 deletions(-) diff --git a/src/commands/info/Help.ts b/src/commands/info/Help.ts index 28f814974..8783629fb 100644 --- a/src/commands/info/Help.ts +++ b/src/commands/info/Help.ts @@ -45,7 +45,12 @@ export default class Help extends Command { const command = this.client.commands.get(args[0].toLowerCase()); if (!command) { return await ctx.sendMessage({ - embeds: [client.embed().setColor(client.color.red).setDescription(ctx.locale("cmd.help.not_found", { cmdName: args[0] }))], + embeds: [ + client + .embed() + .setColor(client.color.red) + .setDescription(ctx.locale("cmd.help.not_found", { cmdName: args[0] })), + ], }); } const helpEmbed = embed diff --git a/src/commands/info/Invite.ts b/src/commands/info/Invite.ts index d70d7b91b..1a1d5eecf 100644 --- a/src/commands/info/Invite.ts +++ b/src/commands/info/Invite.ts @@ -1,7 +1,6 @@ import { ActionRowBuilder, ButtonBuilder, ButtonStyle } from "discord.js"; import { Command, type Context, type Lavamusic } from "../../structures/index.js"; - export default class Invite extends Command { constructor(client: Lavamusic) { super(client, { @@ -43,11 +42,7 @@ export default class Invite extends Command { new ButtonBuilder().setLabel(ctx.locale("buttons.support")).setStyle(ButtonStyle.Link).setURL("https://discord.gg/STXurwnZD5"), ); return await ctx.sendMessage({ - embeds: [ - embed - .setColor(this.client.color.main) - .setDescription(ctx.locale("cmd.invite.content")) - ], + embeds: [embed.setColor(this.client.color.main).setDescription(ctx.locale("cmd.invite.content"))], components: [row], }); } diff --git a/src/commands/info/LavaLink.ts b/src/commands/info/LavaLink.ts index 300feca6e..57a6ec703 100644 --- a/src/commands/info/LavaLink.ts +++ b/src/commands/info/LavaLink.ts @@ -1,6 +1,5 @@ import { Command, type Context, type Lavamusic } from "../../structures/index.js"; - export default class LavaLink extends Command { constructor(client: Lavamusic) { super(client, { diff --git a/src/config.ts b/src/config.ts index cbe27ba54..dd713f398 100644 --- a/src/config.ts +++ b/src/config.ts @@ -1,5 +1,5 @@ import dotenv from "dotenv"; -import { SearchEngine, Language } from "./types.js"; +import { Language, SearchEngine } from "./types.js"; dotenv.config(); const parseBoolean = (value?: string): boolean => value?.trim().toLowerCase() === "true"; diff --git a/src/database/server.ts b/src/database/server.ts index 0dbcae942..739ebb449 100644 --- a/src/database/server.ts +++ b/src/database/server.ts @@ -157,7 +157,7 @@ export default class ServerData { await this.prisma.song.create({ data: { track: JSON.stringify(song), - playlistId: playlist.id + playlistId: playlist.id, }, }); } else { diff --git a/src/events/client/InteractionCreate.ts b/src/events/client/InteractionCreate.ts index d07900a4c..ec91d9054 100644 --- a/src/events/client/InteractionCreate.ts +++ b/src/events/client/InteractionCreate.ts @@ -24,7 +24,11 @@ export default class InteractionCreate extends Event { const allowedCategories = ["filters", "music", "playlist"]; const commandInSetup = this.client.commands.get(interaction.commandName); - if (setup && interaction.channelId === setup.textId && (!commandInSetup || !allowedCategories.includes(commandInSetup.category))) { + if ( + setup && + interaction.channelId === setup.textId && + (!commandInSetup || !allowedCategories.includes(commandInSetup.category)) + ) { return await interaction.reply({ content: `You can't use this command in setup channel.`, ephemeral: true, diff --git a/src/structures/Context.ts b/src/structures/Context.ts index 7f0ac68f6..3b7137a1e 100644 --- a/src/structures/Context.ts +++ b/src/structures/Context.ts @@ -17,8 +17,8 @@ import { type TextChannel, type User, } from "discord.js"; -import type { Lavamusic } from "./index.js"; import { T } from "./I18n.js"; +import type { Lavamusic } from "./index.js"; export default class Context { public ctx: CommandInteraction | Message; diff --git a/src/structures/I18n.ts b/src/structures/I18n.ts index 532cca67f..eddd7ed1f 100644 --- a/src/structures/I18n.ts +++ b/src/structures/I18n.ts @@ -1,13 +1,11 @@ - import i18n from "i18n"; -import Logger from "./Logger.js"; import { Locale } from "discord.js"; import { Language } from "../types.js"; +import Logger from "./Logger.js"; const logger = new Logger(); - export function initI18n() { i18n.configure({ locales: Object.keys(Language), @@ -23,8 +21,8 @@ export function initI18n() { }, mustacheConfig: { tags: ["{", "}"], - disable: false - } + disable: false, + }, }); logger.info("I18n has been initialized"); @@ -40,10 +38,10 @@ export function T(locale: string, text: string | i18n.TranslateOptions, ...param export function localization(lan: any, name: any, desc: any) { return { name: [Locale[lan], name], - description: [Locale[lan], T(lan, desc)] + description: [Locale[lan], T(lan, desc)], }; } export function descriptionLocalization(name: any, text: any) { return i18n.getLocales().map((locale) => localization(Locale[locale] || locale, name, text)); -} \ No newline at end of file +} diff --git a/src/structures/Lavamusic.ts b/src/structures/Lavamusic.ts index 40feecbe7..3f7caafb4 100644 --- a/src/structures/Lavamusic.ts +++ b/src/structures/Lavamusic.ts @@ -13,14 +13,14 @@ import { type RESTPostAPIChatInputApplicationCommandsJSONBody, Routes, } from "discord.js"; +import { Locale } from "discord.js"; import config from "../config.js"; import ServerData from "../database/server.js"; import loadPlugins from "../plugin/index.js"; import { Utils } from "../utils/Utils.js"; +import { T, i18n, initI18n, localization } from "./I18n.js"; import Logger from "./Logger.js"; import { type Command, Queue, ShoukakuClient } from "./index.js"; -import { initI18n, T, i18n, localization } from "./I18n.js"; -import { Locale } from 'discord.js'; const __dirname = path.dirname(fileURLToPath(import.meta.url)); @@ -86,12 +86,14 @@ export default class Lavamusic extends Client { type: ApplicationCommandType.ChatInput, options: command.options || [], default_member_permissions: - Array.isArray(command.permissions.user) && command.permissions.user.length > 0 ? PermissionsBitField.resolve(command.permissions.user as any).toString() : null, + Array.isArray(command.permissions.user) && command.permissions.user.length > 0 + ? PermissionsBitField.resolve(command.permissions.user as any).toString() + : null, name_localizations: null, - description_localizations: null + description_localizations: null, }; // command description and name localizations - const localizations = [] + const localizations = []; i18n.getLocales().map((locale) => { localizations.push(localization(locale, command.name, command.description.content)); }); @@ -106,7 +108,7 @@ export default class Lavamusic extends Client { if (command.options.length > 0) { command.options.map((option) => { // command options name and description localizations - const optionsLocalizations = [] + const optionsLocalizations = []; i18n.getLocales().map((locale) => { optionsLocalizations.push(localization(locale, option.name, option.description)); }); diff --git a/src/types.ts b/src/types.ts index ebd6b1b4b..1e6d76a08 100644 --- a/src/types.ts +++ b/src/types.ts @@ -15,37 +15,37 @@ export enum Language { French = "French", } export const LocaleFlags = { - // [Locale.Indonesian]: "🇮🇩", + // [Locale.Indonesian]: "🇮🇩", [Locale.EnglishUS]: "🇺🇸", - // [Locale.EnglishGB]: "🇬🇧", - // [Locale.Bulgarian]: "🇧🇬", - // [Locale.ChineseCN]: "🇨🇳", - // [Locale.ChineseTW]: "🇹🇼", - // [Locale.Croatian]: "🇭🇷", - // [Locale.Czech]: "🇨🇿", - // [Locale.Danish]: "🇩🇰", - // [Locale.Dutch]: "🇳🇱", - // [Locale.Finnish]: "🇫🇮", + // [Locale.EnglishGB]: "🇬🇧", + // [Locale.Bulgarian]: "🇧🇬", + // [Locale.ChineseCN]: "🇨🇳", + // [Locale.ChineseTW]: "🇹🇼", + // [Locale.Croatian]: "🇭🇷", + // [Locale.Czech]: "🇨🇿", + // [Locale.Danish]: "🇩🇰", + // [Locale.Dutch]: "🇳🇱", + // [Locale.Finnish]: "🇫🇮", [Locale.French]: "🇫🇷", - // [Locale.German]: "🇩🇪", - // [Locale.Greek]: "🇬🇷", + // [Locale.German]: "🇩🇪", + // [Locale.Greek]: "🇬🇷", [Locale.Hindi]: "🇮🇳", - // [Locale.Hungarian]: "🇭🇺", - // [Locale.Italian]: "🇮🇹", - // [Locale.Japanese]: "🇯🇵", + // [Locale.Hungarian]: "🇭🇺", + // [Locale.Italian]: "🇮🇹", + // [Locale.Japanese]: "🇯🇵", [Locale.Korean]: "🇰🇷", - // [Locale.Lithuanian]: "🇱🇹", - // [Locale.Norwegian]: "🇳🇴", + // [Locale.Lithuanian]: "🇱🇹", + // [Locale.Norwegian]: "🇳🇴", [Locale.Polish]: "🇵🇱", - // [Locale.PortugueseBR]: "🇧🇷", - // [Locale.Romanian]: "🇷🇴", - // [Locale.Russian]: "🇷🇺", - // [Locale.SpanishES]: "🇪🇸", - // [Locale.Swedish]: "🇸🇪", - // [Locale.Thai]: "🇹🇭", - // [Locale.Turkish]: "🇹🇷", - // [Locale.Ukrainian]: "🇺🇦", - // [Locale.Vietnamese]: "🇻🇳" + // [Locale.PortugueseBR]: "🇧🇷", + // [Locale.Romanian]: "🇷🇴", + // [Locale.Russian]: "🇷🇺", + // [Locale.SpanishES]: "🇪🇸", + // [Locale.Swedish]: "🇸🇪", + // [Locale.Thai]: "🇹🇭", + // [Locale.Turkish]: "🇹🇷", + // [Locale.Ukrainian]: "🇺🇦", + // [Locale.Vietnamese]: "🇻🇳" }; /** * Project: lavamusic