Skip to content

Commit

Permalink
Merge pull request appujet#599 from hwangsihu/main
Browse files Browse the repository at this point in the history
Added command and some filters change
  • Loading branch information
LucasB25 authored Jul 8, 2024
2 parents 15e7db9 + 2b06c93 commit e3d1550
Show file tree
Hide file tree
Showing 6 changed files with 87 additions and 12 deletions.
2 changes: 1 addition & 1 deletion src/commands/filters/NightCore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: [
Expand Down
14 changes: 7 additions & 7 deletions src/commands/filters/Pitch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -38,10 +38,10 @@ export default class Pitch extends Command {

public async run(client: Lavamusic, ctx: Context, args: string[]): Promise<any> {
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: [
{
Expand All @@ -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,
},
],
Expand Down
75 changes: 75 additions & 0 deletions src/commands/filters/Rate.ts
Original file line number Diff line number Diff line change
@@ -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 <number>",
},
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<any> {
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
*/
4 changes: 2 additions & 2 deletions src/commands/filters/Speed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 <number>",
},
Expand Down Expand Up @@ -51,7 +51,7 @@ export default class Speed extends Command {
],
});
}
player.player.setTimescale({ speed });
player.player.setTimescale({speed});
return await ctx.sendMessage({
embeds: [
{
Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions src/commands/filters/lowPass.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: [
Expand All @@ -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: [
Expand Down

0 comments on commit e3d1550

Please sign in to comment.