mirror of
https://github.com/darksaid98/cadence-discord-bot.git
synced 2026-12-02 14:38:49 +00:00
WIP add support for filters other than ffmpeg
This commit is contained in:
1 parent
04dd7a7218
commit
af6bdd4da8
2 files changed
+50
-5
No files matched your search
@@ -6,7 +6,8 @@ import {
|
||||
Interaction,
|
||||
Message,
|
||||
MessageComponentInteraction,
|
||||
SlashCommandBuilder
|
||||
SlashCommandBuilder,
|
||||
SlashCommandSubcommandsOnlyBuilder
|
||||
} from 'discord.js';
|
||||
import { Logger } from 'pino';
|
||||
import loggerModule from '../services/logger';
|
||||
@@ -43,7 +44,7 @@ abstract class BaseInteraction {
|
||||
}
|
||||
|
||||
export abstract class BaseSlashCommandInteraction extends BaseInteraction {
|
||||
data: Omit<SlashCommandBuilder, 'addSubcommand' | 'addSubcommandGroup'>;
|
||||
data: Omit<SlashCommandBuilder, 'addSubcommand' | 'addSubcommandGroup'> | SlashCommandSubcommandsOnlyBuilder;
|
||||
isSystemCommand: boolean;
|
||||
isNew: boolean;
|
||||
isBeta: boolean;
|
||||
@@ -52,7 +53,7 @@ export abstract class BaseSlashCommandInteraction extends BaseInteraction {
|
||||
name: string;
|
||||
|
||||
constructor(
|
||||
data: Omit<SlashCommandBuilder, 'addSubcommand' | 'addSubcommandGroup'>,
|
||||
data: Omit<SlashCommandBuilder, 'addSubcommand' | 'addSubcommandGroup'> | SlashCommandSubcommandsOnlyBuilder,
|
||||
isSystemCommand: boolean = false,
|
||||
isNew: boolean = false,
|
||||
isBeta: boolean = false
|
||||
|
||||
@@ -7,15 +7,17 @@ import {
|
||||
APIStringSelectComponent,
|
||||
ButtonBuilder,
|
||||
ButtonStyle,
|
||||
ChatInputCommandInteraction,
|
||||
ComponentType,
|
||||
EmbedBuilder,
|
||||
SlashCommandBuilder,
|
||||
StringSelectMenuBuilder,
|
||||
StringSelectMenuOptionBuilder
|
||||
} from 'discord.js';
|
||||
import { Logger } from 'pino';
|
||||
import { BaseSlashCommandInteraction } from '../../../classes/interactions';
|
||||
import { FFmpegFilterOption, FFmpegFilterOptions } from '../../../types/configTypes';
|
||||
import { BaseSlashCommandParams, BaseSlashCommandReturnType } from '../../../types/interactionTypes';
|
||||
import { BaseSlashCommandInteraction } from '../../../classes/interactions';
|
||||
import { queueDoesNotExist, queueNoCurrentTrack } from '../../../utils/validation/queueValidator';
|
||||
import { notInSameVoiceChannel, notInVoiceChannel } from '../../../utils/validation/voiceChannelValidator';
|
||||
|
||||
@@ -23,7 +25,22 @@ const ffmpegFilterOptions: FFmpegFilterOptions = config.get('ffmpegFilterOptions
|
||||
|
||||
class FiltersCommand extends BaseSlashCommandInteraction {
|
||||
constructor() {
|
||||
const data = new SlashCommandBuilder().setName('filters').setDescription('Toggle various audio filters.');
|
||||
const data = new SlashCommandBuilder()
|
||||
.setName('filters')
|
||||
.setDescription('Toggle various audio filters.')
|
||||
.addStringOption((option) =>
|
||||
option
|
||||
.setName('type')
|
||||
.setDescription('Audio filtering type to use.')
|
||||
.setRequired(false)
|
||||
.addChoices(
|
||||
{ name: 'FFmpeg', value: 'ffmpeg' },
|
||||
{ name: 'Biquad', value: 'biquad' },
|
||||
{ name: 'Equalizer', value: 'equalizer' },
|
||||
{ name: 'Disable', value: 'disable' }
|
||||
)
|
||||
);
|
||||
|
||||
super(data);
|
||||
}
|
||||
|
||||
@@ -46,6 +63,33 @@ class FiltersCommand extends BaseSlashCommandInteraction {
|
||||
}
|
||||
}
|
||||
|
||||
const filterProvider: string = interaction.options.getString('type') || 'ffmpeg';
|
||||
|
||||
switch (filterProvider) {
|
||||
case 'ffmpeg':
|
||||
logger.info('Handling ffmpeg filters.');
|
||||
return await this.handleFfmpegFilters(queue, logger, interaction);
|
||||
case 'biquad':
|
||||
logger.info('Biquad filters are not yet implemented.');
|
||||
break;
|
||||
case 'equalizer':
|
||||
logger.info('Equalizer filters are not yet implemented.');
|
||||
break;
|
||||
case 'disable':
|
||||
logger.info('Disabling filters.');
|
||||
if (queue.filters.ffmpeg.filters.length > 0) {
|
||||
queue.filters.ffmpeg.setFilters(false);
|
||||
logger.debug('Reset queue filters.');
|
||||
}
|
||||
logger.info('Response not yet implemented.');
|
||||
}
|
||||
}
|
||||
|
||||
private async handleFfmpegFilters(
|
||||
queue: GuildQueue<unknown>,
|
||||
logger: Logger,
|
||||
interaction: ChatInputCommandInteraction
|
||||
) {
|
||||
const filterOptions: StringSelectMenuOptionBuilder[] = [];
|
||||
|
||||
ffmpegFilterOptions.availableFilters.forEach((filter: FFmpegFilterOption) => {
|
||||
|
||||
Reference in new issue
Block a user