Skip to content

Commit

Permalink
added filters
Browse files Browse the repository at this point in the history
  • Loading branch information
appujet committed Sep 15, 2024
1 parent d25e529 commit 41697fe
Show file tree
Hide file tree
Showing 22 changed files with 526 additions and 30 deletions.
1 change: 0 additions & 1 deletion .husky/commit-msg

This file was deleted.

1 change: 0 additions & 1 deletion .husky/pre-commit

This file was deleted.

1 change: 0 additions & 1 deletion commitlint.config.js

This file was deleted.

9 changes: 0 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,9 @@
"homepage": "https://github.com/appujet/lavamusic#readme",
"devDependencies": {
"@biomejs/biome": "^1.9.0",
"@commitlint/cli": "^19.5.0",
"@commitlint/config-conventional": "^19.5.0",
"@types/i18n": "^0.13.12",
"@types/node": "^22.5.5",
"@types/signale": "^1.4.7",
"husky": "^9.1.6",
"lint-staged": "^15.2.10",
"prisma": "^5.19.1",
"tslib": "^2.7.0",
"typescript": "^5.6.2"
Expand All @@ -59,11 +55,6 @@
"undici": "^6.19.8",
"zod": "^3.23.8"
},
"lint-staged": {
"*.ts": [
"biome check --write"
]
},
"signale": {
"displayScope": true,
"displayBadge": true,
Expand Down
2 changes: 1 addition & 1 deletion src/commands/config/247.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export default class _247 extends Command {
textChannelId: ctx.channel.id,
selfMute: false,
selfDeaf: true,
instaUpdateFiltersFix: true,

vcRegion: member.voice.channel.rtcRegion,
});
}
Expand Down
2 changes: 1 addition & 1 deletion src/commands/filters/NightCore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export default class NightCore extends Command {
const filterEnabled = player.filterManager.filters.nightcore;

if (filterEnabled) {
await player.filterManager.toggleNightcore();
await player.filterManager.toggleTremolo();
await ctx.sendMessage({
embeds: [
{
Expand Down
81 changes: 81 additions & 0 deletions src/commands/filters/Pitch.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
import { Command, type Context, type Lavamusic } from "../../structures/index.js";

export default class Pitch extends Command {
constructor(client: Lavamusic) {
super(client, {
name: "pitch",
description: {
content: "cmd.pitch.description",
examples: ["pitch 1", "pitch 1.5", "pitch 1,5"],
usage: "pitch <number>",
},
category: "filters",
aliases: ["ph"],
cooldown: 3,
args: true,
vote: false,
player: {
voice: true,
dj: true,
active: true,
djPerm: null,
},
permissions: {
dev: false,
client: ["SendMessages", "ReadMessageHistory", "ViewChannel", "EmbedLinks"],
user: [],
},
slashCommand: true,
options: [
{
name: "pitch",
description: "cmd.pitch.options.pitch",
type: 3,
required: true,
},
],
});
}

public async run(client: Lavamusic, ctx: Context, args: string[]): Promise<any> {
const player = client.manager.getPlayer(ctx.guild!.id);
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) {
await ctx.sendMessage({
embeds: [
{
description: ctx.locale("cmd.pitch.errors.invalid_number"),
color: this.client.color.red,
},
],
});
return;
}

await player.filterManager.setPitch(pitch);
return await ctx.sendMessage({
embeds: [
{
description: ctx.locale("cmd.pitch.messages.pitch_set", {
pitch,
}),
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
*/
81 changes: 81 additions & 0 deletions src/commands/filters/Rate.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
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: "cmd.rate.description",
examples: ["rate 1", "rate 1.5", "rate 1,5"],
usage: "rate <number>",
},
category: "filters",
aliases: ["rt"],
cooldown: 3,
args: true,
vote: false,
player: {
voice: true,
dj: true,
active: true,
djPerm: null,
},
permissions: {
dev: false,
client: ["SendMessages", "ReadMessageHistory", "ViewChannel", "EmbedLinks"],
user: [],
},
slashCommand: true,
options: [
{
name: "rate",
description: "cmd.rate.options.rate",
type: 3,
required: true,
},
],
});
}

public async run(client: Lavamusic, ctx: Context, args: string[]): Promise<any> {
const player = client.manager.getPlayer(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) {
await ctx.sendMessage({
embeds: [
{
description: ctx.locale("cmd.rate.errors.invalid_number"),
color: this.client.color.red,
},
],
});
return;
}

await player.filterManager.setRate(rate);
await ctx.sendMessage({
embeds: [
{
description: ctx.locale("cmd.rate.messages.rate_set", {
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
*/
57 changes: 57 additions & 0 deletions src/commands/filters/Reset.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
import { Command, type Context, type Lavamusic } from "../../structures/index.js";

export default class Reset extends Command {
constructor(client: Lavamusic) {
super(client, {
name: "reset",
description: {
content: "cmd.reset.description",
examples: ["reset"],
usage: "reset",
},
category: "filters",
aliases: ["rs"],
cooldown: 3,
args: false,
vote: false,
player: {
voice: true,
dj: true,
active: false,
djPerm: null,
},
permissions: {
dev: false,
client: ["SendMessages", "ReadMessageHistory", "ViewChannel", "EmbedLinks"],
user: [],
},
slashCommand: true,
options: [],
});
}

public async run(client: Lavamusic, ctx: Context): Promise<any> {
const player = client.manager.getPlayer(ctx.guild!.id);
player.filterManager.resetFilters();
player.filterManager.clearEQ();
await ctx.sendMessage({
embeds: [
{
description: ctx.locale("cmd.reset.messages.filters_reset"),
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
*/
68 changes: 68 additions & 0 deletions src/commands/filters/Rotation.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
import { Command, type Context, type Lavamusic } from "../../structures/index.js";

export default class Rotation extends Command {
constructor(client: Lavamusic) {
super(client, {
name: "rotation",
description: {
content: "cmd.rotation.description",
examples: ["rotation"],
usage: "rotation",
},
category: "filters",
aliases: ["rt"],
cooldown: 3,
args: false,
vote: false,
player: {
voice: true,
dj: true,
active: true,
djPerm: null,
},
permissions: {
dev: false,
client: ["SendMessages", "ReadMessageHistory", "ViewChannel", "EmbedLinks"],
user: [],
},
slashCommand: true,
options: [],
});
}

public async run(client: Lavamusic, ctx: Context): Promise<any> {
const player = client.manager.getPlayer(ctx.guild!.id);
if (player.filterManager.filters.rotation) {
player.filterManager.toggleRotation();
await ctx.sendMessage({
embeds: [
{
description: ctx.locale("cmd.rotation.messages.disabled"),
color: this.client.color.main,
},
],
});
} else {
player.filterManager.toggleRotation();
await ctx.sendMessage({
embeds: [
{
description: ctx.locale("cmd.rotation.messages.enabled"),
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
*/
Loading

0 comments on commit 41697fe

Please sign in to comment.