diff --git a/src/commands/player/filters.ts b/src/commands/player/filters.ts index ea981cf..4651dd0 100644 --- a/src/commands/player/filters.ts +++ b/src/commands/player/filters.ts @@ -14,6 +14,7 @@ import { } from 'discord.js'; import { useQueue } from 'discord-player'; import loggerModule from '../../services/logger'; +import { CommandParams } from '../../types/commandTypes'; module.exports = { isNew: false, @@ -23,7 +24,7 @@ module.exports = { .setDescription('Toggle various audio filters during playback.') .setDMPermission(false) .setNSFW(false), - execute: async ({ interaction, executionId }) => { + execute: async ({ interaction, executionId }: CommandParams) => { const logger = loggerModule.child({ source: 'filters.js', module: 'slashCommand', diff --git a/src/commands/player/leave.ts b/src/commands/player/leave.ts index cf88094..22d0159 100644 --- a/src/commands/player/leave.ts +++ b/src/commands/player/leave.ts @@ -5,6 +5,7 @@ import { notInVoiceChannel, notInSameVoiceChannel } from '../../utils/validation import{ SlashCommandBuilder, EmbedBuilder } from 'discord.js'; import { useQueue } from 'discord-player'; import loggerModule from '../../services/logger'; +import { CommandParams } from '../../types/commandTypes'; module.exports = { isNew: false, @@ -14,7 +15,7 @@ module.exports = { .setDescription('Clear the track queue and remove the bot from voice channel.') .setDMPermission(false) .setNSFW(false), - execute: async ({ interaction, executionId }) => { + execute: async ({ interaction, executionId }: CommandParams) => { const logger = loggerModule.child({ source: 'leave.js', module: 'slashCommand', diff --git a/src/commands/player/loop.ts b/src/commands/player/loop.ts index 181eec5..a4f4461 100644 --- a/src/commands/player/loop.ts +++ b/src/commands/player/loop.ts @@ -7,6 +7,7 @@ import { queueDoesNotExist } from '../../utils/validation/queueValidator'; import{ SlashCommandBuilder, EmbedBuilder } from 'discord.js'; import { useQueue } from 'discord-player'; import loggerModule from '../../services/logger'; +import { CommandParams } from '../../types/commandTypes'; module.exports = { isNew: false, @@ -28,7 +29,7 @@ module.exports = { { name: 'Disabled', value: '0' } ) ), - execute: async ({ interaction, executionId }) => { + execute: async ({ interaction, executionId }: CommandParams) => { const logger = loggerModule.child({ source: 'loop.js', module: 'slashCommand', diff --git a/src/commands/player/lyrics.ts b/src/commands/player/lyrics.ts index 0f2130a..28e4db3 100644 --- a/src/commands/player/lyrics.ts +++ b/src/commands/player/lyrics.ts @@ -7,6 +7,7 @@ import { SlashCommandBuilder, EmbedBuilder } from 'discord.js'; import { useMainPlayer, useQueue, QueryType } from 'discord-player'; import { lyricsExtractor } from '@discord-player/extractor'; import loggerModule from '../../services/logger'; +import { CommandAutocompleteParams, CommandParams } from '../../types/commandTypes'; const recentQueries = new Map(); @@ -33,7 +34,7 @@ module.exports = { .setMaxLength(500) .setAutocomplete(true) ), - autocomplete: async ({ interaction, executionId }) => { + autocomplete: async ({ interaction, executionId }: CommandAutocompleteParams) => { const logger = loggerTemplate.child({ executionId: executionId, shardId: interaction.guild.shardId, @@ -93,7 +94,7 @@ module.exports = { logger.debug(`Responding to autocomplete with results for query: '${query}'.`); return interaction.respond(response); }, - execute: async ({ interaction, executionId }) => { + execute: async ({ interaction, executionId }: CommandParams) => { const logger = loggerTemplate.child({ executionId: executionId, shardId: interaction.guild.shardId, diff --git a/src/commands/player/nowplaying.ts b/src/commands/player/nowplaying.ts index 9a2923d..dee9a61 100644 --- a/src/commands/player/nowplaying.ts +++ b/src/commands/player/nowplaying.ts @@ -7,6 +7,7 @@ import { queueDoesNotExist, queueNoCurrentTrack } from '../../utils/validation/q import { SlashCommandBuilder, EmbedBuilder, ActionRowBuilder, ButtonBuilder } from 'discord.js'; import { useQueue } from 'discord-player'; import loggerModule from '../../services/logger'; +import { CommandParams } from '../../types/commandTypes'; module.exports = { isNew: false, @@ -16,7 +17,7 @@ module.exports = { .setDescription('Show information about the track currently playing.') .setDMPermission(false) .setNSFW(false), - execute: async ({ interaction, executionId }) => { + execute: async ({ interaction, executionId }: CommandParams) => { const logger = loggerModule.child({ source: 'nowplaying.js', module: 'slashCommand', diff --git a/src/commands/player/pause.ts b/src/commands/player/pause.ts index bd704d1..6bfe904 100644 --- a/src/commands/player/pause.ts +++ b/src/commands/player/pause.ts @@ -6,6 +6,7 @@ import { queueDoesNotExist, queueNoCurrentTrack } from '../../utils/validation/q import{ SlashCommandBuilder, EmbedBuilder } from 'discord.js'; import { useQueue } from 'discord-player'; import loggerModule from '../../services/logger'; +import { CommandParams } from '../../types/commandTypes'; module.exports = { isNew: false, @@ -15,7 +16,7 @@ module.exports = { .setDescription('Pause or resume the current track.') .setDMPermission(false) .setNSFW(false), - execute: async ({ interaction, executionId }) => { + execute: async ({ interaction, executionId }: CommandParams) => { const logger = loggerModule.child({ source: 'pause.js', module: 'slashCommand', diff --git a/src/commands/player/play.ts b/src/commands/player/play.ts index 74180af..c1f5187 100644 --- a/src/commands/player/play.ts +++ b/src/commands/player/play.ts @@ -9,6 +9,7 @@ import { SlashCommandBuilder, EmbedBuilder } from 'discord.js'; import { useMainPlayer, useQueue } from 'discord-player'; import loggerModule from '../../services/logger'; import { EmbedOptions } from '../../types/configTypes'; +import { CommandAutocompleteParams, CommandParams } from '../../types/commandTypes'; const recentQueries = new Map(); @@ -35,7 +36,7 @@ module.exports = { .setMaxLength(500) .setAutocomplete(true) ), - autocomplete: async ({ interaction, executionId }) => { + autocomplete: async ({ interaction, executionId }: CommandAutocompleteParams) => { const logger = loggerTemplate.child({ executionId: executionId, shardId: interaction.guild.shardId, @@ -87,7 +88,7 @@ module.exports = { logger.debug(`Responding to autocomplete with results for query: '${query}'.`); return interaction.respond(response); }, - execute: async ({ interaction, executionId }) => { + execute: async ({ interaction, executionId }: CommandParams) => { const logger = loggerTemplate.child({ executionId: executionId, shardId: interaction.guild.shardId, diff --git a/src/commands/player/queue.ts b/src/commands/player/queue.ts index dd570a9..6f92bcb 100644 --- a/src/commands/player/queue.ts +++ b/src/commands/player/queue.ts @@ -6,6 +6,7 @@ import { notInVoiceChannel, notInSameVoiceChannel } from '../../utils/validation import{ SlashCommandBuilder, EmbedBuilder } from 'discord.js'; import { useQueue } from 'discord-player'; import loggerModule from '../../services/logger'; +import { CommandParams } from '../../types/commandTypes'; module.exports = { isNew: false, @@ -16,7 +17,7 @@ module.exports = { .setDMPermission(false) .setNSFW(false) .addNumberOption((option) => option.setName('page').setDescription('Page number of the queue').setMinValue(1)), - execute: async ({ interaction, executionId }) => { + execute: async ({ interaction, executionId }: CommandParams) => { const logger = loggerModule.child({ source: 'queue.js', module: 'slashCommand', diff --git a/src/commands/player/remove.ts b/src/commands/player/remove.ts index 05e9116..6d023cf 100644 --- a/src/commands/player/remove.ts +++ b/src/commands/player/remove.ts @@ -6,6 +6,7 @@ import { queueDoesNotExist } from '../../utils/validation/queueValidator'; import{ SlashCommandBuilder, EmbedBuilder } from 'discord.js'; import { useQueue } from 'discord-player'; import loggerModule from '../../services/logger'; +import { CommandParams } from '../../types/commandTypes'; module.exports = { isNew: false, @@ -22,7 +23,7 @@ module.exports = { .setMinValue(1) .setRequired(true) ), - execute: async ({ interaction, executionId }) => { + execute: async ({ interaction, executionId }: CommandParams) => { const logger = loggerModule.child({ source: 'remove.js', module: 'slashCommand', diff --git a/src/commands/player/seek.ts b/src/commands/player/seek.ts index ba06c88..3f059f6 100644 --- a/src/commands/player/seek.ts +++ b/src/commands/player/seek.ts @@ -6,6 +6,7 @@ import { queueDoesNotExist, queueNoCurrentTrack } from '../../utils/validation/q import{ SlashCommandBuilder, EmbedBuilder } from 'discord.js'; import { useQueue } from 'discord-player'; import loggerModule from '../../services/logger'; +import { CommandParams } from '../../types/commandTypes'; module.exports = { isNew: false, @@ -21,7 +22,7 @@ module.exports = { .setDescription('Duration in format 00:00:00 (HH:mm:ss) to seek to.') .setRequired(true) ), - execute: async ({ interaction, executionId }) => { + execute: async ({ interaction, executionId }: CommandParams) => { const logger = loggerModule.child({ source: 'seek.js', module: 'slashCommand', diff --git a/src/commands/player/shuffle.ts b/src/commands/player/shuffle.ts index 3ab5f23..07a906e 100644 --- a/src/commands/player/shuffle.ts +++ b/src/commands/player/shuffle.ts @@ -6,6 +6,7 @@ import { queueDoesNotExist, queueIsEmpty } from '../../utils/validation/queueVal import{ SlashCommandBuilder, EmbedBuilder } from 'discord.js'; import { useQueue } from 'discord-player'; import loggerModule from '../../services/logger'; +import { CommandParams } from '../../types/commandTypes'; module.exports = { isNew: false, @@ -15,7 +16,7 @@ module.exports = { .setDescription('Shuffle tracks in the queue randomly.') .setDMPermission(false) .setNSFW(false), - execute: async ({ interaction, executionId }) => { + execute: async ({ interaction, executionId }: CommandParams) => { const logger = loggerModule.child({ source: 'shuffle.js', module: 'slashCommand', diff --git a/src/commands/player/skip.ts b/src/commands/player/skip.ts index 8cc8e71..e2a4ba8 100644 --- a/src/commands/player/skip.ts +++ b/src/commands/player/skip.ts @@ -6,6 +6,7 @@ import { queueDoesNotExist, queueNoCurrentTrack } from '../../utils/validation/q import { SlashCommandBuilder, EmbedBuilder } from 'discord.js'; import { useQueue } from 'discord-player'; import loggerModule from '../../services/logger'; +import { CommandParams } from '../../types/commandTypes'; module.exports = { isNew: false, @@ -18,7 +19,7 @@ module.exports = { .addNumberOption((option) => option.setName('tracknumber').setDescription('Track number to skip to in the queue.').setMinValue(1) ), - execute: async ({ interaction, executionId }) => { + execute: async ({ interaction, executionId }: CommandParams) => { const logger = loggerModule.child({ source: 'skip.js', module: 'slashCommand', diff --git a/src/commands/player/stop.ts b/src/commands/player/stop.ts index 3efed8f..29328dc 100644 --- a/src/commands/player/stop.ts +++ b/src/commands/player/stop.ts @@ -5,6 +5,7 @@ import { notInVoiceChannel, notInSameVoiceChannel } from '../../utils/validation import{ SlashCommandBuilder, EmbedBuilder } from 'discord.js'; import { useQueue } from 'discord-player'; import loggerModule from '../../services/logger'; +import { CommandParams } from '../../types/commandTypes'; module.exports = { isNew: false, @@ -14,7 +15,7 @@ module.exports = { .setDescription('Stop playing audio and clear the track queue.') .setDMPermission(false) .setNSFW(false), - execute: async ({ interaction, executionId }) => { + execute: async ({ interaction, executionId }: CommandParams) => { const logger = loggerModule.child({ source: 'stop.js', module: 'slashCommand', diff --git a/src/commands/player/volume.ts b/src/commands/player/volume.ts index 2701c13..3834fa9 100644 --- a/src/commands/player/volume.ts +++ b/src/commands/player/volume.ts @@ -6,6 +6,7 @@ import { queueDoesNotExist } from '../../utils/validation/queueValidator'; import{ SlashCommandBuilder, EmbedBuilder } from 'discord.js'; import { useQueue } from 'discord-player'; import loggerModule from '../../services/logger'; +import { CommandParams } from '../../types/commandTypes'; module.exports = { isNew: false, @@ -22,7 +23,7 @@ module.exports = { .setMinValue(0) .setMaxValue(100) ), - execute: async ({ interaction, executionId }) => { + execute: async ({ interaction, executionId }: CommandParams) => { const logger = loggerModule.child({ source: 'volume.js', module: 'slashCommand', diff --git a/src/commands/system/guilds.ts b/src/commands/system/guilds.ts index 09b36aa..a468f5b 100644 --- a/src/commands/system/guilds.ts +++ b/src/commands/system/guilds.ts @@ -4,6 +4,7 @@ const embedOptions: EmbedOptions = config.get('embedOptions'); import { notValidGuildId } from '../../utils/validation/systemCommandValidator'; import{ SlashCommandBuilder, EmbedBuilder } from 'discord.js'; import loggerModule from '../../services/logger'; +import { CommandParams } from '../../types/commandTypes'; module.exports = { isSystemCommand: true, @@ -14,7 +15,7 @@ module.exports = { .setDescription('Show list of guilds where bot is added.') .setDMPermission(false) .setNSFW(false), - execute: async ({ interaction, client, executionId }) => { + execute: async ({ interaction, client, executionId }: CommandParams) => { const logger = loggerModule.child({ source: 'guilds.js', module: 'slashCommand', diff --git a/src/commands/system/reload.ts b/src/commands/system/reload.ts index 3ece3e7..0de7fa3 100644 --- a/src/commands/system/reload.ts +++ b/src/commands/system/reload.ts @@ -4,6 +4,7 @@ const embedOptions: EmbedOptions = config.get('embedOptions'); import { notValidGuildId } from '../../utils/validation/systemCommandValidator'; import{ SlashCommandBuilder, EmbedBuilder } from 'discord.js'; import loggerModule from '../../services/logger'; +import { CommandParams } from '../../types/commandTypes'; module.exports = { isSystemCommand: true, @@ -14,7 +15,7 @@ module.exports = { .setDescription('Reload the bot commands.') .setDMPermission(false) .setNSFW(false), - execute: async ({ interaction, client, executionId }) => { + execute: async ({ interaction, client, executionId }: CommandParams) => { const logger = loggerModule.child({ source: 'reload.js', module: 'slashCommand', diff --git a/src/commands/system/shards.ts b/src/commands/system/shards.ts index 67d3822..458d32d 100644 --- a/src/commands/system/shards.ts +++ b/src/commands/system/shards.ts @@ -4,6 +4,7 @@ const embedOptions: EmbedOptions = config.get('embedOptions'); import { notValidGuildId } from '../../utils/validation/systemCommandValidator'; import{ SlashCommandBuilder, EmbedBuilder } from 'discord.js'; import loggerModule from '../../services/logger'; +import { CommandParams } from '../../types/commandTypes'; module.exports = { isSystemCommand: true, @@ -31,7 +32,7 @@ module.exports = { ) .addNumberOption((option) => option.setName('page').setDescription('Page number to show').setMinValue(1)), - execute: async ({ interaction, client, executionId }) => { + execute: async ({ interaction, client, executionId }: CommandParams) => { const logger = loggerModule.child({ source: 'shards.js', module: 'slashCommand', diff --git a/src/commands/system/systemstatus.ts b/src/commands/system/systemstatus.ts index 81b7af5..ee60f42 100644 --- a/src/commands/system/systemstatus.ts +++ b/src/commands/system/systemstatus.ts @@ -8,6 +8,7 @@ import { version, dependencies } from '../../../package.json'; import loggerModule from '../../services/logger'; import { EmbedOptions } from '../../types/configTypes'; +import { CommandParams } from '../../types/commandTypes'; const embedOptions: EmbedOptions = config.get('embedOptions'); module.exports = { @@ -19,7 +20,7 @@ module.exports = { .setDescription('Show the bot and system status.') .setDMPermission(false) .setNSFW(false), - execute: async ({ interaction, client, executionId }) => { + execute: async ({ interaction, client, executionId }: CommandParams) => { const logger = loggerModule.child({ source: 'systemstatus.js', module: 'slashCommand', diff --git a/src/types/commandTypes.ts b/src/types/commandTypes.ts new file mode 100644 index 0000000..e17181d --- /dev/null +++ b/src/types/commandTypes.ts @@ -0,0 +1,14 @@ +import { ChatInputCommandInteraction, AutocompleteInteraction } from 'discord.js'; +import { ExtendedClient } from './clientTypes'; + +export interface CommandParams { + interaction: ChatInputCommandInteraction; + client: ExtendedClient | undefined; + executionId: string; +} + +export interface CommandAutocompleteParams { + interaction: AutocompleteInteraction; + client: ExtendedClient | undefined; + executionId: string; +}