From 50e23c04eb87830838fd5cb0cffa969d3032d3f9 Mon Sep 17 00:00:00 2001 From: LucasB25 <50886682+LucasB25@users.noreply.github.com> Date: Tue, 30 Jul 2024 13:06:43 +0200 Subject: [PATCH] format and lint --- process.json | 20 ++++---- scripts/restart.js | 4 +- src/commands/config/Language.ts | 2 +- src/commands/info/Botinfo.ts | 8 +-- src/commands/music/Play.ts | 9 ---- src/commands/music/PlayNext.ts | 9 ---- src/events/client/InteractionCreate.ts | 1 - src/structures/Lavamusic.ts | 6 ++- src/utils/SetupSystem.ts | 69 +++++++++++++------------- 9 files changed, 54 insertions(+), 74 deletions(-) diff --git a/process.json b/process.json index 930928c59..bda8eaceb 100644 --- a/process.json +++ b/process.json @@ -1,12 +1,10 @@ { - "apps": [ - { - "name": "lavamusic", - "script": "dist/index.js", - "node_args": [ - "--enable-source-maps" - ], - "restart_delay": 10000 - } - ] -} \ No newline at end of file + "apps": [ + { + "name": "lavamusic", + "script": "dist/index.js", + "node_args": ["--enable-source-maps"], + "restart_delay": 10000 + } + ] +} diff --git a/scripts/restart.js b/scripts/restart.js index 015c97d47..75a0558eb 100644 --- a/scripts/restart.js +++ b/scripts/restart.js @@ -1,7 +1,7 @@ -import { exec } from 'node:child_process'; +import { exec } from "node:child_process"; function startLavamusic() { - exec('npm start', (error, stdout, stderr) => { + exec("npm start", (error, stdout, stderr) => { if (error) { console.error(`Error starting Lavamusic: ${error.message}`); return; diff --git a/src/commands/config/Language.ts b/src/commands/config/Language.ts index 405e94b3e..6620d8a3f 100644 --- a/src/commands/config/Language.ts +++ b/src/commands/config/Language.ts @@ -7,7 +7,7 @@ export default class LanguageCommand extends Command { name: "language", description: { content: "cmd.language.description", - examples: ["language set \`EnglishUS\`", "language reset"], + examples: ["language set `EnglishUS`", "language reset"], usage: "language", }, category: "general", diff --git a/src/commands/info/Botinfo.ts b/src/commands/info/Botinfo.ts index 64738756c..b69fdc67e 100644 --- a/src/commands/info/Botinfo.ts +++ b/src/commands/info/Botinfo.ts @@ -46,9 +46,9 @@ export default class Botinfo extends Command { const commands = client.commands.size; const promises = [ - client.shard.broadcastEval(client => client.guilds.cache.size), - client.shard.broadcastEval(client => client.guilds.cache.reduce((acc, guild) => acc + guild.memberCount, 0)), - client.shard.broadcastEval(client => client.channels.cache.size), + client.shard.broadcastEval((client) => client.guilds.cache.size), + client.shard.broadcastEval((client) => client.guilds.cache.reduce((acc, guild) => acc + guild.memberCount, 0)), + client.shard.broadcastEval((client) => client.channels.cache.size), ]; return Promise.all(promises).then(async (results) => { const guilds = results[0].reduce((acc, guildCount) => acc + guildCount, 0); @@ -89,4 +89,4 @@ export default class Botinfo extends Command { * This code is the property of Coder and may not be reproduced or * modified without permission. For more information, contact us at * https://discord.gg/ns8CTk9J3e - */ \ No newline at end of file + */ diff --git a/src/commands/music/Play.ts b/src/commands/music/Play.ts index 26a39aaa4..e4918dba3 100644 --- a/src/commands/music/Play.ts +++ b/src/commands/music/Play.ts @@ -56,13 +56,11 @@ export default class Play extends Command { switch (res.loadType) { case LoadType.ERROR: ctx.editMessage({ - content: "", embeds: [embed.setColor(this.client.color.red).setDescription(ctx.locale("cmd.play.errors.search_error"))], }); break; case LoadType.EMPTY: ctx.editMessage({ - content: "", embeds: [embed.setColor(this.client.color.red).setDescription(ctx.locale("cmd.play.errors.no_results"))], }); break; @@ -70,7 +68,6 @@ export default class Play extends Command { const track = player.buildTrack(res.data, ctx.author); if (player.queue.length > client.config.maxQueueSize) return await ctx.editMessage({ - content: "", embeds: [ embed .setColor(this.client.color.red) @@ -80,7 +77,6 @@ export default class Play extends Command { player.queue.push(track); await player.isPlaying(); ctx.editMessage({ - content: "", embeds: [ embed .setColor(this.client.color.main) @@ -92,7 +88,6 @@ export default class Play extends Command { case LoadType.PLAYLIST: { if (res.data.tracks.length > client.config.maxPlaylistSize) return await ctx.editMessage({ - content: "", embeds: [ embed .setColor(this.client.color.red) @@ -105,7 +100,6 @@ export default class Play extends Command { const pl = player.buildTrack(track, ctx.author); if (player.queue.length > client.config.maxQueueSize) return await ctx.editMessage({ - content: "", embeds: [ embed .setColor(this.client.color.red) @@ -118,7 +112,6 @@ export default class Play extends Command { } await player.isPlaying(); ctx.editMessage({ - content: "", embeds: [ embed .setColor(this.client.color.main) @@ -131,7 +124,6 @@ export default class Play extends Command { const track1 = player.buildTrack(res.data[0], ctx.author); if (player.queue.length > client.config.maxQueueSize) return await ctx.editMessage({ - content: "", embeds: [ embed .setColor(this.client.color.red) @@ -141,7 +133,6 @@ export default class Play extends Command { player.queue.push(track1); await player.isPlaying(); ctx.editMessage({ - content: "", embeds: [ embed .setColor(this.client.color.main) diff --git a/src/commands/music/PlayNext.ts b/src/commands/music/PlayNext.ts index b8428c283..b18312afb 100644 --- a/src/commands/music/PlayNext.ts +++ b/src/commands/music/PlayNext.ts @@ -55,13 +55,11 @@ export default class PlayNext extends Command { switch (res.loadType) { case LoadType.ERROR: ctx.editMessage({ - content: "", embeds: [embed.setColor(this.client.color.red).setDescription(ctx.locale("cmd.playnext.errors.search_error"))], }); break; case LoadType.EMPTY: ctx.editMessage({ - content: "", embeds: [embed.setColor(this.client.color.red).setDescription(ctx.locale("cmd.playnext.errors.no_results"))], }); break; @@ -69,7 +67,6 @@ export default class PlayNext extends Command { const track = player.buildTrack(res.data, ctx.author); if (player.queue.length > client.config.maxQueueSize) return await ctx.editMessage({ - content: "", embeds: [ embed .setColor(this.client.color.red) @@ -81,7 +78,6 @@ export default class PlayNext extends Command { player.queue.splice(0, 0, track); await player.isPlaying(); ctx.editMessage({ - content: "", embeds: [ embed .setColor(this.client.color.main) @@ -95,7 +91,6 @@ export default class PlayNext extends Command { case LoadType.PLAYLIST: { if (res.data.tracks.length > client.config.maxPlaylistSize) return await ctx.editMessage({ - content: "", embeds: [ embed .setColor(this.client.color.red) @@ -108,7 +103,6 @@ export default class PlayNext extends Command { const pl = player.buildTrack(track, ctx.author); if (player.queue.length > client.config.maxQueueSize) return await ctx.editMessage({ - content: "", embeds: [ embed .setColor(this.client.color.red) @@ -121,7 +115,6 @@ export default class PlayNext extends Command { } await player.isPlaying(); ctx.editMessage({ - content: "", embeds: [ embed .setColor(this.client.color.main) @@ -134,7 +127,6 @@ export default class PlayNext extends Command { const track1 = player.buildTrack(res.data[0], ctx.author); if (player.queue.length > client.config.maxQueueSize) return await ctx.editMessage({ - content: "", embeds: [ embed .setColor(this.client.color.red) @@ -146,7 +138,6 @@ export default class PlayNext extends Command { player.queue.splice(0, 0, track1); await player.isPlaying(); ctx.editMessage({ - content: "", embeds: [ embed .setColor(this.client.color.main) diff --git a/src/events/client/InteractionCreate.ts b/src/events/client/InteractionCreate.ts index 80f5130fc..06d70fef3 100644 --- a/src/events/client/InteractionCreate.ts +++ b/src/events/client/InteractionCreate.ts @@ -9,7 +9,6 @@ import { EmbedBuilder, type GuildMember, InteractionType, - Locale, PermissionFlagsBits, type TextChannel, } from "discord.js"; diff --git a/src/structures/Lavamusic.ts b/src/structures/Lavamusic.ts index 8e6291275..434e602ca 100644 --- a/src/structures/Lavamusic.ts +++ b/src/structures/Lavamusic.ts @@ -128,7 +128,6 @@ export default class Lavamusic extends Client { // subcommand options localizations data.options.map((option) => { - if ("options" in option && option.options.length > 0) { option.options.map((subOption) => { // subcommand options name and description localizations @@ -140,7 +139,10 @@ export default class Lavamusic extends Client { const [language, name] = localization.name; const [language2, description] = localization.description; subOption.name_localizations = { ...subOption.name_localizations, [language]: name }; - subOption.description_localizations = { ...subOption.description_localizations, [language2]: description }; + subOption.description_localizations = { + ...subOption.description_localizations, + [language2]: description, + }; } // subcommand options description localization subOption.description = T(Locale.EnglishUS, subOption.description); diff --git a/src/utils/SetupSystem.ts b/src/utils/SetupSystem.ts index 56ae52ffd..60a7ebc66 100644 --- a/src/utils/SetupSystem.ts +++ b/src/utils/SetupSystem.ts @@ -42,7 +42,7 @@ async function setupStart(client: Lavamusic, query: string, player: Dispatcher, case LoadType.ERROR: await message.channel .send({ - embeds: [embed.setColor(client.color.red).setDescription(T(locale,"player.setupStart.error_searching"))], + embeds: [embed.setColor(client.color.red).setDescription(T(locale, "player.setupStart.error_searching"))], }) .then((msg) => setTimeout(() => msg.delete(), 5000)); break; @@ -62,7 +62,7 @@ async function setupStart(client: Lavamusic, query: string, player: Dispatcher, embed .setColor(client.color.red) .setDescription( - T(locale,"player.setupStart.queue_too_long", { maxQueueSize: client.config.maxQueueSize }), + T(locale, "player.setupStart.queue_too_long", { maxQueueSize: client.config.maxQueueSize }), ), ], }) @@ -74,14 +74,12 @@ async function setupStart(client: Lavamusic, query: string, player: Dispatcher, await message.channel .send({ embeds: [ - embed - .setColor(client.color.main) - .setDescription( - T(locale,"player.setupStart.added_to_queue", { - title: res.data.info.title, - uri: res.data.info.uri, - }), - ), + embed.setColor(client.color.main).setDescription( + T(locale, "player.setupStart.added_to_queue", { + title: res.data.info.title, + uri: res.data.info.uri, + }), + ), ], }) .then((msg) => setTimeout(() => msg.delete(), 5000)); @@ -94,13 +92,11 @@ async function setupStart(client: Lavamusic, query: string, player: Dispatcher, await message.channel .send({ embeds: [ - embed - .setColor(client.color.red) - .setDescription( - T(locale,"player.setupStart.playlist_too_long", { - maxPlaylistSize: client.config.maxPlaylistSize, - }), - ), + embed.setColor(client.color.red).setDescription( + T(locale, "player.setupStart.playlist_too_long", { + maxPlaylistSize: client.config.maxPlaylistSize, + }), + ), ], }) .then((msg) => setTimeout(() => msg.delete(), 5000)); @@ -112,13 +108,11 @@ async function setupStart(client: Lavamusic, query: string, player: Dispatcher, await message.channel .send({ embeds: [ - embed - .setColor(client.color.red) - .setDescription( - T(locale,"player.setupStart.queue_too_long", { - maxQueueSize: client.config.maxQueueSize, - }), - ), + embed.setColor(client.color.red).setDescription( + T(locale, "player.setupStart.queue_too_long", { + maxQueueSize: client.config.maxQueueSize, + }), + ), ], }) .then((msg) => setTimeout(() => msg.delete(), 5000)); @@ -133,7 +127,7 @@ async function setupStart(client: Lavamusic, query: string, player: Dispatcher, embed .setColor(client.color.main) .setDescription( - T(locale,"player.setupStart.added_playlist_to_queue", { length: res.data.tracks.length }), + T(locale, "player.setupStart.added_playlist_to_queue", { length: res.data.tracks.length }), ), ], }) @@ -150,7 +144,7 @@ async function setupStart(client: Lavamusic, query: string, player: Dispatcher, embed .setColor(client.color.red) .setDescription( - T(locale,"player.setupStart.queue_too_long", { maxQueueSize: client.config.maxQueueSize }), + T(locale, "player.setupStart.queue_too_long", { maxQueueSize: client.config.maxQueueSize }), ), ], }) @@ -162,14 +156,12 @@ async function setupStart(client: Lavamusic, query: string, player: Dispatcher, await message.channel .send({ embeds: [ - embed - .setColor(client.color.main) - .setDescription( - T(locale,"player.setupStart.added_to_queue", { - title: res.data[0].info.title, - uri: res.data[0].info.uri, - }), - ), + embed.setColor(client.color.main).setDescription( + T(locale, "player.setupStart.added_to_queue", { + title: res.data[0].info.title, + uri: res.data[0].info.uri, + }), + ), ], }) .then((msg) => setTimeout(() => msg.delete(), 5000)); @@ -184,7 +176,14 @@ async function setupStart(client: Lavamusic, query: string, player: Dispatcher, } } -async function trackStart(msgId: any, channel: TextChannel, player: Dispatcher, track: Song, client: Lavamusic, locale: string): Promise { +async function trackStart( + msgId: any, + channel: TextChannel, + player: Dispatcher, + track: Song, + client: Lavamusic, + locale: string, +): Promise { const icon = player.current ? player.current.info.artworkUrl : client.config.links.img; let m: Message;