From 7d47cc28bb8c176cacea2da90269a6982e469018 Mon Sep 17 00:00:00 2001 From: hwangsihu Date: Mon, 8 Jul 2024 19:24:06 +0900 Subject: [PATCH 1/3] Added commands and some filter change --- src/commands/filters/NightCore.ts | 2 +- src/commands/filters/Pitch.ts | 14 ++--- src/commands/filters/Rate.ts | 75 +++++++++++++++++++++++ src/commands/filters/Speed.ts | 4 +- src/commands/{music => filters}/Volume.ts | 2 +- src/commands/filters/lowPass.ts | 4 +- 6 files changed, 88 insertions(+), 13 deletions(-) create mode 100644 src/commands/filters/Rate.ts rename src/commands/{music => filters}/Volume.ts (98%) diff --git a/src/commands/filters/NightCore.ts b/src/commands/filters/NightCore.ts index 1f0273fbe..c31225086 100644 --- a/src/commands/filters/NightCore.ts +++ b/src/commands/filters/NightCore.ts @@ -44,7 +44,7 @@ export default class NightCore extends Command { ], }); } else { - player.player.setTimescale({ speed: 1.2, pitch: 1.2, rate: 1.0 }); + player.player.setTimescale({speed: 1.2, pitch: 1.2, rate: 1.0}); player.filters.push("nightcore"); ctx.sendMessage({ embeds: [ diff --git a/src/commands/filters/Pitch.ts b/src/commands/filters/Pitch.ts index 90bc001cb..46e875704 100644 --- a/src/commands/filters/Pitch.ts +++ b/src/commands/filters/Pitch.ts @@ -27,7 +27,7 @@ export default class Pitch extends Command { slashCommand: true, options: [ { - name: "number", + name: "pitch", description: "The number you want to set the pitch to (between 0.5 and 5)", type: 3, required: true, @@ -38,10 +38,10 @@ export default class Pitch extends Command { public async run(client: Lavamusic, ctx: Context, args: string[]): Promise { const player = client.queue.get(ctx.guild.id); - const numberString = args[0].replace(",", "."); - const isValidNumber = /^[0-9]*\.?[0-9]+$/.test(numberString); - const number = parseFloat(numberString); - if (!isValidNumber || isNaN(number) || number < 0.5 || number > 5) { + const pitchString = args[0].replace(",", "."); + 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({ embeds: [ { @@ -51,11 +51,11 @@ export default class Pitch extends Command { ], }); } - player.player.setTimescale({ pitch: number }); + player.player.setTimescale({pitch: pitch}); return await ctx.sendMessage({ embeds: [ { - description: `Pitch has been set to ${number}.`, + description: `Pitch has been set to ${pitch}.`, color: this.client.color.main, }, ], diff --git a/src/commands/filters/Rate.ts b/src/commands/filters/Rate.ts new file mode 100644 index 000000000..83e7ef60f --- /dev/null +++ b/src/commands/filters/Rate.ts @@ -0,0 +1,75 @@ +import { Command, type Context, type Lavamusic } from "../../structures/index.js"; + +export default class Rate extends Command { + constructor(client: Lavamusic) { + super(client, { + name: "rate", + description: { + content: "Change the rate of the song", + examples: ["rate 1", "pitch 1.5", "pitch 1,5"], + usage: "rate ", + }, + category: "filters", + aliases: ["rt"], + cooldown: 3, + args: true, + player: { + voice: true, + dj: true, + active: true, + djPerm: null, + }, + permissions: { + dev: false, + client: ["SendMessages", "ViewChannel", "EmbedLinks"], + user: [], + }, + slashCommand: true, + options: [ + { + name: "rate", + description: "The number you want to set the rate to (between 0.5 and 5)", + type: 3, + required: true, + }, + ], + }); + } + + public async run(client: Lavamusic, ctx: Context, args: string[]): Promise { + const player = client.queue.get(ctx.guild.id); + const rateString = args[0].replace(",", "."); + 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({ + embeds: [ + { + description: "Please provide a valid number between 0.5 and 5.", + color: this.client.color.red, + }, + ], + }); + } + player.player.setTimescale({rate: rate}); + return await ctx.sendMessage({ + embeds: [ + { + description: `Pitch and speed has been set to ${rate}.`, + color: this.client.color.main, + }, + ], + }); + } +} + +/** + * Project: lavamusic + * Author: Appu + * Main Contributor: LucasB25 + * Company: Coders + * Copyright (c) 2024. All rights reserved. + * This code is the property of Coder and may not be reproduced or + * modified without permission. For more information, contact us at + * https://discord.gg/ns8CTk9J3e + */ diff --git a/src/commands/filters/Speed.ts b/src/commands/filters/Speed.ts index cc33a9176..3c011a441 100644 --- a/src/commands/filters/Speed.ts +++ b/src/commands/filters/Speed.ts @@ -5,7 +5,7 @@ export default class Speed extends Command { super(client, { name: "speed", description: { - content: "Sets the speed of the song", + content: "Change the speed of the song", examples: ["speed 1.5", "speed 1,5"], usage: "speed ", }, @@ -51,7 +51,7 @@ export default class Speed extends Command { ], }); } - player.player.setTimescale({ speed }); + player.player.setTimescale({speed}); return await ctx.sendMessage({ embeds: [ { diff --git a/src/commands/music/Volume.ts b/src/commands/filters/Volume.ts similarity index 98% rename from src/commands/music/Volume.ts rename to src/commands/filters/Volume.ts index bc6773747..32a412c97 100644 --- a/src/commands/music/Volume.ts +++ b/src/commands/filters/Volume.ts @@ -9,7 +9,7 @@ export default class Volume extends Command { examples: ["volume 100"], usage: "volume ", }, - category: "music", + category: "filters", aliases: ["vol"], cooldown: 3, args: true, diff --git a/src/commands/filters/lowPass.ts b/src/commands/filters/lowPass.ts index 1bc490614..1274f955a 100644 --- a/src/commands/filters/lowPass.ts +++ b/src/commands/filters/lowPass.ts @@ -33,7 +33,7 @@ export default class LowPass extends Command { const player = client.queue.get(ctx.guild.id); const filterEnabled = player.filters.includes("lowpass"); if (filterEnabled) { - player.player.setLowPass({}); //TODO + player.player.setLowPass({smoothing: 0}); player.filters = player.filters.filter((filter) => filter !== "lowpass"); ctx.sendMessage({ embeds: [ @@ -44,7 +44,7 @@ export default class LowPass extends Command { ], }); } else { - player.player.setLowPass({ smoothing: 20 }); + player.player.setLowPass({smoothing: 20}); player.filters.push("lowpass"); ctx.sendMessage({ embeds: [ From 4eda06c06668e87f8bab364ca7b46e18452c82ee Mon Sep 17 00:00:00 2001 From: hwangsihu Date: Mon, 8 Jul 2024 19:27:37 +0900 Subject: [PATCH 2/3] Nightcore fixed --- src/commands/filters/NightCore.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/commands/filters/NightCore.ts b/src/commands/filters/NightCore.ts index c31225086..94552e1a9 100644 --- a/src/commands/filters/NightCore.ts +++ b/src/commands/filters/NightCore.ts @@ -44,7 +44,7 @@ export default class NightCore extends Command { ], }); } else { - player.player.setTimescale({speed: 1.2, pitch: 1.2, rate: 1.0}); + player.player.setTimescale({rate: 1.2}); player.filters.push("nightcore"); ctx.sendMessage({ embeds: [ From 2b06c9342e1653d488542860ee3073c1976440fb Mon Sep 17 00:00:00 2001 From: LucasB25 <50886682+LucasB25@users.noreply.github.com> Date: Mon, 8 Jul 2024 13:48:55 +0200 Subject: [PATCH 3/3] Update Volume.ts Signed-off-by: LucasB25 <50886682+LucasB25@users.noreply.github.com> --- src/commands/filters/Volume.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/commands/filters/Volume.ts b/src/commands/filters/Volume.ts index 32a412c97..bc6773747 100644 --- a/src/commands/filters/Volume.ts +++ b/src/commands/filters/Volume.ts @@ -9,7 +9,7 @@ export default class Volume extends Command { examples: ["volume 100"], usage: "volume ", }, - category: "filters", + category: "music", aliases: ["vol"], cooldown: 3, args: true,