fix: add annotations to command parameters

This commit is contained in:
Marius Begby committed 2023-08-27 02:52:41 +02:00
1 parent b118ebdfb0
commit 179f7ddbfd
19 files changed
+52 -20

No files matched your search

+2 -1
View File
@@ -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',
+2 -1
View File
@@ -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',
+2 -1
View File
@@ -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',
+3 -2
View File
@@ -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,
+2 -1
View File
@@ -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',
+2 -1
View File
@@ -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',
+3 -2
View File
@@ -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,
+2 -1
View File
@@ -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',
+2 -1
View File
@@ -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',
+2 -1
View File
@@ -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',
+2 -1
View File
@@ -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',
+2 -1
View File
@@ -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',
+2 -1
View File
@@ -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',
+2 -1
View File
@@ -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',
+2 -1
View File
@@ -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',
+2 -1
View File
@@ -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',
+2 -1
View File
@@ -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',
+2 -1
View File
@@ -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',
+14
View File
@@ -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;
}