Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added command and some filters change #599

Merged
merged 3 commits into from
Jul 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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