audio filters
This commit is contained in:
parent
3fd002187d
commit
9dc01b68bb
5 changed files with 33 additions and 6 deletions
|
@ -19,7 +19,12 @@ client.on("warn", console.warn);
|
|||
// instantiate the player
|
||||
const player = new Player(client);
|
||||
|
||||
player.on("error", console.error);
|
||||
player.on("error", (queue, error) => {
|
||||
console.log(`[${queue.guild.name}] Error emitted from the queue: ${error.message}`);
|
||||
});
|
||||
player.on("connectionError", (queue, error) => {
|
||||
console.log(`[${queue.guild.name}] Error emitted from the connection: ${error.message}`);
|
||||
});
|
||||
|
||||
player.on("trackStart", (queue, track) => {
|
||||
queue.metadata.send(`🎶 | Started playing: **${track.title}** in **${queue.connection.channel.name}**!`);
|
||||
|
@ -136,6 +141,10 @@ client.on("message", async (message) => {
|
|||
{
|
||||
name: "np",
|
||||
description: "Now Playing"
|
||||
},
|
||||
{
|
||||
name: "bassboost",
|
||||
description: "Toggles bassboost filter"
|
||||
}
|
||||
]);
|
||||
|
||||
|
@ -254,6 +263,16 @@ client.on("interaction", async (interaction) => {
|
|||
const success = queue.setRepeatMode(loopMode);
|
||||
const mode = loopMode === QueueRepeatMode.TRACK ? "🔂" : loopMode === QueueRepeatMode.QUEUE ? "🔁" : "▶";
|
||||
return void interaction.followUp({ content: success ? `${mode} | Updated loop mode!` : "❌ | Could not update loop mode!" });
|
||||
} else if (interaction.commandName === "bassboost") {
|
||||
await interaction.defer();
|
||||
const queue = player.getQueue(interaction.guildID);
|
||||
if (!queue || !queue.playing) return void interaction.followUp({ content: "❌ | No music is being played!" });
|
||||
await queue.setFilters({
|
||||
bassboost: !queue.getFiltersEnabled().includes("bassboost"),
|
||||
normalizer2: !queue.getFiltersEnabled().includes("bassboost") // because we need to toggle it with bass
|
||||
});
|
||||
|
||||
return void interaction.followUp({ content: `🎵 | Bassboost ${queue.getFiltersEnabled().includes("bassboost") ? "Enabled" : "Disabled"}!` });
|
||||
} else {
|
||||
interaction.reply({
|
||||
content: "Unknown command!",
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@discordjs/opus": "^0.5.3",
|
||||
"discord-player": "^5.0.0-dev.8d80d82caaaa7432b96b10242e960d0f6080b5a9",
|
||||
"discord-player": "^5.0.0-dev.3fd002187de27ed6dc3398fd8f4f5dfe309ba350",
|
||||
"discord.js": "^13.0.0-dev.c850ae10270076c4b2e10b130dd8f88eed4ed201"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@ import { Collection, Guild, StageChannel, VoiceChannel } from "discord.js";
|
|||
import { Player } from "../Player";
|
||||
import { StreamDispatcher } from "../VoiceInterface/BasicStreamDispatcher";
|
||||
import Track from "./Track";
|
||||
import { PlayerOptions, PlayOptions, QueueFilters, QueueRepeatMode } from "../types/types";
|
||||
import { FiltersName, PlayerOptions, PlayOptions, QueueFilters, QueueRepeatMode } from "../types/types";
|
||||
import ytdl from "discord-ytdl-core";
|
||||
import { AudioResource, StreamType } from "@discordjs/voice";
|
||||
import { Util } from "../utils/Util";
|
||||
|
|
|
@ -12,7 +12,9 @@ export type FiltersName = keyof QueueFilters;
|
|||
* @typedef {AudioFilters} QueueFilters
|
||||
*/
|
||||
export type QueueFilters = {
|
||||
bassboost_low?: boolean;
|
||||
bassboost?: boolean;
|
||||
bassboost_high?: boolean;
|
||||
"8D"?: boolean;
|
||||
vaporwave?: boolean;
|
||||
nightcore?: boolean;
|
||||
|
|
|
@ -1,9 +1,13 @@
|
|||
import { FiltersName } from "../types/types";
|
||||
|
||||
const bass = (g: number) => `bass=g=${g}:f=110:w=0.3`;
|
||||
|
||||
/**
|
||||
* The available audio filters
|
||||
* @typedef {object} AudioFilters
|
||||
* @property {string} bassboost The bassboost filter
|
||||
* @property {string} bassboost_low The bassboost filter (+15dB)
|
||||
* @property {string} bassboost The bassboost filter (+20dB)
|
||||
* @property {string} bassboost_high The bassboost filter (+30dB)
|
||||
* @property {string} 8D The 8D filter
|
||||
* @property {string} vaporwave The vaporwave filter
|
||||
* @property {string} nightcore The nightcore filter
|
||||
|
@ -37,7 +41,9 @@ import { FiltersName } from "../types/types";
|
|||
*/
|
||||
|
||||
const FilterList = {
|
||||
bassboost: "bass=g=20:f=110:w=0.3",
|
||||
bassboost_low: bass(15),
|
||||
bassboost: bass(20),
|
||||
bassboost_high: bass(30),
|
||||
"8D": "apulsator=hz=0.09",
|
||||
vaporwave: "aresample=48000,asetrate=48000*0.8",
|
||||
nightcore: "aresample=48000,asetrate=48000*1.25",
|
||||
|
@ -76,7 +82,7 @@ const FilterList = {
|
|||
},
|
||||
|
||||
get names() {
|
||||
return Object.keys(this).filter((p) => !["names", "length"].includes(p) && typeof this[p as FiltersName] !== "function");
|
||||
return Object.keys(this).filter((p) => !["names", "length"].includes(p) && typeof this[p as FiltersName] !== "function") as FiltersName[];
|
||||
},
|
||||
|
||||
get length() {
|
||||
|
|
Loading…
Reference in a new issue