From f3984e51e6c2c9b89be662b61ff216c8db39ef3b Mon Sep 17 00:00:00 2001 From: LucasB25#7323 <50886682+LucasB25@users.noreply.github.com> Date: Tue, 16 Jul 2024 15:16:47 +0200 Subject: [PATCH] update --- src/commands/config/247.ts | 4 +- src/commands/config/Dj.ts | 135 +++++++++++++++-------------- src/commands/config/Prefix.ts | 12 +-- src/commands/config/Setup.ts | 6 +- src/commands/dev/Eval.ts | 11 ++- src/commands/dev/GuildLeave.ts | 14 +-- src/commands/dev/GuildList.ts | 2 +- src/commands/filters/8d.ts | 12 +-- src/commands/filters/BassBoost.ts | 13 +-- src/commands/filters/Distorsion.ts | 13 +-- src/commands/filters/Karaoke.ts | 13 +-- src/commands/filters/NightCore.ts | 13 +-- src/commands/filters/Pitch.ts | 6 +- src/commands/filters/Rate.ts | 10 +-- src/commands/filters/Reset.ts | 4 +- src/commands/filters/Rotation.ts | 11 ++- src/commands/filters/Speed.ts | 6 +- src/commands/filters/Tremolo.ts | 10 ++- src/commands/filters/Vibrato.ts | 10 ++- src/commands/filters/lowPass.ts | 13 +-- src/commands/info/Help.ts | 2 +- 21 files changed, 171 insertions(+), 149 deletions(-) diff --git a/src/commands/config/247.ts b/src/commands/config/247.ts index decde7b87..14fd920b1 100644 --- a/src/commands/config/247.ts +++ b/src/commands/config/247.ts @@ -31,7 +31,7 @@ export default class _247 extends Command { } public async run(client: Lavamusic, ctx: Context): Promise { - const embed = client.embed(); + const embed = this.client.embed(); let player = client.shoukaku.players.get(ctx.guild.id) as any; try { const data = await client.db.get_247(ctx.guild.id); @@ -62,7 +62,7 @@ export default class _247 extends Command { .setDescription( "**24/7 mode has been enabled. The bot will not leave the voice channel even if there are no people in the voice channel.**", ) - .setColor(client.color.main), + .setColor(this.client.color.main), ], }); } catch (error) { diff --git a/src/commands/config/Dj.ts b/src/commands/config/Dj.ts index dd1a20757..8a673c981 100644 --- a/src/commands/config/Dj.ts +++ b/src/commands/config/Dj.ts @@ -1,4 +1,3 @@ -//TODO import { Command, type Context, type Lavamusic } from "../../structures/index.js"; export default class Dj extends Command { @@ -29,12 +28,12 @@ export default class Dj extends Command { options: [ { name: "add", - description: "The dj role you want to add", + description: "The DJ role you want to add", type: 1, options: [ { name: "role", - description: "The dj role you want to add", + description: "The DJ role you want to add", type: 8, required: true, }, @@ -42,12 +41,12 @@ export default class Dj extends Command { }, { name: "remove", - description: "The dj role you want to remove", + description: "The DJ role you want to remove", type: 1, options: [ { name: "role", - description: "The dj role you want to remove", + description: "The DJ role you want to remove", type: 8, required: true, }, @@ -55,12 +54,12 @@ export default class Dj extends Command { }, { name: "clear", - description: "Clears all dj roles", + description: "Clears all DJ roles", type: 1, }, { name: "toggle", - description: "Toggles the dj role", + description: "Toggles the DJ role", type: 1, }, ], @@ -68,8 +67,11 @@ export default class Dj extends Command { } public async run(client: Lavamusic, ctx: Context, args: string[]): Promise { + const embed = this.client.embed().setColor(this.client.color.main); + const dj = await client.db.getDj(ctx.guild.id); let subCommand: string; let role: any; + if (ctx.isInteraction) { subCommand = ctx.interaction.options.data[0].name; if (subCommand === "add" || subCommand === "remove") { @@ -79,70 +81,71 @@ export default class Dj extends Command { subCommand = args[0]; role = ctx.message.mentions.roles.first() || ctx.guild.roles.cache.get(args[1]); } - const embed = client.embed().setColor(client.color.main); - const dj = await client.db.getDj(ctx.guild.id); - if (subCommand === "add") { - if (!role) - return await ctx.sendMessage({ - embeds: [embed.setDescription("Please provide a role to add.")], - }); - const isExRole = await client.db.getRoles(ctx.guild.id).then((r) => r.find((re) => re.roleId === role.id)); - if (isExRole) - return await ctx.sendMessage({ - embeds: [embed.setDescription(`The dj role <@&${role.id}> is already added.`)], - }); - client.db.addRole(ctx.guild.id, role.id); - client.db.setDj(ctx.guild.id, true); - return await ctx.sendMessage({ - embeds: [embed.setDescription(`The dj role <@&${role.id}> has been added.`)], - }); - } - if (subCommand === "remove") { - if (!role) - return await ctx.sendMessage({ - embeds: [embed.setDescription("Please provide a role to remove.")], + + switch (subCommand) { + case "add": + if (!role) { + return ctx.sendMessage({ + embeds: [embed.setDescription("Please provide a role to add.")], + }); + } + if (await client.db.getRoles(ctx.guild.id).then((r) => r.some((re) => re.roleId === role.id))) { + return ctx.sendMessage({ + embeds: [embed.setDescription(`The DJ role <@&${role.id}> is already added.`)], + }); + } + await client.db.addRole(ctx.guild.id, role.id); + await client.db.setDj(ctx.guild.id, true); + return ctx.sendMessage({ + embeds: [embed.setDescription(`The DJ role <@&${role.id}> has been added.`)], }); - const isExRole = await client.db.getRoles(ctx.guild.id).then((r) => r.find((re) => re.roleId === role.id)); - if (!isExRole) - return await ctx.sendMessage({ - embeds: [embed.setDescription(`The dj role <@&${role.id}> is not added.`)], + + case "remove": + if (!role) { + return ctx.sendMessage({ + embeds: [embed.setDescription("Please provide a role to remove.")], + }); + } + if (!(await client.db.getRoles(ctx.guild.id).then((r) => r.some((re) => re.roleId === role.id)))) { + return ctx.sendMessage({ + embeds: [embed.setDescription(`The DJ role <@&${role.id}> is not added.`)], + }); + } + await client.db.removeRole(ctx.guild.id, role.id); + return ctx.sendMessage({ + embeds: [embed.setDescription(`The DJ role <@&${role.id}> has been removed.`)], }); - client.db.removeRole(ctx.guild.id, role.id); - return await ctx.sendMessage({ - embeds: [embed.setDescription(`The dj role <@&${role.id}> has been removed.`)], - }); - } - if (subCommand === "clear") { - if (!dj) - return await ctx.sendMessage({ - embeds: [embed.setDescription("The dj role is already empty.")], + + case "clear": + if (!dj) { + return ctx.sendMessage({ + embeds: [embed.setDescription("The DJ role is already empty.")], + }); + } + await client.db.clearRoles(ctx.guild.id); + return ctx.sendMessage({ + embeds: [embed.setDescription("All DJ roles have been removed.")], }); - client.db.clearRoles(ctx.guild.id); - return await ctx.sendMessage({ - embeds: [embed.setDescription("All dj roles have been removed.")], - }); - } - if (subCommand === "toggle") { - if (!dj) - return await ctx.sendMessage({ - embeds: [embed.setDescription("The dj role is empty.")], + + case "toggle": + if (!dj) { + return ctx.sendMessage({ + embeds: [embed.setDescription("The DJ role is empty.")], + }); + } + await client.db.setDj(ctx.guild.id, !dj.mode); + return ctx.sendMessage({ + embeds: [embed.setDescription(`The DJ mode has been toggled to ${dj.mode ? "disabled." : "enabled."}`)], }); - const data = await client.db.getDj(ctx.guild.id); - if (data) { - client.db.setDj(ctx.guild.id, !data.mode); - return await ctx.sendMessage({ - embeds: [embed.setDescription(`The dj mode has been toggled to ${data.mode ? "disabled." : "enabled."}`)], + + default: + return ctx.sendMessage({ + embeds: [ + embed + .setDescription("Please provide a valid subcommand.") + .addFields({ name: "Subcommands", value: "`add`, `remove`, `clear`, `toggle`" }), + ], }); - } - } else { - return await ctx.sendMessage({ - embeds: [ - embed.setDescription("Please provide a valid subcommand.").addFields({ - name: "Subcommands", - value: "`add`, `remove`, `clear`, `toggle`", - }), - ], - }); } } } diff --git a/src/commands/config/Prefix.ts b/src/commands/config/Prefix.ts index 044169f6f..85f18f8ef 100644 --- a/src/commands/config/Prefix.ts +++ b/src/commands/config/Prefix.ts @@ -49,12 +49,13 @@ export default class Prefix extends Command { } public async run(client: Lavamusic, ctx: Context, args: string[]): Promise { - const embed = client.embed().setColor(client.color.main); + const embed = client.embed().setColor(this.client.color.main); const guildId = ctx.guild.id; const guildData = await client.db.get(guildId); const isInteraction = ctx.isInteraction; - let subCommand = ""; - let prefix = ""; + let subCommand: string; + let prefix: string; + if (isInteraction) { subCommand = ctx.interaction.options.data[0].name; prefix = ctx.interaction.options.data[0].options[0]?.value.toString(); @@ -62,6 +63,7 @@ export default class Prefix extends Command { subCommand = args[0] || ""; prefix = args[1] || ""; } + switch (subCommand) { case "set": { if (!prefix) { @@ -73,13 +75,13 @@ export default class Prefix extends Command { embed.setDescription("The prefix cannot be longer than 3 characters."); return await ctx.sendMessage({ embeds: [embed] }); } - client.db.setPrefix(guildId, prefix); + await client.db.setPrefix(guildId, prefix); embed.setDescription(`The prefix for this server is now \`${prefix}\``); return await ctx.sendMessage({ embeds: [embed] }); } case "reset": { const defaultPrefix = client.config.prefix; - client.db.setPrefix(guildId, defaultPrefix); + await client.db.setPrefix(guildId, defaultPrefix); embed.setDescription(`The prefix for this server is now \`${defaultPrefix}\``); return await ctx.sendMessage({ embeds: [embed] }); } diff --git a/src/commands/config/Setup.ts b/src/commands/config/Setup.ts index b025383ec..4c6454935 100644 --- a/src/commands/config/Setup.ts +++ b/src/commands/config/Setup.ts @@ -49,7 +49,7 @@ export default class Setup extends Command { public async run(client: Lavamusic, ctx: Context, args: string[]): Promise { const subCommand = ctx.isInteraction ? ctx.interaction.options.data[0].name : args[0]; - const embed = client.embed().setColor(client.color.main); + const embed = client.embed().setColor(this.client.color.main); switch (subCommand) { case "create": { const data = await client.db.getSetup(ctx.guild.id); @@ -103,7 +103,7 @@ export default class Setup extends Command { embeds: [ { description: `The song request channel has been created in <#${textChannel.id}>.`, - color: client.color.main, + color: this.client.color.main, }, ], }); @@ -129,7 +129,7 @@ export default class Setup extends Command { { description: "The song request channel has been deleted. If the channel is not deleted normally, please delete it yourself.", - color: client.color.main, + color: this.client.color.main, }, ], }); diff --git a/src/commands/dev/Eval.ts b/src/commands/dev/Eval.ts index d4e5a9e06..494c0106a 100644 --- a/src/commands/dev/Eval.ts +++ b/src/commands/dev/Eval.ts @@ -37,8 +37,7 @@ export default class Eval extends Command { try { let evaled = eval(code); if (evaled === client.config) evaled = "Nice try"; - const button = new ButtonBuilder().setStyle(ButtonStyle.Danger).setLabel("Delete").setCustomId("eval-delete"); - const row = new ActionRowBuilder().addComponents(button); + if (typeof evaled !== "string") evaled = util.inspect(evaled); if (evaled.length > 2000) { const response = await fetch("https://hasteb.in/post", { @@ -54,15 +53,21 @@ export default class Eval extends Command { content: evaled, }); } + + const button = new ButtonBuilder().setStyle(ButtonStyle.Danger).setLabel("Delete").setCustomId("eval-delete"); + const row = new ActionRowBuilder().addComponents(button); + const msg = await ctx.sendMessage({ content: `\`\`\`js\n${evaled}\n\`\`\``, components: [row], }); - const filter = (i: any): boolean => i.customId === "eval-delete" && i.user.id === ctx.author.id; + + const filter = (i: any) => i.customId === "eval-delete" && i.user.id === ctx.author.id; const collector = msg.createMessageComponentCollector({ time: 60000, filter: filter, }); + collector.on("collect", async (i) => { await i.deferUpdate(); await msg.delete(); diff --git a/src/commands/dev/GuildLeave.ts b/src/commands/dev/GuildLeave.ts index f7c6a693f..84b3fb78d 100644 --- a/src/commands/dev/GuildLeave.ts +++ b/src/commands/dev/GuildLeave.ts @@ -6,8 +6,8 @@ export default class GuildLeave extends Command { name: "guildleave", description: { content: "Leave a guild", - examples: ["guildleave"], - usage: "guildleave", + examples: ["guildleave "], + usage: "guildleave ", }, category: "dev", aliases: ["gl"], @@ -29,15 +29,15 @@ export default class GuildLeave extends Command { }); } - public async run(_client: Lavamusic, ctx: Context, args: string[]): Promise { + public async run(client: Lavamusic, ctx: Context, args: string[]): Promise { const guildId = args[0]; - const guild = this.client.guilds.cache.get(guildId); + const guild = client.guilds.cache.get(guildId); if (!guild) return await ctx.sendMessage("Guild not found."); try { await guild.leave(); - ctx.sendMessage(`Left guild ${guild.name}`); - } catch (_error) { - ctx.sendMessage(`Failed to leave guild ${guild.name}`); + await ctx.sendMessage(`Left guild ${guild.name}`); + } catch { + await ctx.sendMessage(`Failed to leave guild ${guild.name}`); } } } diff --git a/src/commands/dev/GuildList.ts b/src/commands/dev/GuildList.ts index 1a9ab47d7..58c52acf8 100644 --- a/src/commands/dev/GuildList.ts +++ b/src/commands/dev/GuildList.ts @@ -30,7 +30,7 @@ export default class GuildList extends Command { } public async run(client: Lavamusic, ctx: Context): Promise { - const guilds = this.client.guilds.cache.map((guild) => `- **${guild.name}** - (${guild.id})`); + const guilds = client.guilds.cache.map((guild) => `- **${guild.name}** - (${guild.id})`); const chunks = client.utils.chunk(guilds, 10) || [[]]; const pages = chunks.map((chunk, index) => { return this.client diff --git a/src/commands/filters/8d.ts b/src/commands/filters/8d.ts index af114ca4c..f6d7fec91 100644 --- a/src/commands/filters/8d.ts +++ b/src/commands/filters/8d.ts @@ -33,24 +33,26 @@ export default class _8d extends Command { const player = client.queue.get(ctx.guild.id); const filterEnabled = player.filters.includes("8D"); const rotationConfig = filterEnabled ? {} : { rotationHz: 0.2 }; - player.player.setRotation(rotationConfig); + + await player.player.setRotation(rotationConfig); + if (filterEnabled) { player.filters = player.filters.filter((filter) => filter !== "8D"); - ctx.sendMessage({ + await ctx.sendMessage({ embeds: [ { description: "8D filter has been disabled.", - color: client.color.main, + color: this.client.color.main, }, ], }); } else { player.filters.push("8D"); - ctx.sendMessage({ + await ctx.sendMessage({ embeds: [ { description: "8D filter has been enabled.", - color: client.color.main, + color: this.client.color.main, }, ], }); diff --git a/src/commands/filters/BassBoost.ts b/src/commands/filters/BassBoost.ts index 29d452204..b1bfb25e8 100644 --- a/src/commands/filters/BassBoost.ts +++ b/src/commands/filters/BassBoost.ts @@ -32,30 +32,31 @@ export default class BassBoost extends Command { public async run(client: Lavamusic, ctx: Context): Promise { const player = client.queue.get(ctx.guild.id); const filterEnabled = player.filters.includes("bassboost"); + if (filterEnabled) { - player.player.setEqualizer([]); + await player.player.setEqualizer([]); player.filters = player.filters.filter((filter) => filter !== "bassboost"); - ctx.sendMessage({ + await ctx.sendMessage({ embeds: [ { description: "Bassboost filter has been disabled.", - color: client.color.main, + color: this.client.color.main, }, ], }); } else { - player.player.setEqualizer([ + await player.player.setEqualizer([ { band: 0, gain: 0.34 }, { band: 1, gain: 0.34 }, { band: 2, gain: 0.34 }, { band: 3, gain: 0.34 }, ]); player.filters.push("bassboost"); - ctx.sendMessage({ + await ctx.sendMessage({ embeds: [ { description: "Bassboost filter has been enabled. **Be careful, listening too loudly can damage your hearing!**", - color: client.color.main, + color: this.client.color.main, }, ], }); diff --git a/src/commands/filters/Distorsion.ts b/src/commands/filters/Distorsion.ts index 25b8787e5..d6c7cf322 100644 --- a/src/commands/filters/Distorsion.ts +++ b/src/commands/filters/Distorsion.ts @@ -32,19 +32,20 @@ export default class Distorsion extends Command { public async run(client: Lavamusic, ctx: Context): Promise { const player = client.queue.get(ctx.guild.id); const filterEnabled = player.filters.includes("distorsion"); + if (filterEnabled) { - player.player.setDistortion({}); + await player.player.setDistortion({}); player.filters = player.filters.filter((filter) => filter !== "distorsion"); - ctx.sendMessage({ + await ctx.sendMessage({ embeds: [ { description: "Distorsion filter has been disabled.", - color: client.color.main, + color: this.client.color.main, }, ], }); } else { - player.player.setDistortion({ + await player.player.setDistortion({ sinOffset: 0, sinScale: 1, cosOffset: 0, @@ -55,11 +56,11 @@ export default class Distorsion extends Command { scale: 1, }); player.filters.push("distorsion"); - ctx.sendMessage({ + await ctx.sendMessage({ embeds: [ { description: "Distorsion filter has been enabled.", - color: client.color.main, + color: this.client.color.main, }, ], }); diff --git a/src/commands/filters/Karaoke.ts b/src/commands/filters/Karaoke.ts index 131e22694..c8b98afb8 100644 --- a/src/commands/filters/Karaoke.ts +++ b/src/commands/filters/Karaoke.ts @@ -32,30 +32,31 @@ export default class Karaoke extends Command { public async run(client: Lavamusic, ctx: Context): Promise { const player = client.queue.get(ctx.guild.id); const filterEnabled = player.filters.includes("karaoke"); + if (filterEnabled) { - player.player.setKaraoke(); + await player.player.setKaraoke(); player.filters = player.filters.filter((filter) => filter !== "karaoke"); - ctx.sendMessage({ + await ctx.sendMessage({ embeds: [ { description: "Karaoke filter has been disabled.", - color: client.color.main, + color: this.client.color.main, }, ], }); } else { - player.player.setKaraoke({ + await player.player.setKaraoke({ level: 1, monoLevel: 1, filterBand: 220, filterWidth: 100, }); player.filters.push("karaoke"); - ctx.sendMessage({ + await ctx.sendMessage({ embeds: [ { description: "Karaoke filter has been enabled.", - color: client.color.main, + color: this.client.color.main, }, ], }); diff --git a/src/commands/filters/NightCore.ts b/src/commands/filters/NightCore.ts index 05a694034..88bf04acd 100644 --- a/src/commands/filters/NightCore.ts +++ b/src/commands/filters/NightCore.ts @@ -32,25 +32,26 @@ export default class NightCore extends Command { public async run(client: Lavamusic, ctx: Context): Promise { const player = client.queue.get(ctx.guild.id); const filterEnabled = player.filters.includes("nightcore"); + if (filterEnabled) { - player.player.setTimescale(); + await player.player.setTimescale({}); player.filters = player.filters.filter((filter) => filter !== "nightcore"); - ctx.sendMessage({ + await ctx.sendMessage({ embeds: [ { description: "Nightcore filter has been disabled.", - color: client.color.main, + color: this.client.color.main, }, ], }); } else { - player.player.setTimescale({ rate: 1.2 }); + await player.player.setTimescale({ rate: 1.2 }); player.filters.push("nightcore"); - ctx.sendMessage({ + await ctx.sendMessage({ embeds: [ { description: "Nightcore filter has been enabled.", - color: client.color.main, + color: this.client.color.main, }, ], }); diff --git a/src/commands/filters/Pitch.ts b/src/commands/filters/Pitch.ts index 61db2d6b1..87f015e32 100644 --- a/src/commands/filters/Pitch.ts +++ b/src/commands/filters/Pitch.ts @@ -42,7 +42,7 @@ export default class Pitch extends Command { const isValidNumber = /^[0-9]*\.?[0-9]+$/.test(pitchString); const pitch = parseFloat(pitchString); if (!isValidNumber || isNaN(pitch) || pitch < 0.5 || pitch > 5) { - return await ctx.sendMessage({ + await ctx.sendMessage({ embeds: [ { description: "Please provide a valid number between 0.5 and 5.", @@ -51,8 +51,8 @@ export default class Pitch extends Command { ], }); } - player.player.setTimescale({ pitch: pitch }); - return await ctx.sendMessage({ + await player.player.setTimescale({ pitch }); + await ctx.sendMessage({ embeds: [ { description: `Pitch has been set to ${pitch}.`, diff --git a/src/commands/filters/Rate.ts b/src/commands/filters/Rate.ts index 37f2274b8..1d3ed0495 100644 --- a/src/commands/filters/Rate.ts +++ b/src/commands/filters/Rate.ts @@ -6,7 +6,7 @@ export default class Rate extends Command { name: "rate", description: { content: "Change the rate of the song", - examples: ["rate 1", "pitch 1.5", "pitch 1,5"], + examples: ["rate 1", "rate 1.5", "rate 1,5"], usage: "rate ", }, category: "filters", @@ -42,7 +42,7 @@ export default class Rate extends Command { const isValidNumber = /^[0-9]*\.?[0-9]+$/.test(rateString); const rate = parseFloat(rateString); if (!isValidNumber || isNaN(rate) || rate < 0.5 || rate > 5) { - return await ctx.sendMessage({ + await ctx.sendMessage({ embeds: [ { description: "Please provide a valid number between 0.5 and 5.", @@ -51,11 +51,11 @@ export default class Rate extends Command { ], }); } - player.player.setTimescale({ rate: rate }); - return await ctx.sendMessage({ + await player.player.setTimescale({ rate }); + await ctx.sendMessage({ embeds: [ { - description: `Pitch and speed has been set to ${rate}.`, + description: `Rate has been set to ${rate}.`, color: this.client.color.main, }, ], diff --git a/src/commands/filters/Reset.ts b/src/commands/filters/Reset.ts index a26404fe7..1fb5223be 100644 --- a/src/commands/filters/Reset.ts +++ b/src/commands/filters/Reset.ts @@ -33,11 +33,11 @@ export default class Reset extends Command { const player = client.queue.get(ctx.guild.id); player.player.clearFilters(); player.filters = []; - return await ctx.sendMessage({ + await ctx.sendMessage({ embeds: [ { description: "Filters have been reset.", - color: client.color.main, + color: this.client.color.main, }, ], }); diff --git a/src/commands/filters/Rotation.ts b/src/commands/filters/Rotation.ts index e29192c39..53b4c1a6b 100644 --- a/src/commands/filters/Rotation.ts +++ b/src/commands/filters/Rotation.ts @@ -29,28 +29,27 @@ export default class Rotation extends Command { }); } - // biome-ignore lint/suspicious/useAwait: public async run(client: Lavamusic, ctx: Context): Promise { const player = client.queue.get(ctx.guild.id); if (player.filters.includes("rotation")) { player.player.setRotation(); - player.filters.splice(player.filters.indexOf("rotation"), 1); - ctx.sendMessage({ + player.filters = player.filters.filter((filter) => filter !== "rotation"); + await ctx.sendMessage({ embeds: [ { description: "Rotation filter has been disabled.", - color: client.color.main, + color: this.client.color.main, }, ], }); } else { player.player.setRotation({ rotationHz: 0 }); player.filters.push("rotation"); - ctx.sendMessage({ + await ctx.sendMessage({ embeds: [ { description: "Rotation filter has been enabled.", - color: client.color.main, + color: this.client.color.main, }, ], }); diff --git a/src/commands/filters/Speed.ts b/src/commands/filters/Speed.ts index f9f7f09df..331fe7b2d 100644 --- a/src/commands/filters/Speed.ts +++ b/src/commands/filters/Speed.ts @@ -41,8 +41,9 @@ export default class Speed extends Command { const speedString = args[0].replace(",", "."); const isValidNumber = /^[0-9]*\.?[0-9]+$/.test(speedString); const speed = parseFloat(speedString); + if (!isValidNumber || isNaN(speed) || speed < 0.5 || speed > 5) { - return await ctx.sendMessage({ + await ctx.sendMessage({ embeds: [ { description: "Please provide a valid number between 0.5 and 5.", @@ -51,8 +52,9 @@ export default class Speed extends Command { ], }); } + player.player.setTimescale({ speed }); - return await ctx.sendMessage({ + await ctx.sendMessage({ embeds: [ { description: `Speed has been set to ${speed}.`, diff --git a/src/commands/filters/Tremolo.ts b/src/commands/filters/Tremolo.ts index 4a9653f0e..66e7056a4 100644 --- a/src/commands/filters/Tremolo.ts +++ b/src/commands/filters/Tremolo.ts @@ -32,25 +32,27 @@ export default class Tremolo extends Command { public async run(client: Lavamusic, ctx: Context): Promise { const player = client.queue.get(ctx.guild.id); const tremoloEnabled = player.filters.includes("tremolo"); + if (tremoloEnabled) { player.player.setTremolo(); player.filters.splice(player.filters.indexOf("tremolo"), 1); - return await ctx.sendMessage({ + await ctx.sendMessage({ embeds: [ { description: "Tremolo filter has been disabled.", - color: client.color.main, + color: this.client.color.main, }, ], }); } + player.player.setTremolo({ depth: 0.75, frequency: 4 }); player.filters.push("tremolo"); - return await ctx.sendMessage({ + await ctx.sendMessage({ embeds: [ { description: "Tremolo filter has been enabled.", - color: client.color.main, + color: this.client.color.main, }, ], }); diff --git a/src/commands/filters/Vibrato.ts b/src/commands/filters/Vibrato.ts index d8bd862b7..7de11bfe4 100644 --- a/src/commands/filters/Vibrato.ts +++ b/src/commands/filters/Vibrato.ts @@ -32,25 +32,27 @@ export default class Vibrato extends Command { public async run(client: Lavamusic, ctx: Context): Promise { const player = client.queue.get(ctx.guild.id); const vibratoEnabled = player.filters.includes("vibrato"); + if (vibratoEnabled) { player.player.setVibrato(); player.filters.splice(player.filters.indexOf("vibrato"), 1); - return await ctx.sendMessage({ + await ctx.sendMessage({ embeds: [ { description: "Vibrato filter has been disabled.", - color: client.color.main, + color: this.client.color.main, }, ], }); } + player.player.setVibrato({ depth: 0.75, frequency: 4 }); player.filters.push("vibrato"); - return await ctx.sendMessage({ + await ctx.sendMessage({ embeds: [ { description: "Vibrato filter has been enabled.", - color: client.color.main, + color: this.client.color.main, }, ], }); diff --git a/src/commands/filters/lowPass.ts b/src/commands/filters/lowPass.ts index d0db9738c..32cb7d9ee 100644 --- a/src/commands/filters/lowPass.ts +++ b/src/commands/filters/lowPass.ts @@ -32,25 +32,26 @@ export default class LowPass extends Command { public async run(client: Lavamusic, ctx: Context): Promise { const player = client.queue.get(ctx.guild.id); const filterEnabled = player.filters.includes("lowpass"); + if (filterEnabled) { - player.player.setLowPass({ smoothing: 0 }); + await player.player.setLowPass({ smoothing: 0 }); player.filters = player.filters.filter((filter) => filter !== "lowpass"); - ctx.sendMessage({ + await ctx.sendMessage({ embeds: [ { description: "Lowpass filter has been disabled.", - color: client.color.main, + color: this.client.color.main, }, ], }); } else { - player.player.setLowPass({ smoothing: 20 }); + await player.player.setLowPass({ smoothing: 20 }); player.filters.push("lowpass"); - ctx.sendMessage({ + await ctx.sendMessage({ embeds: [ { description: "Lowpass filter has been enabled.", - color: client.color.main, + color: this.client.color.main, }, ], }); diff --git a/src/commands/info/Help.ts b/src/commands/info/Help.ts index 63b1e2414..72e4b08a3 100644 --- a/src/commands/info/Help.ts +++ b/src/commands/info/Help.ts @@ -37,7 +37,7 @@ export default class Help extends Command { } public async run(client: Lavamusic, ctx: Context, args: string[]): Promise { - const embed = client.embed(); + const embed = this.client.embed(); const guild = await client.db.get(ctx.guild.id); const commands = this.client.commands.filter((cmd) => cmd.category !== "dev"); const categories = [...new Set(commands.map((cmd) => cmd.category))];