Skip to content

Commit

Permalink
Format
Browse files Browse the repository at this point in the history
  • Loading branch information
hwangsihu committed Sep 13, 2024
1 parent fab745f commit 447190e
Show file tree
Hide file tree
Showing 11 changed files with 15 additions and 15 deletions.
2 changes: 1 addition & 1 deletion src/commands/dev/Restart.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: [],
Expand Down
4 changes: 2 additions & 2 deletions src/commands/music/Play.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,15 +163,15 @@ 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({
name: name.length > 100 ? `${name.substring(0, 97)}...` : name,
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({
Expand Down
2 changes: 1 addition & 1 deletion src/commands/music/PlayNext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion src/commands/music/Remove.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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"))],
});
Expand Down
2 changes: 1 addition & 1 deletion src/commands/music/Shuffle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export default class Shuffle extends Command {
public async run(client: Lavamusic, ctx: Context): Promise<any> {
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"))],
});
Expand Down
2 changes: 1 addition & 1 deletion src/commands/music/Skipto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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"))],
});
Expand Down
2 changes: 1 addition & 1 deletion src/commands/playlist/Load.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: [
{
Expand Down
2 changes: 1 addition & 1 deletion src/events/client/MessageCreate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion src/events/client/SetupButtons.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion src/events/player/TrackStart.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
8 changes: 4 additions & 4 deletions src/structures/Dispatcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -96,8 +96,8 @@ export default class Dispatcher {
}

public play(): Promise<void> {
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);
Expand Down Expand Up @@ -184,7 +184,7 @@ export default class Dispatcher {
}

public async isPlaying(): Promise<void> {
if (this.queue.length && !this.current && !this.player.paused) {
if (this.queue.length > 0 && !this.current && !this.player.paused) {
await this.play();
}
}
Expand Down

0 comments on commit 447190e

Please sign in to comment.