Skip to content

Commit

Permalink
biome fix
Browse files Browse the repository at this point in the history
  • Loading branch information
hwangsihu committed Jul 12, 2024
1 parent 3d31657 commit b291b2b
Show file tree
Hide file tree
Showing 22 changed files with 39 additions and 45 deletions.
8 changes: 2 additions & 6 deletions biome.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,7 @@
},
"files": {
"ignoreUnknown": true,
"ignore": [
".vscode",
"node_modules",
"dist"
]
"ignore": [".vscode", "node_modules", "dist"]
},
"json": {
"formatter": {
Expand All @@ -77,4 +73,4 @@
"semicolons": "always"
}
}
}
}
5 changes: 1 addition & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,7 @@
"format": "biome format --write ./src"
},
"lint-staged": {
"*.ts": [
"biome check --write",
"biome format --write"
]
"*.ts": ["biome check --write", "biome format --write"]
},
"repository": {
"type": "git",
Expand Down
2 changes: 1 addition & 1 deletion scripts/clean-no-log.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ async function clean() {
if (existsSync(path)) {
await rm(path, { recursive: true, force: true });
}
} catch (error) {
} catch (_error) {
process.exit(1);
}
}
Expand Down
3 changes: 0 additions & 3 deletions scripts/clean.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,11 @@ import { rm } from "node:fs/promises";
import { resolve } from "node:path";

async function clean() {
console.log("Cleaning dist folder...");
try {
const path = resolve("dist");
if (existsSync(path)) {
await rm(path, { recursive: true, force: true });
console.log("Dist folder has been cleaned");
} else {
console.log("Dist folder does not exist");
}
} catch (error) {
console.error("Error while cleaning dist folder:", error);
Expand Down
1 change: 0 additions & 1 deletion src/commands/filters/Rotation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ export default class Rotation extends Command {
});
}

