mirror of
https://github.com/darksaid98/cadence-discord-bot.git
synced 2026-12-03 22:15:37 +00:00
feat!: Extract logic for autocomplete and component interactions
This commit is contained in:
1 parent
f16a18deb5
commit
1ec1281e98
29 files changed
+694
-442
No files matched your search
@@ -2,12 +2,13 @@ import config from 'config';
|
||||
import { EmbedBuilder, SlashCommandBuilder } from 'discord.js';
|
||||
|
||||
import loggerModule from '../../../services/logger';
|
||||
import { CommandParams } from '../../../types/commandTypes';
|
||||
import { CustomSlashCommandInteraction } from '../../../types/interactionTypes';
|
||||
import { BotOptions, EmbedOptions } from '../../../types/configTypes';
|
||||
|
||||
const embedOptions: EmbedOptions = config.get('embedOptions');
|
||||
const botOptions: BotOptions = config.get('botOptions');
|
||||
module.exports = {
|
||||
|
||||
const command: CustomSlashCommandInteraction = {
|
||||
isNew: false,
|
||||
isBeta: false,
|
||||
data: new SlashCommandBuilder()
|
||||
@@ -15,7 +16,7 @@ module.exports = {
|
||||
.setDescription('Show a list of commands and their usage.')
|
||||
.setDMPermission(false)
|
||||
.setNSFW(false),
|
||||
execute: async ({ interaction, client, executionId }: CommandParams) => {
|
||||
execute: async ({ interaction, client, executionId }) => {
|
||||
const logger = loggerModule.child({
|
||||
source: 'help.js',
|
||||
module: 'slashCommand',
|
||||
@@ -69,3 +70,5 @@ module.exports = {
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
export default command;
|
||||
@@ -5,12 +5,13 @@ import osu from 'node-os-utils';
|
||||
// @ts-ignore
|
||||
import { version } from '../../../../package.json';
|
||||
import loggerModule from '../../../services/logger';
|
||||
import { CommandParams } from '../../../types/commandTypes';
|
||||
import { EmbedOptions } from '../../../types/configTypes';
|
||||
import { getUptimeFormatted } from '../../../utils/system/getUptimeFormatted';
|
||||
import { CustomSlashCommandInteraction } from '../../../types/interactionTypes';
|
||||
|
||||
const embedOptions: EmbedOptions = config.get('embedOptions');
|
||||
module.exports = {
|
||||
|
||||
const command: CustomSlashCommandInteraction = {
|
||||
isNew: false,
|
||||
isBeta: false,
|
||||
data: new SlashCommandBuilder()
|
||||
@@ -18,7 +19,7 @@ module.exports = {
|
||||
.setDescription('Show the bot and system status.')
|
||||
.setDMPermission(false)
|
||||
.setNSFW(false),
|
||||
execute: async ({ interaction, client, executionId }: CommandParams) => {
|
||||
execute: async ({ interaction, client, executionId }) => {
|
||||
const logger = loggerModule.child({
|
||||
source: 'status.js',
|
||||
module: 'slashCommand',
|
||||
@@ -133,3 +134,5 @@ module.exports = {
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
export default command;
|
||||
@@ -15,14 +15,15 @@ import {
|
||||
} from 'discord.js';
|
||||
|
||||
import loggerModule from '../../../services/logger';
|
||||
import { CommandParams, CustomError } from '../../../types/commandTypes';
|
||||
import { CustomError, CustomSlashCommandInteraction } from '../../../types/interactionTypes';
|
||||
import { EmbedOptions, FFmpegFilterOption, FFmpegFilterOptions } from '../../../types/configTypes';
|
||||
import { queueDoesNotExist, queueNoCurrentTrack } from '../../../utils/validation/queueValidator';
|
||||
import { notInSameVoiceChannel, notInVoiceChannel } from '../../../utils/validation/voiceChannelValidator';
|
||||
|
||||
const embedOptions: EmbedOptions = config.get('embedOptions');
|
||||
const ffmpegFilterOptions: FFmpegFilterOptions = config.get('ffmpegFilterOptions');
|
||||
module.exports = {
|
||||
|
||||
const command: CustomSlashCommandInteraction = {
|
||||
isNew: false,
|
||||
isBeta: false,
|
||||
data: new SlashCommandBuilder()
|
||||
@@ -30,7 +31,7 @@ module.exports = {
|
||||
.setDescription('Toggle various audio filters during playback.')
|
||||
.setDMPermission(false)
|
||||
.setNSFW(false),
|
||||
execute: async ({ interaction, executionId }: CommandParams) => {
|
||||
execute: async ({ interaction, executionId }) => {
|
||||
const logger = loggerModule.child({
|
||||
source: 'filters.js',
|
||||
module: 'slashCommand',
|
||||
@@ -237,3 +238,5 @@ module.exports = {
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
export default command;
|
||||
@@ -3,12 +3,13 @@ import { NodeResolvable, useQueue } from 'discord-player';
|
||||
import { EmbedBuilder, GuildMember, SlashCommandBuilder } from 'discord.js';
|
||||
|
||||
import loggerModule from '../../../services/logger';
|
||||
import { CommandParams } from '../../../types/commandTypes';
|
||||
import { CustomSlashCommandInteraction } from '../../../types/interactionTypes';
|
||||
import { EmbedOptions } from '../../../types/configTypes';
|
||||
import { notInSameVoiceChannel, notInVoiceChannel } from '../../../utils/validation/voiceChannelValidator';
|
||||
|
||||
const embedOptions: EmbedOptions = config.get('embedOptions');
|
||||
module.exports = {
|
||||
|
||||
const command: CustomSlashCommandInteraction = {
|
||||
isNew: false,
|
||||
isBeta: false,
|
||||
data: new SlashCommandBuilder()
|
||||
@@ -16,7 +17,7 @@ module.exports = {
|
||||
.setDescription('Clear the track queue and remove the bot from voice channel.')
|
||||
.setDMPermission(false)
|
||||
.setNSFW(false),
|
||||
execute: async ({ interaction, executionId }: CommandParams) => {
|
||||
execute: async ({ interaction, executionId }) => {
|
||||
const logger = loggerModule.child({
|
||||
source: 'leave.js',
|
||||
module: 'slashCommand',
|
||||
@@ -80,3 +81,5 @@ module.exports = {
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
export default command;
|
||||
@@ -1,16 +1,17 @@
|
||||
import config from 'config';
|
||||
import { NodeResolvable, useQueue } from 'discord-player';
|
||||
import { EmbedBuilder, GuildMember, SlashCommandBuilder } from 'discord.js';
|
||||
import { EmbedBuilder, GuildMember, SlashCommandBuilder, SlashCommandStringOption } from 'discord.js';
|
||||
|
||||
import loggerModule from '../../../services/logger';
|
||||
import { CommandParams } from '../../../types/commandTypes';
|
||||
import { CustomSlashCommandInteraction } from '../../../types/interactionTypes';
|
||||
import { BotOptions, EmbedOptions } from '../../../types/configTypes';
|
||||
import { queueDoesNotExist } from '../../../utils/validation/queueValidator';
|
||||
import { notInSameVoiceChannel, notInVoiceChannel } from '../../../utils/validation/voiceChannelValidator';
|
||||
|
||||
const embedOptions: EmbedOptions = config.get('embedOptions');
|
||||
const botOptions: BotOptions = config.get('botOptions');
|
||||
module.exports = {
|
||||
|
||||
const command: CustomSlashCommandInteraction = {
|
||||
isNew: false,
|
||||
isBeta: false,
|
||||
data: new SlashCommandBuilder()
|
||||
@@ -18,8 +19,8 @@ module.exports = {
|
||||
.setDescription('Toggle looping a track, the whole queue or autoplay.')
|
||||
.setDMPermission(false)
|
||||
.setNSFW(false)
|
||||
.addStringOption((option) =>
|
||||
option
|
||||
.addStringOption(() =>
|
||||
new SlashCommandStringOption()
|
||||
.setName('mode')
|
||||
.setDescription('Mode to set for looping.')
|
||||
.setRequired(false)
|
||||
@@ -30,7 +31,7 @@ module.exports = {
|
||||
{ name: 'Disabled', value: '0' }
|
||||
)
|
||||
),
|
||||
execute: async ({ interaction, executionId }: CommandParams) => {
|
||||
execute: async ({ interaction, executionId }) => {
|
||||
const logger = loggerModule.child({
|
||||
source: 'loop.js',
|
||||
module: 'slashCommand',
|
||||
@@ -184,3 +185,5 @@ module.exports = {
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
export default command;
|
||||
@@ -5,13 +5,12 @@ import { EmbedBuilder, SlashCommandBuilder } from 'discord.js';
|
||||
import { lyricsExtractor } from '@discord-player/extractor';
|
||||
|
||||
import loggerModule from '../../../services/logger';
|
||||
import { CommandAutocompleteParams, CommandParams } from '../../../types/commandTypes';
|
||||
import { CustomSlashCommandInteraction } from '../../../types/interactionTypes';
|
||||
import { EmbedOptions } from '../../../types/configTypes';
|
||||
import { queueDoesNotExist, queueNoCurrentTrack } from '../../../utils/validation/queueValidator';
|
||||
import { notInSameVoiceChannel, notInVoiceChannel } from '../../../utils/validation/voiceChannelValidator';
|
||||
|
||||
const embedOptions: EmbedOptions = config.get('embedOptions');
|
||||
const recentQueries = new Map();
|
||||
|
||||
const loggerTemplate = loggerModule.child({
|
||||
source: 'lyrics.js',
|
||||
@@ -19,7 +18,7 @@ const loggerTemplate = loggerModule.child({
|
||||
name: '/lyrics'
|
||||
});
|
||||
|
||||
module.exports = {
|
||||
const command: CustomSlashCommandInteraction = {
|
||||
isNew: false,
|
||||
isBeta: false,
|
||||
data: new SlashCommandBuilder()
|
||||
@@ -36,67 +35,7 @@ module.exports = {
|
||||
.setMaxLength(500)
|
||||
.setAutocomplete(true)
|
||||
),
|
||||
autocomplete: async ({ interaction, executionId }: CommandAutocompleteParams) => {
|
||||
const logger = loggerTemplate.child({
|
||||
executionId: executionId,
|
||||
shardId: interaction.guild?.shardId,
|
||||
guildId: interaction.guild?.id
|
||||
});
|
||||
|
||||
const query = interaction.options.getString('query', true);
|
||||
|
||||
const { lastQuery, result, timestamp } = recentQueries.get(interaction.user.id) || {};
|
||||
|
||||
if (lastQuery && (query.startsWith(lastQuery) || lastQuery.startsWith(query)) && Date.now() - timestamp < 500) {
|
||||
logger.debug(`Responding with results from lastQuery for query '${query}'`);
|
||||
return interaction.respond(result);
|
||||
}
|
||||
|
||||
if (query.length < 3) {
|
||||
logger.debug(`Responding with empty results due to < 3 length for query '${query}'`);
|
||||
return interaction.respond([]);
|
||||
}
|
||||
|
||||
const genius = lyricsExtractor();
|
||||
const lyricsResult = await genius.search(query).catch(() => null);
|
||||
let response = [];
|
||||
|
||||
if (!lyricsResult) {
|
||||
logger.debug(`No Genius lyrics found for query '${query}', using player.search() as fallback.`);
|
||||
const player = useMainPlayer()!;
|
||||
const searchResults = await player.search(query);
|
||||
response = searchResults.tracks.slice(0, 1).map((track) => ({
|
||||
name:
|
||||
`${track.title} [Artist: ${track.author}]`.length > 100
|
||||
? `${track.title}`.slice(0, 100)
|
||||
: `${track.title} [Artist: ${track.author}]`,
|
||||
value: track.title.slice(0, 100)
|
||||
}));
|
||||
} else {
|
||||
logger.debug(`Found Genius lyrics for query '${query}'.`);
|
||||
response = [
|
||||
{
|
||||
name: `${lyricsResult.title} [Artist: ${lyricsResult.artist.name}]`.slice(0, 100),
|
||||
value: lyricsResult.title.slice(0, 100)
|
||||
}
|
||||
];
|
||||
}
|
||||
|
||||
if (!response || response.length === 0) {
|
||||
logger.debug(`Responding with empty results for query '${query}'`);
|
||||
return interaction.respond([]);
|
||||
}
|
||||
|
||||
recentQueries.set(interaction.user.id, {
|
||||
lastQuery: query,
|
||||
result: response,
|
||||
timestamp: Date.now()
|
||||
});
|
||||
|
||||
logger.debug(`Responding to autocomplete with results for query: '${query}'.`);
|
||||
return interaction.respond(response);
|
||||
},
|
||||
execute: async ({ interaction, executionId }: CommandParams) => {
|
||||
execute: async ({ interaction, executionId }) => {
|
||||
const logger = loggerTemplate.child({
|
||||
executionId: executionId,
|
||||
shardId: interaction.guild?.shardId,
|
||||
@@ -267,3 +206,5 @@ module.exports = {
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
export default command;
|
||||
@@ -11,7 +11,7 @@ import {
|
||||
} from 'discord.js';
|
||||
|
||||
import loggerModule from '../../../services/logger';
|
||||
import { CommandParams, TrackMetadata } from '../../../types/commandTypes';
|
||||
import { CustomSlashCommandInteraction, TrackMetadata } from '../../../types/interactionTypes';
|
||||
import { EmbedOptions, PlayerOptions } from '../../../types/configTypes';
|
||||
import { queueDoesNotExist, queueNoCurrentTrack } from '../../../utils/validation/queueValidator';
|
||||
import { notInSameVoiceChannel, notInVoiceChannel } from '../../../utils/validation/voiceChannelValidator';
|
||||
@@ -19,7 +19,7 @@ import { notInSameVoiceChannel, notInVoiceChannel } from '../../../utils/validat
|
||||
const embedOptions: EmbedOptions = config.get('embedOptions');
|
||||
const playerOptions: PlayerOptions = config.get('playerOptions');
|
||||
|
||||
module.exports = {
|
||||
const command: CustomSlashCommandInteraction = {
|
||||
isNew: false,
|
||||
isBeta: false,
|
||||
data: new SlashCommandBuilder()
|
||||
@@ -27,7 +27,7 @@ module.exports = {
|
||||
.setDescription('Show information about the track currently playing.')
|
||||
.setDMPermission(false)
|
||||
.setNSFW(false),
|
||||
execute: async ({ interaction, executionId }: CommandParams) => {
|
||||
execute: async ({ interaction, executionId }) => {
|
||||
const logger = loggerModule.child({
|
||||
source: 'nowplaying.js',
|
||||
module: 'slashCommand',
|
||||
@@ -136,7 +136,7 @@ module.exports = {
|
||||
logger.debug('Successfully retrieved information about the current track.');
|
||||
|
||||
logger.debug('Sending info embed with action row components.');
|
||||
await interaction.editReply({
|
||||
return await interaction.editReply({
|
||||
embeds: [
|
||||
new EmbedBuilder()
|
||||
.setAuthor({
|
||||
@@ -185,7 +185,7 @@ module.exports = {
|
||||
],
|
||||
components: [nowPlayingActionRow as APIActionRowComponent<APIMessageActionRowComponent>]
|
||||
});
|
||||
|
||||
logger.debug('Finished sending response.');
|
||||
}
|
||||
};
|
||||
|
||||
export default command;
|
||||
@@ -3,13 +3,14 @@ import { NodeResolvable, useQueue } from 'discord-player';
|
||||
import { EmbedBuilder, GuildMember, SlashCommandBuilder } from 'discord.js';
|
||||
|
||||
import loggerModule from '../../../services/logger';
|
||||
import { CommandParams } from '../../../types/commandTypes';
|
||||
import { CustomSlashCommandInteraction } from '../../../types/interactionTypes';
|
||||
import { EmbedOptions } from '../../../types/configTypes';
|
||||
import { queueDoesNotExist, queueNoCurrentTrack } from '../../../utils/validation/queueValidator';
|
||||
import { notInSameVoiceChannel, notInVoiceChannel } from '../../../utils/validation/voiceChannelValidator';
|
||||
|
||||
const embedOptions: EmbedOptions = config.get('embedOptions');
|
||||
module.exports = {
|
||||
|
||||
const command: CustomSlashCommandInteraction = {
|
||||
isNew: false,
|
||||
isBeta: false,
|
||||
data: new SlashCommandBuilder()
|
||||
@@ -17,7 +18,7 @@ module.exports = {
|
||||
.setDescription('Pause or resume the current track.')
|
||||
.setDMPermission(false)
|
||||
.setNSFW(false),
|
||||
execute: async ({ interaction, executionId }: CommandParams) => {
|
||||
execute: async ({ interaction, executionId }) => {
|
||||
const logger = loggerModule.child({
|
||||
source: 'pause.js',
|
||||
module: 'slashCommand',
|
||||
@@ -87,3 +88,5 @@ module.exports = {
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
export default command;
|
||||
@@ -3,7 +3,7 @@ import { useMainPlayer, useQueue } from 'discord-player';
|
||||
import { EmbedBuilder, GuildMember, SlashCommandBuilder } from 'discord.js';
|
||||
|
||||
import loggerModule from '../../../services/logger';
|
||||
import { CommandAutocompleteParams, CommandParams } from '../../../types/commandTypes';
|
||||
import { CustomSlashCommandInteraction } from '../../../types/interactionTypes';
|
||||
import { BotOptions, EmbedOptions, PlayerOptions } from '../../../types/configTypes';
|
||||
import { cannotJoinVoiceOrTalk } from '../../../utils/validation/permissionValidator';
|
||||
import { transformQuery } from '../../../utils/validation/searchQueryValidator';
|
||||
@@ -12,7 +12,6 @@ import { notInSameVoiceChannel, notInVoiceChannel } from '../../../utils/validat
|
||||
const embedOptions: EmbedOptions = config.get('embedOptions');
|
||||
const botOptions: BotOptions = config.get('botOptions');
|
||||
const playerOptions: PlayerOptions = config.get('playerOptions');
|
||||
const recentQueries = new Map();
|
||||
|
||||
const loggerTemplate = loggerModule.child({
|
||||
source: 'play.js',
|
||||
@@ -20,7 +19,7 @@ const loggerTemplate = loggerModule.child({
|
||||
name: '/play'
|
||||
});
|
||||
|
||||
module.exports = {
|
||||
const command: CustomSlashCommandInteraction = {
|
||||
isNew: false,
|
||||
isBeta: false,
|
||||
data: new SlashCommandBuilder()
|
||||
@@ -37,59 +36,7 @@ module.exports = {
|
||||
.setMaxLength(500)
|
||||
.setAutocomplete(true)
|
||||
),
|
||||
autocomplete: async ({ interaction, executionId }: CommandAutocompleteParams) => {
|
||||
const logger = loggerTemplate.child({
|
||||
executionId: executionId,
|
||||
shardId: interaction.guild?.shardId,
|
||||
guildId: interaction.guild?.id
|
||||
});
|
||||
|
||||
const player = useMainPlayer()!;
|
||||
const query = interaction.options.getString('query', true);
|
||||
|
||||
const { lastQuery, results, timestamp } = recentQueries.get(interaction.user.id) || {};
|
||||
|
||||
if (lastQuery && (query.startsWith(lastQuery) || lastQuery.startsWith(query)) && Date.now() - timestamp < 500) {
|
||||
logger.debug(`Responding with results from lastQuery for query '${query}'`);
|
||||
return interaction.respond(results);
|
||||
}
|
||||
|
||||
if (query.length < 3) {
|
||||
logger.debug(`Responding with empty results due to < 3 length for query '${query}'`);
|
||||
return interaction.respond([]);
|
||||
}
|
||||
const searchResults = await player.search(query);
|
||||
|
||||
let response = [];
|
||||
|
||||
response = searchResults.tracks.slice(0, 5).map((track) => {
|
||||
if (track.url.length > 100) {
|
||||
track.url = track.title.slice(0, 100);
|
||||
}
|
||||
return {
|
||||
name:
|
||||
`${track.title} [Author: ${track.author}]`.length > 100
|
||||
? `${track.title}`.slice(0, 100)
|
||||
: `${track.title} [Author: ${track.author}]`,
|
||||
value: track.url
|
||||
};
|
||||
});
|
||||
|
||||
recentQueries.set(interaction.user.id, {
|
||||
lastQuery: query,
|
||||
results: response,
|
||||
timestamp: Date.now()
|
||||
});
|
||||
|
||||
if (!response || response.length === 0) {
|
||||
logger.debug(`Responding with empty results for query '${query}'`);
|
||||
return interaction.respond([]);
|
||||
}
|
||||
|
||||
logger.debug(`Responding to autocomplete with results for query: '${query}'.`);
|
||||
return interaction.respond(response);
|
||||
},
|
||||
execute: async ({ interaction, executionId }: CommandParams) => {
|
||||
execute: async ({ interaction, executionId }) => {
|
||||
const logger = loggerTemplate.child({
|
||||
executionId: executionId,
|
||||
shardId: interaction.guild?.shardId,
|
||||
@@ -411,3 +358,5 @@ module.exports = {
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
export default command;
|
||||
@@ -3,13 +3,14 @@ import { NodeResolvable, useQueue } from 'discord-player';
|
||||
import { EmbedBuilder, SlashCommandBuilder } from 'discord.js';
|
||||
|
||||
import loggerModule from '../../../services/logger';
|
||||
import { CommandParams } from '../../../types/commandTypes';
|
||||
import { CustomSlashCommandInteraction } from '../../../types/interactionTypes';
|
||||
import { EmbedOptions, PlayerOptions } from '../../../types/configTypes';
|
||||
import { notInSameVoiceChannel, notInVoiceChannel } from '../../../utils/validation/voiceChannelValidator';
|
||||
|
||||
const embedOptions: EmbedOptions = config.get('embedOptions');
|
||||
const playerOptions: PlayerOptions = config.get('playerOptions');
|
||||
module.exports = {
|
||||
|
||||
const command: CustomSlashCommandInteraction = {
|
||||
isNew: false,
|
||||
isBeta: false,
|
||||
data: new SlashCommandBuilder()
|
||||
@@ -18,7 +19,7 @@ module.exports = {
|
||||
.setDMPermission(false)
|
||||
.setNSFW(false)
|
||||
.addNumberOption((option) => option.setName('page').setDescription('Page number of the queue').setMinValue(1)),
|
||||
execute: async ({ interaction, executionId }: CommandParams) => {
|
||||
execute: async ({ interaction, executionId }) => {
|
||||
const logger = loggerModule.child({
|
||||
source: 'queue.js',
|
||||
module: 'slashCommand',
|
||||
@@ -207,3 +208,5 @@ module.exports = {
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
export default command;
|
||||
@@ -3,13 +3,14 @@ import { NodeResolvable, useQueue } from 'discord-player';
|
||||
import { EmbedBuilder, GuildMember, SlashCommandBuilder } from 'discord.js';
|
||||
|
||||
import loggerModule from '../../../services/logger';
|
||||
import { CommandParams } from '../../../types/commandTypes';
|
||||
import { CustomSlashCommandInteraction } from '../../../types/interactionTypes';
|
||||
import { EmbedOptions } from '../../../types/configTypes';
|
||||
import { queueDoesNotExist } from '../../../utils/validation/queueValidator';
|
||||
import { notInSameVoiceChannel, notInVoiceChannel } from '../../../utils/validation/voiceChannelValidator';
|
||||
|
||||
const embedOptions: EmbedOptions = config.get('embedOptions');
|
||||
module.exports = {
|
||||
|
||||
const command: CustomSlashCommandInteraction = {
|
||||
isNew: false,
|
||||
isBeta: false,
|
||||
data: new SlashCommandBuilder()
|
||||
@@ -24,7 +25,7 @@ module.exports = {
|
||||
.setMinValue(1)
|
||||
.setRequired(true)
|
||||
),
|
||||
execute: async ({ interaction, executionId }: CommandParams) => {
|
||||
execute: async ({ interaction, executionId }) => {
|
||||
const logger = loggerModule.child({
|
||||
source: 'remove.js',
|
||||
module: 'slashCommand',
|
||||
@@ -104,3 +105,5 @@ module.exports = {
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
export default command;
|
||||
@@ -3,13 +3,14 @@ import { NodeResolvable, useQueue } from 'discord-player';
|
||||
import { EmbedBuilder, GuildMember, SlashCommandBuilder } from 'discord.js';
|
||||
|
||||
import loggerModule from '../../../services/logger';
|
||||
import { CommandParams } from '../../../types/commandTypes';
|
||||
import { CustomSlashCommandInteraction } from '../../../types/interactionTypes';
|
||||
import { EmbedOptions } from '../../../types/configTypes';
|
||||
import { queueDoesNotExist, queueNoCurrentTrack } from '../../../utils/validation/queueValidator';
|
||||
import { notInSameVoiceChannel, notInVoiceChannel } from '../../../utils/validation/voiceChannelValidator';
|
||||
|
||||
const embedOptions: EmbedOptions = config.get('embedOptions');
|
||||
module.exports = {
|
||||
|
||||
const command: CustomSlashCommandInteraction = {
|
||||
isNew: false,
|
||||
isBeta: false,
|
||||
data: new SlashCommandBuilder()
|
||||
@@ -23,7 +24,7 @@ module.exports = {
|
||||
.setDescription('Duration in format 00:00:00 (HH:mm:ss) to seek to.')
|
||||
.setRequired(true)
|
||||
),
|
||||
execute: async ({ interaction, executionId }: CommandParams) => {
|
||||
execute: async ({ interaction, executionId }) => {
|
||||
const logger = loggerModule.child({
|
||||
source: 'seek.js',
|
||||
module: 'slashCommand',
|
||||
@@ -186,3 +187,5 @@ module.exports = {
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
export default command;
|
||||
@@ -3,13 +3,14 @@ import { NodeResolvable, useQueue } from 'discord-player';
|
||||
import { EmbedBuilder, GuildMember, SlashCommandBuilder } from 'discord.js';
|
||||
|
||||
import loggerModule from '../../../services/logger';
|
||||
import { CommandParams } from '../../../types/commandTypes';
|
||||
import { CustomSlashCommandInteraction } from '../../../types/interactionTypes';
|
||||
import { EmbedOptions } from '../../../types/configTypes';
|
||||
import { queueDoesNotExist, queueIsEmpty } from '../../../utils/validation/queueValidator';
|
||||
import { notInSameVoiceChannel, notInVoiceChannel } from '../../../utils/validation/voiceChannelValidator';
|
||||
|
||||
const embedOptions: EmbedOptions = config.get('embedOptions');
|
||||
module.exports = {
|
||||
|
||||
const command: CustomSlashCommandInteraction = {
|
||||
isNew: false,
|
||||
isBeta: false,
|
||||
data: new SlashCommandBuilder()
|
||||
@@ -17,7 +18,7 @@ module.exports = {
|
||||
.setDescription('Shuffle tracks in the queue randomly.')
|
||||
.setDMPermission(false)
|
||||
.setNSFW(false),
|
||||
execute: async ({ interaction, executionId }: CommandParams) => {
|
||||
execute: async ({ interaction, executionId }) => {
|
||||
const logger = loggerModule.child({
|
||||
source: 'shuffle.js',
|
||||
module: 'slashCommand',
|
||||
@@ -72,3 +73,5 @@ module.exports = {
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
export default command;
|
||||
@@ -3,13 +3,14 @@ import { NodeResolvable, useQueue } from 'discord-player';
|
||||
import { EmbedBuilder, GuildMember, SlashCommandBuilder } from 'discord.js';
|
||||
|
||||
import loggerModule from '../../../services/logger';
|
||||
import { CommandParams } from '../../../types/commandTypes';
|
||||
import { CustomSlashCommandInteraction } from '../../../types/interactionTypes';
|
||||
import { EmbedOptions } from '../../../types/configTypes';
|
||||
import { queueDoesNotExist, queueNoCurrentTrack } from '../../../utils/validation/queueValidator';
|
||||
import { notInSameVoiceChannel, notInVoiceChannel } from '../../../utils/validation/voiceChannelValidator';
|
||||
|
||||
const embedOptions: EmbedOptions = config.get('embedOptions');
|
||||
module.exports = {
|
||||
|
||||
const command: CustomSlashCommandInteraction = {
|
||||
isNew: false,
|
||||
isBeta: false,
|
||||
data: new SlashCommandBuilder()
|
||||
@@ -20,7 +21,7 @@ module.exports = {
|
||||
.addNumberOption((option) =>
|
||||
option.setName('tracknumber').setDescription('Track number to skip to in the queue.').setMinValue(1)
|
||||
),
|
||||
execute: async ({ interaction, executionId }: CommandParams) => {
|
||||
execute: async ({ interaction, executionId }) => {
|
||||
const logger = loggerModule.child({
|
||||
source: 'skip.js',
|
||||
module: 'slashCommand',
|
||||
@@ -181,3 +182,5 @@ module.exports = {
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
export default command;
|
||||
@@ -3,12 +3,13 @@ import { NodeResolvable, useQueue } from 'discord-player';
|
||||
import { EmbedBuilder, GuildMember, SlashCommandBuilder } from 'discord.js';
|
||||
|
||||
import loggerModule from '../../../services/logger';
|
||||
import { CommandParams } from '../../../types/commandTypes';
|
||||
import { CustomSlashCommandInteraction } from '../../../types/interactionTypes';
|
||||
import { EmbedOptions } from '../../../types/configTypes';
|
||||
import { notInSameVoiceChannel, notInVoiceChannel } from '../../../utils/validation/voiceChannelValidator';
|
||||
|
||||
const embedOptions: EmbedOptions = config.get('embedOptions');
|
||||
module.exports = {
|
||||
|
||||
const command: CustomSlashCommandInteraction = {
|
||||
isNew: false,
|
||||
isBeta: false,
|
||||
data: new SlashCommandBuilder()
|
||||
@@ -16,7 +17,7 @@ module.exports = {
|
||||
.setDescription('Stop playing audio and clear the track queue.')
|
||||
.setDMPermission(false)
|
||||
.setNSFW(false),
|
||||
execute: async ({ interaction, executionId }: CommandParams) => {
|
||||
execute: async ({ interaction, executionId }) => {
|
||||
const logger = loggerModule.child({
|
||||
source: 'stop.js',
|
||||
module: 'slashCommand',
|
||||
@@ -82,3 +83,5 @@ module.exports = {
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
export default command;
|
||||
@@ -3,13 +3,14 @@ import { NodeResolvable, useQueue } from 'discord-player';
|
||||
import { EmbedBuilder, GuildMember, SlashCommandBuilder } from 'discord.js';
|
||||
|
||||
import loggerModule from '../../../services/logger';
|
||||
import { CommandParams } from '../../../types/commandTypes';
|
||||
import { CustomSlashCommandInteraction } from '../../../types/interactionTypes';
|
||||
import { EmbedOptions } from '../../../types/configTypes';
|
||||
import { queueDoesNotExist } from '../../../utils/validation/queueValidator';
|
||||
import { notInSameVoiceChannel, notInVoiceChannel } from '../../../utils/validation/voiceChannelValidator';
|
||||
|
||||
const embedOptions: EmbedOptions = config.get('embedOptions');
|
||||
module.exports = {
|
||||
|
||||
const command: CustomSlashCommandInteraction = {
|
||||
isNew: false,
|
||||
isBeta: false,
|
||||
data: new SlashCommandBuilder()
|
||||
@@ -24,7 +25,7 @@ module.exports = {
|
||||
.setMinValue(0)
|
||||
.setMaxValue(100)
|
||||
),
|
||||
execute: async ({ interaction, executionId }: CommandParams) => {
|
||||
execute: async ({ interaction, executionId }) => {
|
||||
const logger = loggerModule.child({
|
||||
source: 'volume.js',
|
||||
module: 'slashCommand',
|
||||
@@ -126,3 +127,5 @@ module.exports = {
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
export default command;
|
||||
@@ -2,12 +2,13 @@ import config from 'config';
|
||||
import { EmbedBuilder, Guild, SlashCommandBuilder } from 'discord.js';
|
||||
|
||||
import loggerModule from '../../../services/logger';
|
||||
import { CommandParams } from '../../../types/commandTypes';
|
||||
import { CustomSlashCommandInteraction } from '../../../types/interactionTypes';
|
||||
import { EmbedOptions } from '../../../types/configTypes';
|
||||
import { notValidGuildId } from '../../../utils/validation/systemCommandValidator';
|
||||
|
||||
const embedOptions: EmbedOptions = config.get('embedOptions');
|
||||
module.exports = {
|
||||
|
||||
const command: CustomSlashCommandInteraction = {
|
||||
isSystemCommand: true,
|
||||
isNew: false,
|
||||
isBeta: false,
|
||||
@@ -16,7 +17,7 @@ module.exports = {
|
||||
.setDescription('Show list of guilds where bot is added.')
|
||||
.setDMPermission(false)
|
||||
.setNSFW(false),
|
||||
execute: async ({ interaction, client, executionId }: CommandParams) => {
|
||||
execute: async ({ interaction, client, executionId }) => {
|
||||
const logger = loggerModule.child({
|
||||
source: 'guilds.js',
|
||||
module: 'slashCommand',
|
||||
@@ -86,3 +87,5 @@ module.exports = {
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
export default command;
|
||||
@@ -3,12 +3,13 @@ import { EmbedBuilder, SlashCommandBuilder } from 'discord.js';
|
||||
|
||||
import loggerModule from '../../../services/logger';
|
||||
import { ExtendedClient } from '../../../types/clientTypes';
|
||||
import { CommandParams } from '../../../types/commandTypes';
|
||||
import { CustomSlashCommandInteraction } from '../../../types/interactionTypes';
|
||||
import { EmbedOptions } from '../../../types/configTypes';
|
||||
import { notValidGuildId } from '../../../utils/validation/systemCommandValidator';
|
||||
|
||||
const embedOptions: EmbedOptions = config.get('embedOptions');
|
||||
module.exports = {
|
||||
|
||||
const command: CustomSlashCommandInteraction = {
|
||||
isSystemCommand: true,
|
||||
isNew: false,
|
||||
isBeta: false,
|
||||
@@ -17,7 +18,7 @@ module.exports = {
|
||||
.setDescription('Reload the bot commands.')
|
||||
.setDMPermission(false)
|
||||
.setNSFW(false),
|
||||
execute: async ({ interaction, client, executionId }: CommandParams) => {
|
||||
execute: async ({ interaction, client, executionId }) => {
|
||||
const logger = loggerModule.child({
|
||||
source: 'reload.js',
|
||||
module: 'slashCommand',
|
||||
@@ -82,3 +83,5 @@ module.exports = {
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
export default command;
|
||||
@@ -3,12 +3,13 @@ import { EmbedBuilder, SlashCommandBuilder } from 'discord.js';
|
||||
|
||||
import loggerModule from '../../../services/logger';
|
||||
import { ExtendedClient } from '../../../types/clientTypes';
|
||||
import { CommandParams, ShardInfo } from '../../../types/commandTypes';
|
||||
import { ShardInfo, CustomSlashCommandInteraction } from '../../../types/interactionTypes';
|
||||
import { EmbedOptions } from '../../../types/configTypes';
|
||||
import { notValidGuildId } from '../../../utils/validation/systemCommandValidator';
|
||||
|
||||
const embedOptions: EmbedOptions = config.get('embedOptions');
|
||||
module.exports = {
|
||||
|
||||
const command: CustomSlashCommandInteraction = {
|
||||
isSystemCommand: true,
|
||||
isNew: false,
|
||||
isBeta: false,
|
||||
@@ -34,7 +35,7 @@ module.exports = {
|
||||
)
|
||||
|
||||
.addNumberOption((option) => option.setName('page').setDescription('Page number to show').setMinValue(1)),
|
||||
execute: async ({ interaction, client, executionId }: CommandParams) => {
|
||||
execute: async ({ interaction, client, executionId }) => {
|
||||
const logger = loggerModule.child({
|
||||
source: 'shards.js',
|
||||
module: 'slashCommand',
|
||||
@@ -198,3 +199,5 @@ module.exports = {
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
export default command;
|
||||
@@ -5,14 +5,14 @@ import osu from 'node-os-utils';
|
||||
// @ts-ignore
|
||||
import { dependencies, version } from '../../../../package.json';
|
||||
import loggerModule from '../../../services/logger';
|
||||
import { CommandParams } from '../../../types/commandTypes';
|
||||
import { CustomSlashCommandInteraction } from '../../../types/interactionTypes';
|
||||
import { EmbedOptions } from '../../../types/configTypes';
|
||||
import { getUptimeFormatted } from '../../../utils/system/getUptimeFormatted';
|
||||
import { notValidGuildId } from '../../../utils/validation/systemCommandValidator';
|
||||
|
||||
const embedOptions: EmbedOptions = config.get('embedOptions');
|
||||
|
||||
module.exports = {
|
||||
const command: CustomSlashCommandInteraction = {
|
||||
isSystemCommand: true,
|
||||
isNew: false,
|
||||
isBeta: false,
|
||||
@@ -21,7 +21,7 @@ module.exports = {
|
||||
.setDescription('Show the bot and system status.')
|
||||
.setDMPermission(false)
|
||||
.setNSFW(false),
|
||||
execute: async ({ interaction, client, executionId }: CommandParams) => {
|
||||
execute: async ({ interaction, client, executionId }) => {
|
||||
const logger = loggerModule.child({
|
||||
source: 'systemstatus.js',
|
||||
module: 'slashCommand',
|
||||
@@ -171,3 +171,5 @@ module.exports = {
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
export default command;
|
||||
Reference in new issue
Block a user