Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
LucasB25 committed Sep 24, 2024
1 parent 3a0819e commit 7d91283
Show file tree
Hide file tree
Showing 14 changed files with 76 additions and 29 deletions.
2 changes: 1 addition & 1 deletion scripts/restart.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ const { exec } = require('node:child_process');
async function startLavamusic() {
exec('npm start', (error, stdout, stderr) => {
if (error) {
console.error(`Error starting Lavamusic: ${error.message}`);
console.error(`Error starting Lavamusic: ${error}`);
return;
}
if (stderr) {
Expand Down
5 changes: 4 additions & 1 deletion src/commands/config/Setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,10 @@ export default class Setup extends Command {
}
client.db.deleteSetup(ctx.guild!.id);
const textChannel = ctx.guild.channels.cache.get(data2.textId);
if (textChannel) await textChannel.delete().catch(() => {});
if (textChannel)
await textChannel.delete().catch(() => {
null;
});
await ctx.sendMessage({
embeds: [
{
Expand Down
9 changes: 6 additions & 3 deletions src/commands/music/Loop.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,18 +36,21 @@ export default class Loop extends Command {
let loopMessage = '';

switch (player?.repeatMode) {
case 'off':
case 'off': {
player.setRepeatMode('track');
loopMessage = ctx.locale('cmd.loop.looping_song');
break;
case 'track':
}
case 'track': {
player.setRepeatMode('queue');
loopMessage = ctx.locale('cmd.loop.looping_queue');
break;
case 'queue':
}
case 'queue': {
player.setRepeatMode('off');
loopMessage = ctx.locale('cmd.loop.looping_off');
break;
}
}

return await ctx.sendMessage({
Expand Down
2 changes: 1 addition & 1 deletion src/commands/music/Queue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export default class Queue extends Command {
],
});
}
const songStrings = [];
const songStrings: string[] = [];
for (let i = 0; i < player.queue.tracks.length; i++) {
const track = player.queue.tracks[i];
songStrings.push(
Expand Down
2 changes: 1 addition & 1 deletion src/commands/playlist/AddSong.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ export default class AddSong extends Command {
}

let trackStrings: any;
let count: number = 0;
let count = 0;
if (res.loadType === 'playlist') {
trackStrings = res.tracks.map(track => track.encoded);
count = res.tracks.length;
Expand Down
1 change: 0 additions & 1 deletion src/commands/playlist/Steal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,6 @@ export default class StealPlaylist extends Command {
.respond(filtered.map(playlist => ({ name: playlist.name, value: playlist.name })))
.catch(console.error);
} catch (error) {
console.error('Error in autocomplete interaction:', error);
return await interaction
.respond([{ name: 'An error occurred while fetching playlists.', value: 'Error' }])
.catch(console.error);
Expand Down
2 changes: 1 addition & 1 deletion src/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ const envSchema = z.object({
*/
BOT_ACTIVITY_TYPE: z.preprocess(val => {
if (typeof val === 'string') {
return parseInt(val, 10);
return Number.parseInt(val, 10);
}
return val;
}, z.number().default(0)),
Expand Down
12 changes: 9 additions & 3 deletions src/events/client/SetupSystem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ export default class SetupSystem extends Event {
if (!(channel instanceof TextChannel)) return;
if (!message.member?.voice.channel) {
await oops(channel, T(locale, 'event.message.no_voice_channel_queue'));
await message.delete().catch(() => {});
await message.delete().catch(() => {
null;
});
return;
}

Expand All @@ -42,7 +44,9 @@ export default class SetupSystem extends Event {
channel: clientMember.voice.channelId,
}),
);
await message.delete().catch(() => {});
await message.delete().catch(() => {
null;
});
return;
}

Expand All @@ -60,7 +64,9 @@ export default class SetupSystem extends Event {
}

await setupStart(this.client, message.content, player, message);
await message.delete().catch(() => {});
await message.delete().catch(() => {
null;
});
}
}

Expand Down
4 changes: 3 additions & 1 deletion src/events/client/VoiceStateUpdate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@ export default class VoiceStateUpdate extends Event {
newState.guild.members.me.permissions.has(['Connect', 'Speak']) ||
newState.channel.permissionsFor(newState.guild.members.me).has('MuteMembers')
) {
await newState.guild.members.me.voice.setSuppressed(false).catch(() => {});
await newState.guild.members.me.voice.setSuppressed(false).catch(() => {
null;
});
}
}

Expand Down
8 changes: 6 additions & 2 deletions src/events/player/QueueEnd.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,15 @@ export default class QueueEnd extends Event {
const channel = guild.channels.cache.get(player.textChannelId!) as TextChannel;
if (!channel) return;

const message = await channel.messages.fetch(messageId).catch(() => {});
const message = await channel.messages.fetch(messageId).catch(() => {
null;
});
if (!message) return;

if (message.editable) {
await message.edit({ components: [] }).catch(() => {});
await message.edit({ components: [] }).catch(() => {
null;
});
}
}
}
Expand Down
8 changes: 6 additions & 2 deletions src/events/player/TrackEnd.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,14 @@ export default class TrackEnd extends Event {
const channel = guild.channels.cache.get(player.textChannelId!) as TextChannel;
if (!channel) return;

const message = await channel.messages.fetch(messageId).catch(() => {});
const message = await channel.messages.fetch(messageId).catch(() => {
null;
});
if (!message) return;

message.delete().catch(() => {});
message.delete().catch(() => {
null;
});
}
}

Expand Down
4 changes: 3 additions & 1 deletion src/utils/BotLog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ export default class BotLog {
const color = colors[type];
const embed = client.embed().setColor(color).setDescription(message).setTimestamp();

channel.send({ embeds: [embed] }).catch(() => {});
channel.send({ embeds: [embed] }).catch(() => {
null;
});
}
}

Expand Down
44 changes: 34 additions & 10 deletions src/utils/SetupSystem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,9 @@ async function setupStart(client: Lavamusic, query: string, player: Player, mess
})
.then(msg => setTimeout(() => msg.delete(), 5000));
neb(n, player, client, locale);
await m.edit({ embeds: [n] }).catch(() => {});
await m.edit({ embeds: [n] }).catch(() => {
null;
});
break;
}
case 'playlist': {
Expand All @@ -110,7 +112,9 @@ async function setupStart(client: Lavamusic, query: string, player: Player, mess
})
.then(msg => setTimeout(() => msg.delete(), 5000));
neb(n, player, client, locale);
await m.edit({ embeds: [n] }).catch(() => {});
await m.edit({ embeds: [n] }).catch(() => {
null;
});
break;
}
}
Expand Down Expand Up @@ -178,7 +182,9 @@ async function trackStart(
return b;
}),
})
.catch(() => {});
.catch(() => {
null;
});
} else {
await channel
.send({
Expand All @@ -191,7 +197,9 @@ async function trackStart(
.then(msg => {
client.db.setSetup(msg.guild.id, msg.id, msg.channel.id);
})
.catch(() => {});
.catch(() => {
null;
});
}
}

Expand Down Expand Up @@ -241,7 +249,9 @@ async function updateSetup(client: Lavamusic, guild: any, locale: string): Promi
return b;
}),
})
.catch(() => {});
.catch(() => {
null;
});
} else {
const embed = client
.embed()
Expand All @@ -260,7 +270,9 @@ async function updateSetup(client: Lavamusic, guild: any, locale: string): Promi
return b;
}),
})
.catch(() => {});
.catch(() => {
null;
});
}
}
}
Expand All @@ -269,13 +281,19 @@ async function buttonReply(int: any, args: string, color: ColorResolvable): Prom
const embed = new EmbedBuilder();
let m: Message;
if (int.replied) {
m = await int.editReply({ embeds: [embed.setColor(color).setDescription(args)] }).catch(() => {});
m = await int.editReply({ embeds: [embed.setColor(color).setDescription(args)] }).catch(() => {
null;
});
} else {
m = await int.followUp({ embeds: [embed.setColor(color).setDescription(args)] }).catch(() => {});
m = await int.followUp({ embeds: [embed.setColor(color).setDescription(args)] }).catch(() => {
null;
});
}
setTimeout(async () => {
if (int && !int.ephemeral) {
await m.delete().catch(() => {});
await m.delete().catch(() => {
null;
});
}
}, 2000);
}
Expand All @@ -286,7 +304,13 @@ async function oops(channel: TextChannel, args: string): Promise<void> {
const m = await channel.send({
embeds: [embed1],
});
setTimeout(async () => await m.delete().catch(() => {}), 12000);
setTimeout(
async () =>
await m.delete().catch(() => {
null;
}),
12000,
);
} catch (e) {
return console.error(e);
}
Expand Down
2 changes: 1 addition & 1 deletion src/utils/Utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export class Utils {
}

public static chunk(array: any[], size: number) {
const chunked_arr = [];
const chunked_arr: any[][] = [];
for (let index = 0; index < array.length; index += size) {
chunked_arr.push(array.slice(index, size + index));
}
Expand Down

0 comments on commit 7d91283

Please sign in to comment.