// biome-ignore lint/suspicious/useAwait: <explanation>
public async run(client: Lavamusic, ctx: Context): Promise<any> {
const player = client.queue.get(ctx.guild.id);
if (player.filters.includes("rotation")) {
Expand Down
1 change: 0 additions & 1 deletion src/commands/playlist/Add.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@ export default class AddPlaylist extends Command {
}
}


/**
* Project: lavamusic
* Author: Appu
Expand Down
16 changes: 11 additions & 5 deletions src/commands/playlist/GetPLayLists.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Command, Context, Lavamusic } from "../../structures/index.js";
import { Command, type Context, type Lavamusic } from "../../structures/index.js";

export default class GetPlaylists extends Command {
constructor(client: Lavamusic) {
Expand Down Expand Up @@ -41,10 +41,10 @@ export default class GetPlaylists extends Command {
let userId;
let targetUser = ctx.args[0];

if (targetUser && targetUser.startsWith('<@') && targetUser.endsWith('>')) {
if (targetUser?.startsWith("<@") && targetUser.endsWith(">")) {
targetUser = targetUser.slice(2, -1);

if (targetUser.startsWith('!')) {
if (targetUser.startsWith("!")) {
targetUser = targetUser.slice(1);
}

Expand All @@ -59,7 +59,10 @@ export default class GetPlaylists extends Command {
const playlists = await client.db.getUserPlaylists(userId);

if (!playlists || playlists.length === 0) {
const noPlaylistsMessage = this.client.embed().setDescription("[This user has no playlists]").setColor(this.client.color.red);
const noPlaylistsMessage = this.client
.embed()
.setDescription("[This user has no playlists]")
.setColor(this.client.color.red);
return await ctx.sendMessage({ embeds: [noPlaylistsMessage] });
}

Expand All @@ -72,7 +75,10 @@ export default class GetPlaylists extends Command {
await ctx.sendMessage({ embeds: [successMessage] });
} catch (error) {
console.error(error);
const errorMessage = this.client.embed().setDescription("[An error occurred while retrieving the playlists]").setColor(this.client.color.red);
const errorMessage = this.client
.embed()
.setDescription("[An error occurred while retrieving the playlists]")
.setColor(this.client.color.red);
await ctx.sendMessage({ embeds: [errorMessage] });
}
}
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 @@ -73,7 +73,7 @@ export default class LoadPlaylist extends Command {
player.queue.push(track);
player.isPlaying();
}
await player.isPlaying()
await player.isPlaying();
return await ctx.sendMessage({
embeds: [
{
Expand Down
10 changes: 8 additions & 2 deletions src/commands/playlist/Remove.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,10 @@ export default class RemoveSong extends Command {
const playlistData = await client.db.getPlaylist(ctx.author.id, playlist);

if (!playlistData) {
const playlistNotFoundError = this.client.embed().setDescription("[That playlist doesn't exist]").setColor(this.client.color.red);
const playlistNotFoundError = this.client
.embed()
.setDescription("[That playlist doesn't exist]")
.setColor(this.client.color.red);
return await ctx.sendMessage({ embeds: [playlistNotFoundError] });
}

Expand All @@ -84,7 +87,10 @@ export default class RemoveSong extends Command {
ctx.sendMessage({ embeds: [successMessage] });
} catch (error) {
console.error(error);
const genericError = this.client.embed().setDescription("[An error occurred while removing the song]").setColor(this.client.color.red);
const genericError = this.client
.embed()
.setDescription("[An error occurred while removing the song]")
.setColor(this.client.color.red);
return await ctx.sendMessage({ embeds: [genericError] });
}
}
Expand Down
20 changes: 13 additions & 7 deletions src/commands/playlist/StealPlaylist.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,22 +44,22 @@ export default class StealPlaylist extends Command {

public async run(client: Lavamusic, ctx: Context, args: string[]): Promise<any> {
const playlistName = args.shift();
let userId;
let _userId;
let targetUser = ctx.args[0];

if (targetUser && targetUser.startsWith('<@') && targetUser.endsWith('>')) {
if (targetUser?.startsWith("<@") && targetUser.endsWith(">")) {
targetUser = targetUser.slice(2, -1);

if (targetUser.startsWith('!')) {
if (targetUser.startsWith("!")) {
targetUser = targetUser.slice(1);
}

targetUser = await client.users.fetch(targetUser);
userId = targetUser.id;
_userId = targetUser.id;
} else if (targetUser) {
targetUser = await client.users.fetch(ctx.args[0]);
} else {
userId = ctx.author.id;
_userId = ctx.author.id;
}

if (!playlistName) {
Expand All @@ -77,7 +77,10 @@ export default class StealPlaylist extends Command {
const targetPlaylist = await client.db.getPlaylist(targetUserId, playlistName);

if (!targetPlaylist) {
const playlistNotFoundError = this.client.embed().setDescription("[That playlist doesn't exist for the mentioned user]").setColor(this.client.color.red);
const playlistNotFoundError = this.client
.embed()
.setDescription("[That playlist doesn't exist for the mentioned user]")
.setColor(this.client.color.red);
return await ctx.sendMessage({ embeds: [playlistNotFoundError] });
}

Expand All @@ -91,7 +94,10 @@ export default class StealPlaylist extends Command {
await ctx.sendMessage({ embeds: [successMessage] });
} catch (error) {
console.error(error);
const errorMessage = this.client.embed().setDescription("[An error occurred while stealing the playlist]").setColor(this.client.color.red);
const errorMessage = this.client
.embed()
.setDescription("[An error occurred while stealing the playlist]")
.setColor(this.client.color.red);
await ctx.sendMessage({ embeds: [errorMessage] });
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/database/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ export default class ServerData {
userId,
name,
songs: {
create: songs.map(song => ({ track: song.track })),
create: songs.map((song) => ({ track: song.track })),
},
},
});
Expand Down
1 change: 0 additions & 1 deletion src/events/client/InteractionCreate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ export default class InteractionCreate extends Event {
});
}

// biome-ignore lint/complexity/noExcessiveCognitiveComplexity: <explanation>
public async run(interaction: CommandInteraction | AutocompleteInteraction): Promise<any> {
if (interaction instanceof CommandInteraction && interaction.isCommand()) {
const setup = await this.client.db.getSetup(interaction.guildId);
Expand Down
1 change: 0 additions & 1 deletion src/events/client/MessageCreate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ export default class MessageCreate extends Event {
});
}

// biome-ignore lint/complexity/noExcessiveCognitiveComplexity: <explanation>
public async run(message: Message): Promise<any> {
if (message.author.bot) return;

Expand Down
1 change: 0 additions & 1 deletion src/events/client/Ready.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ export default class Ready extends Event {
});
}

// biome-ignore lint/suspicious/useAwait: <explanation>
public async run(): Promise<void> {
this.client.logger.success(`${this.client.user?.tag} is ready!`);
this.client.user?.setPresence({
Expand Down
1 change: 0 additions & 1 deletion src/events/client/SetupButtons.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ export default class SetupButtons extends Event {
});
}

// biome-ignore lint/complexity/noExcessiveCognitiveComplexity: <explanation>
public async run(interaction: any): Promise<void> {
if (!interaction.replied) await interaction.deferReply().catch(() => {});
if (!interaction.member.voice.channel) {
Expand Down
1 change: 0 additions & 1 deletion src/events/player/NodeDestroy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ export default class NodeDestroy extends Event {
});
}

// biome-ignore lint/suspicious/useAwait: <explanation>
public async run(node: string, code: number, reason: string): Promise<void> {
const message = `Node ${node} destroyed with code ${code} and reason ${reason}.`;
this.client.logger.error(message);
Expand Down
1 change: 0 additions & 1 deletion src/events/player/NodeDisconnect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ export default class NodeDisconnect extends Event {
});
}

// biome-ignore lint/suspicious/useAwait: <explanation>
public async run(node: string, count: number): Promise<void> {
const message = `Node ${node} disconnected ${count} times`;
this.client.logger.warn(message);
Expand Down
1 change: 0 additions & 1 deletion src/events/player/NodeError.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ export default class NodeError extends Event {
});
}

// biome-ignore lint/suspicious/useAwait: <explanation>
public async run(node: string, error: any): Promise<void> {
const errorMessage = JSON.stringify(error, null, 2);
const message = `Node ${node} Error: ${errorMessage}`;
Expand Down
1 change: 0 additions & 1 deletion src/events/player/NodeReconnect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ export default class NodeReconnect extends Event {
});
}

// biome-ignore lint/suspicious/useAwait: <explanation>
public async run(node: string): Promise<void> {
const message = `Node ${node} reconnected`;
this.client.logger.warn(message);
Expand Down
4 changes: 1 addition & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@ const logger = new Logger();
async function main(): Promise<void> {
try {
const logFilePath = "./src/utils/LavaLogo.txt";
const logFile = await fs.readFile(logFilePath, "utf-8");
// biome-ignore lint/suspicious/noConsoleLog: <explanation>
console.log("\x1b[35m%s\x1b[0m", logFile);
const _logFile = await fs.readFile(logFilePath, "utf-8");

const manager = new ShardingManager("./dist/LavaClient.js", {
respawn: true,
Expand Down
1 change: 0 additions & 1 deletion src/utils/BotLog.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import type { TextChannel } from "discord.js";
import type { Lavamusic } from "../structures/index.js";

// biome-ignore lint/complexity/noStaticOnlyClass: <explanation>
export default class BotLog {
public static send(client: Lavamusic, message: string, type: "error" | "warn" | "info" | "success" = "info"): void {
if (!client?.channels.cache && client.config.logChannelId) return;
Expand Down
1 change: 0 additions & 1 deletion src/utils/Utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { ActionRowBuilder, ActivityType, ButtonBuilder, ButtonStyle, CommandInte
import config from "../config.js";
import type { Context, Lavamusic } from "../structures/index.js";

// biome-ignore lint/complexity/noStaticOnlyClass: <explanation>
export class Utils {
public static formatTime(ms: number): string {
const minuteMs = 60 * 1000;
Expand Down

0 comments on commit b291b2b

Please sign in to comment.