From 447190ee94b464c8bf2243539d05d88d9904f85b Mon Sep 17 00:00:00 2001 From: hwangsihu Date: Fri, 13 Sep 2024 17:47:39 +0900 Subject: [PATCH] Format --- src/commands/dev/Restart.ts | 2 +- src/commands/music/Play.ts | 4 ++-- src/commands/music/PlayNext.ts | 2 +- src/commands/music/Remove.ts | 2 +- src/commands/music/Shuffle.ts | 2 +- src/commands/music/Skipto.ts | 2 +- src/commands/playlist/Load.ts | 2 +- src/events/client/MessageCreate.ts | 2 +- src/events/client/SetupButtons.ts | 2 +- src/events/player/TrackStart.ts | 2 +- src/structures/Dispatcher.ts | 8 ++++---- 11 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/commands/dev/Restart.ts b/src/commands/dev/Restart.ts index b670d582d..b947d7981 100644 --- a/src/commands/dev/Restart.ts +++ b/src/commands/dev/Restart.ts @@ -66,7 +66,7 @@ export default class Restart extends Command { }); collector.on("end", async () => { - if (!collector.collected.size) { + if (collector.collected.size === 0) { await msg.edit({ content: "Restart cancelled.", components: [], diff --git a/src/commands/music/Play.ts b/src/commands/music/Play.ts index fbf56afc3..9ca06e567 100644 --- a/src/commands/music/Play.ts +++ b/src/commands/music/Play.ts @@ -163,7 +163,7 @@ export default class Play extends Command { const songs = []; if (res?.loadType) { - if (res.loadType === LoadType.SEARCH && res.data.length) { + if (res.loadType === LoadType.SEARCH && res.data.length > 0) { res.data.slice(0, 10).forEach((track) => { const name = `${track.info.title} by ${track.info.author}`; songs.push({ @@ -171,7 +171,7 @@ export default class Play extends Command { value: track.info.uri, }); }); - } else if (res.loadType === LoadType.PLAYLIST && res.data.tracks.length) { + } else if (res.loadType === LoadType.PLAYLIST && res.data.tracks.length > 0) { res.data.tracks.slice(0, 10).forEach((track) => { const name = `${track.info.title} by ${track.info.author}`; songs.push({ diff --git a/src/commands/music/PlayNext.ts b/src/commands/music/PlayNext.ts index 6d0a9c83d..6ef71ee4c 100644 --- a/src/commands/music/PlayNext.ts +++ b/src/commands/music/PlayNext.ts @@ -167,7 +167,7 @@ export default class PlayNext extends Command { const res = await this.client.queue.search(focusedValue); const songs = []; - if (res.loadType === LoadType.SEARCH && res.data.length) { + if (res.loadType === LoadType.SEARCH && res.data.length > 0) { res.data.slice(0, 10).forEach((x) => { let name = `${x.info.title} by ${x.info.author}`; if (name.length > 100) { diff --git a/src/commands/music/Remove.ts b/src/commands/music/Remove.ts index 5b1f60567..83445236a 100644 --- a/src/commands/music/Remove.ts +++ b/src/commands/music/Remove.ts @@ -41,7 +41,7 @@ export default class Remove extends Command { const player = client.queue.get(ctx.guild!.id); const embed = this.client.embed(); - if (!player.queue.length) + if (player.queue.length === 0) return await ctx.sendMessage({ embeds: [embed.setColor(this.client.color.red).setDescription(ctx.locale("cmd.remove.errors.no_songs"))], }); diff --git a/src/commands/music/Shuffle.ts b/src/commands/music/Shuffle.ts index 4328cde13..0fb4d908b 100644 --- a/src/commands/music/Shuffle.ts +++ b/src/commands/music/Shuffle.ts @@ -33,7 +33,7 @@ export default class Shuffle extends Command { public async run(client: Lavamusic, ctx: Context): Promise { const player = client.queue.get(ctx.guild!.id); const embed = this.client.embed(); - if (!player.queue.length) { + if (player.queue.length === 0) { return await ctx.sendMessage({ embeds: [embed.setColor(this.client.color.red).setDescription(ctx.locale("player.errors.no_song"))], }); diff --git a/src/commands/music/Skipto.ts b/src/commands/music/Skipto.ts index 1ebb24623..e0bad9876 100644 --- a/src/commands/music/Skipto.ts +++ b/src/commands/music/Skipto.ts @@ -42,7 +42,7 @@ export default class Skipto extends Command { const embed = this.client.embed(); const num = Number(args[0]); - if (!player.queue.length || isNaN(num) || num > player.queue.length || num < 1) { + if (player.queue.length === 0 || isNaN(num) || num > player.queue.length || num < 1) { return await ctx.sendMessage({ embeds: [embed.setColor(this.client.color.red).setDescription(ctx.locale("cmd.skipto.errors.invalid_number"))], }); diff --git a/src/commands/playlist/Load.ts b/src/commands/playlist/Load.ts index f23cdd3cc..618e7c10c 100644 --- a/src/commands/playlist/Load.ts +++ b/src/commands/playlist/Load.ts @@ -55,7 +55,7 @@ export default class LoadPlaylist extends Command { } const songs = await client.db.getSongs(ctx.author.id, playlistName); - if (!songs.length) { + if (songs.length === 0) { return await ctx.sendMessage({ embeds: [ { diff --git a/src/events/client/MessageCreate.ts b/src/events/client/MessageCreate.ts index 51fd82ffc..bdb31688c 100644 --- a/src/events/client/MessageCreate.ts +++ b/src/events/client/MessageCreate.ts @@ -185,7 +185,7 @@ export default class MessageCreate extends Event { } } - if (command.args && !args.length) { + if (command.args && args.length === 0) { const embed = this.client .embed() .setColor(this.client.color.red) diff --git a/src/events/client/SetupButtons.ts b/src/events/client/SetupButtons.ts index b59ba5ea2..267e56512 100644 --- a/src/events/client/SetupButtons.ts +++ b/src/events/client/SetupButtons.ts @@ -104,7 +104,7 @@ export default class SetupButtons extends Event { break; } case "SKIP_BUT": - if (!player.queue.length) { + if (player.queue.length === 0) { return await buttonReply(interaction, T(locale, "event.setupButton.no_music_to_skip"), this.client.color.main); } player.skip(); diff --git a/src/events/player/TrackStart.ts b/src/events/player/TrackStart.ts index 89eced69a..85f97715a 100644 --- a/src/events/player/TrackStart.ts +++ b/src/events/player/TrackStart.ts @@ -187,7 +187,7 @@ function createCollector(message: any, dispatcher: Dispatcher, _track: Song, emb await interaction.deferUpdate(); break; case "skip": - if (dispatcher.queue.length) { + if (dispatcher.queue.length > 0) { await interaction.deferUpdate(); dispatcher.skip(); await editMessage( diff --git a/src/structures/Dispatcher.ts b/src/structures/Dispatcher.ts index a31b2c82c..b2b7676c8 100644 --- a/src/structures/Dispatcher.ts +++ b/src/structures/Dispatcher.ts @@ -78,7 +78,7 @@ export default class Dispatcher { this.player .on("start", () => this.client.shoukaku.emit("trackStart" as any, this.player, this.current, this)) .on("end", () => { - if (!this.queue.length) { + if (this.queue.length === 0) { this.client.shoukaku.emit("queueEnd" as any, this.player, this.current, this); } this.client.shoukaku.emit("trackEnd" as any, this.player, this.current, this); @@ -96,8 +96,8 @@ export default class Dispatcher { } public play(): Promise { - if (!(this.exists && (this.queue.length || this.current))) return; - this.current = this.queue.length ? this.queue.shift() : this.queue[0]; + if (!(this.exists && (this.queue.length > 0 || this.current))) return; + this.current = this.queue.length > 0 ? this.queue.shift() : this.queue[0]; if (this.current) { this.player.playTrack({ track: { encoded: this.current.encoded } }); this.history.push(this.current); @@ -184,7 +184,7 @@ export default class Dispatcher { } public async isPlaying(): Promise { - if (this.queue.length && !this.current && !this.player.paused) { + if (this.queue.length > 0 && !this.current && !this.player.paused) { await this.play(); } }