mirror of
https://github.com/darksaid98/cadence-discord-bot.git
synced 2026-12-04 22:15:29 +00:00
update command descriptions and set logger name
This commit is contained in:
1 parent
775d942e2d
commit
ddeaf82c11
26 files changed
+209
-199
No files matched your search
@@ -1,29 +1,25 @@
|
|||||||
import { LyricsData, lyricsExtractor } from '@discord-player/extractor';
|
import { LyricsData, lyricsExtractor } from '@discord-player/extractor';
|
||||||
import { Player, SearchResult, useMainPlayer } from 'discord-player';
|
import { Player, SearchResult, useMainPlayer } from 'discord-player';
|
||||||
import { ApplicationCommandOptionChoiceData } from 'discord.js';
|
import { ApplicationCommandOptionChoiceData } from 'discord.js';
|
||||||
import { Logger } from 'pino';
|
import {
|
||||||
import loggerModule from '../../services/logger';
|
BaseAutocompleteInteraction,
|
||||||
import { BaseAutocompleteInteraction } from '../../types/interactionTypes';
|
BaseAutocompleteParams,
|
||||||
|
BaseAutocompleteReturnType
|
||||||
const loggerTemplate: Logger = loggerModule.child({
|
} from '../../types/interactionTypes';
|
||||||
source: 'lyrics.js',
|
|
||||||
module: 'autocompleteInteraction',
|
|
||||||
name: '/lyrics'
|
|
||||||
});
|
|
||||||
|
|
||||||
// TODO: create interface for recent query object
|
// TODO: create interface for recent query object
|
||||||
const recentQueries = new Map();
|
const recentQueries = new Map();
|
||||||
|
|
||||||
const autocomplete: BaseAutocompleteInteraction = {
|
class LyricsAutocomplete extends BaseAutocompleteInteraction {
|
||||||
execute: async ({ interaction, executionId }) => {
|
constructor() {
|
||||||
const logger: Logger = loggerTemplate.child({
|
super('lyrics');
|
||||||
executionId: executionId,
|
}
|
||||||
shardId: interaction.guild?.shardId,
|
|
||||||
guildId: interaction.guild?.id
|
async execute(params: BaseAutocompleteParams): BaseAutocompleteReturnType {
|
||||||
});
|
const { executionId, interaction } = params;
|
||||||
|
const logger = this.getLogger(this.name, executionId, interaction);
|
||||||
|
|
||||||
const query: string = interaction.options.getString('query', true);
|
const query: string = interaction.options.getString('query', true);
|
||||||
|
|
||||||
const { lastQuery, result, timestamp } = recentQueries.get(interaction.user.id);
|
const { lastQuery, result, timestamp } = recentQueries.get(interaction.user.id);
|
||||||
|
|
||||||
if (lastQuery && (query.startsWith(lastQuery) || lastQuery.startsWith(query)) && Date.now() - timestamp < 500) {
|
if (lastQuery && (query.startsWith(lastQuery) || lastQuery.startsWith(query)) && Date.now() - timestamp < 500) {
|
||||||
@@ -76,6 +72,6 @@ const autocomplete: BaseAutocompleteInteraction = {
|
|||||||
logger.debug(`Responding to autocomplete with results for query: '${query}'.`);
|
logger.debug(`Responding to autocomplete with results for query: '${query}'.`);
|
||||||
return interaction.respond(response);
|
return interaction.respond(response);
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
export default autocomplete;
|
export default new LyricsAutocomplete();
|
||||||
@@ -1,25 +1,22 @@
|
|||||||
import { Player, SearchResult, useMainPlayer } from 'discord-player';
|
import { Player, SearchResult, useMainPlayer } from 'discord-player';
|
||||||
import { ApplicationCommandOptionChoiceData } from 'discord.js';
|
import { ApplicationCommandOptionChoiceData } from 'discord.js';
|
||||||
import { Logger } from 'pino';
|
import {
|
||||||
import loggerModule from '../../services/logger';
|
BaseAutocompleteInteraction,
|
||||||
import { BaseAutocompleteInteraction } from '../../types/interactionTypes';
|
BaseAutocompleteParams,
|
||||||
|
BaseAutocompleteReturnType
|
||||||
const loggerTemplate: Logger = loggerModule.child({
|
} from '../../types/interactionTypes';
|
||||||
source: 'play.js',
|
|
||||||
module: 'autocompleteInteraction',
|
|
||||||
name: '/play'
|
|
||||||
});
|
|
||||||
|
|
||||||
// TODO: create interface for recent query object
|
// TODO: create interface for recent query object
|
||||||
const recentQueries = new Map();
|
const recentQueries = new Map();
|
||||||
|
|
||||||
const autocomplete: BaseAutocompleteInteraction = {
|
class PlayAutocomplete extends BaseAutocompleteInteraction {
|
||||||
execute: async ({ interaction, executionId }) => {
|
constructor() {
|
||||||
const logger: Logger = loggerTemplate.child({
|
super('play');
|
||||||
executionId: executionId,
|
}
|
||||||
shardId: interaction.guild?.shardId,
|
|
||||||
guildId: interaction.guild?.id
|
async execute(params: BaseAutocompleteParams): BaseAutocompleteReturnType {
|
||||||
});
|
const { executionId, interaction } = params;
|
||||||
|
const logger = this.getLogger(this.name, executionId, interaction);
|
||||||
|
|
||||||
const player: Player = useMainPlayer()!;
|
const player: Player = useMainPlayer()!;
|
||||||
const query: string = interaction.options.getString('query', true);
|
const query: string = interaction.options.getString('query', true);
|
||||||
@@ -66,6 +63,6 @@ const autocomplete: BaseAutocompleteInteraction = {
|
|||||||
logger.debug(`Responding to autocomplete with results for query: '${query}'.`);
|
logger.debug(`Responding to autocomplete with results for query: '${query}'.`);
|
||||||
return interaction.respond(response);
|
return interaction.respond(response);
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
export default autocomplete;
|
export default new PlayAutocomplete();
|
||||||
@@ -9,13 +9,13 @@ class HelpCommand extends BaseSlashCommandInteraction {
|
|||||||
constructor() {
|
constructor() {
|
||||||
const data = new SlashCommandBuilder()
|
const data = new SlashCommandBuilder()
|
||||||
.setName('help')
|
.setName('help')
|
||||||
.setDescription('Show a list of commands and their usage.');
|
.setDescription('Show the list of bot commands.');
|
||||||
super(data);
|
super(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
async execute(params: BaseSlashCommandParams): BaseSlashCommandReturnType {
|
async execute(params: BaseSlashCommandParams): BaseSlashCommandReturnType {
|
||||||
const { executionId, client, interaction } = params;
|
const { executionId, client, interaction } = params;
|
||||||
const logger = this.getLogger('help.js', executionId, interaction);
|
const logger = this.getLogger(this.name, executionId, interaction);
|
||||||
|
|
||||||
const commandList = client!
|
const commandList = client!
|
||||||
.commands!.filter((command: BaseSlashCommandInteraction) => {
|
.commands!.filter((command: BaseSlashCommandInteraction) => {
|
||||||
|
|||||||
@@ -11,13 +11,13 @@ import { getUptimeFormatted } from '../../../utils/system/getUptimeFormatted';
|
|||||||
|
|
||||||
class StatusCommand extends BaseSlashCommandInteraction {
|
class StatusCommand extends BaseSlashCommandInteraction {
|
||||||
constructor() {
|
constructor() {
|
||||||
const data = new SlashCommandBuilder().setName('status').setDescription('Show the bot and system status.');
|
const data = new SlashCommandBuilder().setName('status').setDescription('Show operational status of the bot.');
|
||||||
super(data);
|
super(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
async execute(params: BaseSlashCommandParams): BaseSlashCommandReturnType {
|
async execute(params: BaseSlashCommandParams): BaseSlashCommandReturnType {
|
||||||
const { executionId, interaction, client } = params;
|
const { executionId, interaction, client } = params;
|
||||||
const logger = this.getLogger('status.js', executionId, interaction);
|
const logger = this.getLogger(this.name, executionId, interaction);
|
||||||
|
|
||||||
const uptimeString: string = await getUptimeFormatted({ executionId });
|
const uptimeString: string = await getUptimeFormatted({ executionId });
|
||||||
const usedMemoryInMB: string = Math.ceil((await osu.mem.info()).usedMemMb).toLocaleString('en-US');
|
const usedMemoryInMB: string = Math.ceil((await osu.mem.info()).usedMemMb).toLocaleString('en-US');
|
||||||
|
|||||||
@@ -28,13 +28,13 @@ class FiltersCommand extends BaseSlashCommandInteraction {
|
|||||||
constructor() {
|
constructor() {
|
||||||
const data = new SlashCommandBuilder()
|
const data = new SlashCommandBuilder()
|
||||||
.setName('filters')
|
.setName('filters')
|
||||||
.setDescription('Toggle various audio filters during playback.');
|
.setDescription('Toggle various audio filters.');
|
||||||
super(data);
|
super(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
async execute(params: BaseSlashCommandParams): BaseSlashCommandReturnType {
|
async execute(params: BaseSlashCommandParams): BaseSlashCommandReturnType {
|
||||||
const { executionId, interaction } = params;
|
const { executionId, interaction } = params;
|
||||||
const logger = this.getLogger(this.commandName, executionId, interaction);
|
const logger = this.getLogger(this.name, executionId, interaction);
|
||||||
|
|
||||||
const queue: GuildQueue = useQueue(interaction.guild!.id)!;
|
const queue: GuildQueue = useQueue(interaction.guild!.id)!;
|
||||||
|
|
||||||
|
|||||||
@@ -12,13 +12,13 @@ class LeaveCommand extends BaseSlashCommandInteraction {
|
|||||||
constructor() {
|
constructor() {
|
||||||
const data = new SlashCommandBuilder()
|
const data = new SlashCommandBuilder()
|
||||||
.setName('leave')
|
.setName('leave')
|
||||||
.setDescription('Clear the track queue and remove the bot from voice channel.');
|
.setDescription('Clear the queue and remove bot from voice channel.');
|
||||||
super(data);
|
super(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
async execute(params: BaseSlashCommandParams): BaseSlashCommandReturnType {
|
async execute(params: BaseSlashCommandParams): BaseSlashCommandReturnType {
|
||||||
const { executionId, interaction } = params;
|
const { executionId, interaction } = params;
|
||||||
const logger = this.getLogger(this.commandName, executionId, interaction);
|
const logger = this.getLogger(this.name, executionId, interaction);
|
||||||
|
|
||||||
const queue: GuildQueue = useQueue(interaction.guild!.id)!;
|
const queue: GuildQueue = useQueue(interaction.guild!.id)!;
|
||||||
|
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ class LoopCommand extends BaseSlashCommandInteraction {
|
|||||||
.addStringOption(() =>
|
.addStringOption(() =>
|
||||||
new SlashCommandStringOption()
|
new SlashCommandStringOption()
|
||||||
.setName('mode')
|
.setName('mode')
|
||||||
.setDescription('Mode to set for looping.')
|
.setDescription('Loop mode: Track, queue, autoplay or disabled.')
|
||||||
.setRequired(false)
|
.setRequired(false)
|
||||||
.addChoices(
|
.addChoices(
|
||||||
{ name: 'Track', value: '1' },
|
{ name: 'Track', value: '1' },
|
||||||
@@ -30,7 +30,7 @@ class LoopCommand extends BaseSlashCommandInteraction {
|
|||||||
|
|
||||||
async execute(params: BaseSlashCommandParams): BaseSlashCommandReturnType {
|
async execute(params: BaseSlashCommandParams): BaseSlashCommandReturnType {
|
||||||
const { executionId, interaction } = params;
|
const { executionId, interaction } = params;
|
||||||
const logger = this.getLogger(this.commandName, executionId, interaction);
|
const logger = this.getLogger(this.name, executionId, interaction);
|
||||||
|
|
||||||
const queue: GuildQueue = useQueue(interaction.guild!.id)!;
|
const queue: GuildQueue = useQueue(interaction.guild!.id)!;
|
||||||
|
|
||||||
|
|||||||
@@ -13,11 +13,11 @@ class LyricsCommand extends BaseSlashCommandInteraction {
|
|||||||
constructor() {
|
constructor() {
|
||||||
const data = new SlashCommandBuilder()
|
const data = new SlashCommandBuilder()
|
||||||
.setName('lyrics')
|
.setName('lyrics')
|
||||||
.setDescription('Get lyrics from Genius for current or specified track.')
|
.setDescription('Search Genius lyrics for current or specified track.')
|
||||||
.addStringOption((option) =>
|
.addStringOption((option) =>
|
||||||
option
|
option
|
||||||
.setName('query')
|
.setName('query')
|
||||||
.setDescription('Search query or URL.')
|
.setDescription('Search query by text or URL.')
|
||||||
.setRequired(false)
|
.setRequired(false)
|
||||||
.setMinLength(2)
|
.setMinLength(2)
|
||||||
.setMaxLength(500)
|
.setMaxLength(500)
|
||||||
@@ -28,7 +28,7 @@ class LyricsCommand extends BaseSlashCommandInteraction {
|
|||||||
|
|
||||||
async execute(params: BaseSlashCommandParams): BaseSlashCommandReturnType {
|
async execute(params: BaseSlashCommandParams): BaseSlashCommandReturnType {
|
||||||
const { executionId, interaction } = params;
|
const { executionId, interaction } = params;
|
||||||
const logger = this.getLogger(this.commandName, executionId, interaction);
|
const logger = this.getLogger(this.name, executionId, interaction);
|
||||||
|
|
||||||
const query: string = interaction.options.getString('query')!;
|
const query: string = interaction.options.getString('query')!;
|
||||||
const queue: GuildQueue = useQueue(interaction.guild!.id)!;
|
const queue: GuildQueue = useQueue(interaction.guild!.id)!;
|
||||||
|
|||||||
@@ -26,13 +26,13 @@ class NowPlayingCommand extends BaseSlashCommandInteraction {
|
|||||||
constructor() {
|
constructor() {
|
||||||
const data = new SlashCommandBuilder()
|
const data = new SlashCommandBuilder()
|
||||||
.setName('nowplaying')
|
.setName('nowplaying')
|
||||||
.setDescription('Show information about the track currently playing.');
|
.setDescription('Show information about the current track.');
|
||||||
super(data);
|
super(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
async execute(params: BaseSlashCommandParams): BaseSlashCommandReturnType {
|
async execute(params: BaseSlashCommandParams): BaseSlashCommandReturnType {
|
||||||
const { executionId, interaction } = params;
|
const { executionId, interaction } = params;
|
||||||
const logger = this.getLogger(this.commandName, executionId, interaction);
|
const logger = this.getLogger(this.name, executionId, interaction);
|
||||||
|
|
||||||
const queue: GuildQueue = useQueue(interaction.guild!.id)!;
|
const queue: GuildQueue = useQueue(interaction.guild!.id)!;
|
||||||
|
|
||||||
|
|||||||
@@ -11,13 +11,13 @@ import { notInSameVoiceChannel, notInVoiceChannel } from '../../../utils/validat
|
|||||||
|
|
||||||
class PauseCommand extends BaseSlashCommandInteraction {
|
class PauseCommand extends BaseSlashCommandInteraction {
|
||||||
constructor() {
|
constructor() {
|
||||||
const data = new SlashCommandBuilder().setName('pause').setDescription('Pause or resume the current track.');
|
const data = new SlashCommandBuilder().setName('pause').setDescription('Toggle pause for the current track.');
|
||||||
super(data);
|
super(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
async execute(params: BaseSlashCommandParams): BaseSlashCommandReturnType {
|
async execute(params: BaseSlashCommandParams): BaseSlashCommandReturnType {
|
||||||
const { executionId, interaction } = params;
|
const { executionId, interaction } = params;
|
||||||
const logger = this.getLogger(this.commandName, executionId, interaction);
|
const logger = this.getLogger(this.name, executionId, interaction);
|
||||||
|
|
||||||
const queue: GuildQueue = useQueue(interaction.guild!.id)!;
|
const queue: GuildQueue = useQueue(interaction.guild!.id)!;
|
||||||
|
|
||||||
|
|||||||
@@ -18,11 +18,11 @@ class PlayCommand extends BaseSlashCommandInteraction {
|
|||||||
constructor() {
|
constructor() {
|
||||||
const data = new SlashCommandBuilder()
|
const data = new SlashCommandBuilder()
|
||||||
.setName('play')
|
.setName('play')
|
||||||
.setDescription('Add a track or playlist to the queue by searching or url.')
|
.setDescription('Add a track or playlist to the queue by search query or URL.')
|
||||||
.addStringOption((option) =>
|
.addStringOption((option) =>
|
||||||
option
|
option
|
||||||
.setName('query')
|
.setName('query')
|
||||||
.setDescription('Search query or URL.')
|
.setDescription('Search query by text or URL')
|
||||||
.setRequired(true)
|
.setRequired(true)
|
||||||
.setMinLength(2)
|
.setMinLength(2)
|
||||||
.setMaxLength(500)
|
.setMaxLength(500)
|
||||||
@@ -33,7 +33,7 @@ class PlayCommand extends BaseSlashCommandInteraction {
|
|||||||
|
|
||||||
async execute(params: BaseSlashCommandParams): BaseSlashCommandReturnType {
|
async execute(params: BaseSlashCommandParams): BaseSlashCommandReturnType {
|
||||||
const { executionId, interaction } = params;
|
const { executionId, interaction } = params;
|
||||||
const logger = this.getLogger(this.commandName, executionId, interaction);
|
const logger = this.getLogger(this.name, executionId, interaction);
|
||||||
|
|
||||||
let queue: GuildQueue = useQueue(interaction.guild!.id)!;
|
let queue: GuildQueue = useQueue(interaction.guild!.id)!;
|
||||||
if (queue && (await notInSameVoiceChannel({ interaction, queue, executionId }))) {
|
if (queue && (await notInSameVoiceChannel({ interaction, queue, executionId }))) {
|
||||||
|
|||||||
@@ -17,16 +17,16 @@ class QueueCommand extends BaseSlashCommandInteraction {
|
|||||||
constructor() {
|
constructor() {
|
||||||
const data = new SlashCommandBuilder()
|
const data = new SlashCommandBuilder()
|
||||||
.setName('queue')
|
.setName('queue')
|
||||||
.setDescription('Show the list of tracks added to the queue.')
|
.setDescription('Show tracks that have been added to the queue.')
|
||||||
.addNumberOption((option) =>
|
.addNumberOption((option) =>
|
||||||
option.setName('page').setDescription('Page number of the queue').setMinValue(1)
|
option.setName('page').setDescription('Page number to display for the queue').setMinValue(1)
|
||||||
);
|
);
|
||||||
super(data);
|
super(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
async execute(params: BaseSlashCommandParams): BaseSlashCommandReturnType {
|
async execute(params: BaseSlashCommandParams): BaseSlashCommandReturnType {
|
||||||
const { executionId, interaction } = params;
|
const { executionId, interaction } = params;
|
||||||
const logger = this.getLogger(this.commandName, executionId, interaction);
|
const logger = this.getLogger(this.name, executionId, interaction);
|
||||||
|
|
||||||
const queue: GuildQueue = useQueue(interaction.guild!.id)!;
|
const queue: GuildQueue = useQueue(interaction.guild!.id)!;
|
||||||
|
|
||||||
|
|||||||
@@ -12,11 +12,11 @@ class RemoveCommand extends BaseSlashCommandInteraction {
|
|||||||
constructor() {
|
constructor() {
|
||||||
const data = new SlashCommandBuilder()
|
const data = new SlashCommandBuilder()
|
||||||
.setName('remove')
|
.setName('remove')
|
||||||
.setDescription('Remove a specific track from the queue')
|
.setDescription('Remove specified track from the queue')
|
||||||
.addNumberOption((option) =>
|
.addNumberOption((option) =>
|
||||||
option
|
option
|
||||||
.setName('tracknumber')
|
.setName('tracknumber')
|
||||||
.setDescription('Track number to remove from queue.')
|
.setDescription('The position in queue for track to remove.')
|
||||||
.setMinValue(1)
|
.setMinValue(1)
|
||||||
.setRequired(true)
|
.setRequired(true)
|
||||||
);
|
);
|
||||||
@@ -25,7 +25,7 @@ class RemoveCommand extends BaseSlashCommandInteraction {
|
|||||||
|
|
||||||
async execute(params: BaseSlashCommandParams): BaseSlashCommandReturnType {
|
async execute(params: BaseSlashCommandParams): BaseSlashCommandReturnType {
|
||||||
const { executionId, interaction } = params;
|
const { executionId, interaction } = params;
|
||||||
const logger = this.getLogger(this.commandName, executionId, interaction);
|
const logger = this.getLogger(this.name, executionId, interaction);
|
||||||
|
|
||||||
const queue: GuildQueue = useQueue(interaction.guild!.id)!;
|
const queue: GuildQueue = useQueue(interaction.guild!.id)!;
|
||||||
|
|
||||||
|
|||||||
@@ -12,11 +12,11 @@ class SeekCommand extends BaseSlashCommandInteraction {
|
|||||||
constructor() {
|
constructor() {
|
||||||
const data = new SlashCommandBuilder()
|
const data = new SlashCommandBuilder()
|
||||||
.setName('seek')
|
.setName('seek')
|
||||||
.setDescription('Seek to a specified duration in the current track.')
|
.setDescription('Seek to a duration in the current track.')
|
||||||
.addStringOption((option) =>
|
.addStringOption((option) =>
|
||||||
option
|
option
|
||||||
.setName('duration')
|
.setName('duration')
|
||||||
.setDescription('Duration in format 00:00:00 (HH:mm:ss) to seek to.')
|
.setDescription('Duration in format 00:00:00 (HH:mm:ss).')
|
||||||
.setRequired(true)
|
.setRequired(true)
|
||||||
);
|
);
|
||||||
super(data);
|
super(data);
|
||||||
@@ -24,7 +24,7 @@ class SeekCommand extends BaseSlashCommandInteraction {
|
|||||||
|
|
||||||
async execute(params: BaseSlashCommandParams): BaseSlashCommandReturnType {
|
async execute(params: BaseSlashCommandParams): BaseSlashCommandReturnType {
|
||||||
const { executionId, interaction } = params;
|
const { executionId, interaction } = params;
|
||||||
const logger = this.getLogger(this.commandName, executionId, interaction);
|
const logger = this.getLogger(this.name, executionId, interaction);
|
||||||
|
|
||||||
const queue: GuildQueue = useQueue(interaction.guild!.id)!;
|
const queue: GuildQueue = useQueue(interaction.guild!.id)!;
|
||||||
|
|
||||||
|
|||||||
@@ -12,13 +12,13 @@ class ShuffleCommand extends BaseSlashCommandInteraction {
|
|||||||
constructor() {
|
constructor() {
|
||||||
const data = new SlashCommandBuilder()
|
const data = new SlashCommandBuilder()
|
||||||
.setName('shuffle')
|
.setName('shuffle')
|
||||||
.setDescription('Shuffle tracks in the queue randomly.');
|
.setDescription('Randomly shuffle all tracks in the queue.');
|
||||||
super(data);
|
super(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
async execute(params: BaseSlashCommandParams): BaseSlashCommandReturnType {
|
async execute(params: BaseSlashCommandParams): BaseSlashCommandReturnType {
|
||||||
const { executionId, interaction } = params;
|
const { executionId, interaction } = params;
|
||||||
const logger = this.getLogger(this.commandName, executionId, interaction);
|
const logger = this.getLogger(this.name, executionId, interaction);
|
||||||
|
|
||||||
const queue: GuildQueue = useQueue(interaction.guild!.id)!;
|
const queue: GuildQueue = useQueue(interaction.guild!.id)!;
|
||||||
|
|
||||||
|
|||||||
@@ -12,16 +12,16 @@ class SkipCommand extends BaseSlashCommandInteraction {
|
|||||||
constructor() {
|
constructor() {
|
||||||
const data = new SlashCommandBuilder()
|
const data = new SlashCommandBuilder()
|
||||||
.setName('test')
|
.setName('test')
|
||||||
.setDescription('Skip current or specified track.')
|
.setDescription('Skip track to next or specified position in queue.')
|
||||||
.addNumberOption((option) =>
|
.addNumberOption((option) =>
|
||||||
option.setName('tracknumber').setDescription('Track number to skip to in the queue.').setMinValue(1)
|
option.setName('tracknumber').setDescription('The position in queue to skip to.').setMinValue(1)
|
||||||
);
|
);
|
||||||
super(data);
|
super(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
async execute(params: BaseSlashCommandParams): BaseSlashCommandReturnType {
|
async execute(params: BaseSlashCommandParams): BaseSlashCommandReturnType {
|
||||||
const { executionId, interaction } = params;
|
const { executionId, interaction } = params;
|
||||||
const logger = this.getLogger(this.commandName, executionId, interaction);
|
const logger = this.getLogger(this.name, executionId, interaction);
|
||||||
|
|
||||||
const queue: GuildQueue = useQueue(interaction.guild!.id)!;
|
const queue: GuildQueue = useQueue(interaction.guild!.id)!;
|
||||||
|
|
||||||
|
|||||||
@@ -12,13 +12,13 @@ class StopCommand extends BaseSlashCommandInteraction {
|
|||||||
constructor() {
|
constructor() {
|
||||||
const data = new SlashCommandBuilder()
|
const data = new SlashCommandBuilder()
|
||||||
.setName('stop')
|
.setName('stop')
|
||||||
.setDescription('Stop playing audio and clear the track queue.');
|
.setDescription('Clear the queue and stop playing audio.');
|
||||||
super(data);
|
super(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
async execute(params: BaseSlashCommandParams): BaseSlashCommandReturnType {
|
async execute(params: BaseSlashCommandParams): BaseSlashCommandReturnType {
|
||||||
const { executionId, interaction } = params;
|
const { executionId, interaction } = params;
|
||||||
const logger = this.getLogger(this.commandName, executionId, interaction);
|
const logger = this.getLogger(this.name, executionId, interaction);
|
||||||
|
|
||||||
const queue: GuildQueue = useQueue(interaction.guild!.id)!;
|
const queue: GuildQueue = useQueue(interaction.guild!.id)!;
|
||||||
|
|
||||||
|
|||||||
@@ -12,11 +12,11 @@ class VolumeCommand extends BaseSlashCommandInteraction {
|
|||||||
constructor() {
|
constructor() {
|
||||||
const data = new SlashCommandBuilder()
|
const data = new SlashCommandBuilder()
|
||||||
.setName('volume')
|
.setName('volume')
|
||||||
.setDescription('Show or set the playback volume for tracks.')
|
.setDescription('Show or change the playback volume for tracks.')
|
||||||
.addNumberOption((option) =>
|
.addNumberOption((option) =>
|
||||||
option
|
option
|
||||||
.setName('percentage')
|
.setName('percentage')
|
||||||
.setDescription('Set volume percentage from 1% to 100%.')
|
.setDescription('Volume percentage: From 1% to 100%.')
|
||||||
.setMinValue(0)
|
.setMinValue(0)
|
||||||
.setMaxValue(100)
|
.setMaxValue(100)
|
||||||
);
|
);
|
||||||
@@ -25,7 +25,7 @@ class VolumeCommand extends BaseSlashCommandInteraction {
|
|||||||
|
|
||||||
async execute(params: BaseSlashCommandParams): BaseSlashCommandReturnType {
|
async execute(params: BaseSlashCommandParams): BaseSlashCommandReturnType {
|
||||||
const { executionId, interaction } = params;
|
const { executionId, interaction } = params;
|
||||||
const logger = this.getLogger(this.commandName, executionId, interaction);
|
const logger = this.getLogger(this.name, executionId, interaction);
|
||||||
|
|
||||||
const queue: GuildQueue = useQueue(interaction.guild!.id)!;
|
const queue: GuildQueue = useQueue(interaction.guild!.id)!;
|
||||||
|
|
||||||
|
|||||||
@@ -10,13 +10,14 @@ class GuildsCommand extends BaseSlashCommandInteraction {
|
|||||||
constructor() {
|
constructor() {
|
||||||
const data = new SlashCommandBuilder()
|
const data = new SlashCommandBuilder()
|
||||||
.setName('guilds')
|
.setName('guilds')
|
||||||
.setDescription('Show list of guilds where bot is added.');
|
.setDescription('Show the top 25 guilds by member count.');
|
||||||
super(data);
|
const isSystemCommand: boolean = true;
|
||||||
|
super(data, isSystemCommand);
|
||||||
}
|
}
|
||||||
|
|
||||||
async execute(params: BaseSlashCommandParams): BaseSlashCommandReturnType {
|
async execute(params: BaseSlashCommandParams): BaseSlashCommandReturnType {
|
||||||
const { executionId, interaction, client } = params;
|
const { executionId, interaction, client } = params;
|
||||||
const logger = this.getLogger(this.commandName, executionId, interaction);
|
const logger = this.getLogger(this.name, executionId, interaction);
|
||||||
|
|
||||||
if (await notValidGuildId({ interaction, executionId })) {
|
if (await notValidGuildId({ interaction, executionId })) {
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -9,13 +9,16 @@ import { notValidGuildId } from '../../../utils/validation/systemCommandValidato
|
|||||||
|
|
||||||
class ReloadCommand extends BaseSlashCommandInteraction {
|
class ReloadCommand extends BaseSlashCommandInteraction {
|
||||||
constructor() {
|
constructor() {
|
||||||
const data = new SlashCommandBuilder().setName('reload').setDescription('Reload the bot commands.');
|
const data = new SlashCommandBuilder()
|
||||||
super(data);
|
.setName('reload')
|
||||||
|
.setDescription('Reload all slash commands across shards.');
|
||||||
|
const isSystemCommand: boolean = true;
|
||||||
|
super(data, isSystemCommand);
|
||||||
}
|
}
|
||||||
|
|
||||||
async execute(params: BaseSlashCommandParams): BaseSlashCommandReturnType {
|
async execute(params: BaseSlashCommandParams): BaseSlashCommandReturnType {
|
||||||
const { executionId, interaction, client } = params;
|
const { executionId, interaction, client } = params;
|
||||||
const logger = this.getLogger(this.commandName, executionId, interaction);
|
const logger = this.getLogger(this.name, executionId, interaction);
|
||||||
|
|
||||||
if (await notValidGuildId({ interaction, executionId })) {
|
if (await notValidGuildId({ interaction, executionId })) {
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -12,11 +12,11 @@ class ShardsCommand extends BaseSlashCommandInteraction {
|
|||||||
constructor() {
|
constructor() {
|
||||||
const data = new SlashCommandBuilder()
|
const data = new SlashCommandBuilder()
|
||||||
.setName('shards')
|
.setName('shards')
|
||||||
.setDescription('Show information about the running shards.')
|
.setDescription('Show information about all connected shards.')
|
||||||
.addStringOption((option) =>
|
.addStringOption((option) =>
|
||||||
option
|
option
|
||||||
.setName('sort')
|
.setName('sort')
|
||||||
.setDescription('If specified, what to sort the shards by.')
|
.setDescription('What to sort the shards by.')
|
||||||
.setRequired(false)
|
.setRequired(false)
|
||||||
.addChoices(
|
.addChoices(
|
||||||
{ name: 'None (Shard ID)', value: 'none' },
|
{ name: 'None (Shard ID)', value: 'none' },
|
||||||
@@ -28,13 +28,16 @@ class ShardsCommand extends BaseSlashCommandInteraction {
|
|||||||
{ name: 'Members', value: 'members' }
|
{ name: 'Members', value: 'members' }
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
.addNumberOption((option) => option.setName('page').setDescription('Page number to show').setMinValue(1));
|
.addNumberOption((option) =>
|
||||||
super(data);
|
option.setName('page').setDescription('Page number to display for the shards').setMinValue(1)
|
||||||
|
);
|
||||||
|
const isSystemCommand: boolean = true;
|
||||||
|
super(data, isSystemCommand);
|
||||||
}
|
}
|
||||||
|
|
||||||
async execute(params: BaseSlashCommandParams): BaseSlashCommandReturnType {
|
async execute(params: BaseSlashCommandParams): BaseSlashCommandReturnType {
|
||||||
const { executionId, interaction, client } = params;
|
const { executionId, interaction, client } = params;
|
||||||
const logger = this.getLogger(this.commandName, executionId, interaction);
|
const logger = this.getLogger(this.name, executionId, interaction);
|
||||||
|
|
||||||
if (await notValidGuildId({ interaction, executionId })) {
|
if (await notValidGuildId({ interaction, executionId })) {
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -14,13 +14,14 @@ class SystemStatusCommand extends BaseSlashCommandInteraction {
|
|||||||
constructor() {
|
constructor() {
|
||||||
const data = new SlashCommandBuilder()
|
const data = new SlashCommandBuilder()
|
||||||
.setName('systemstatus')
|
.setName('systemstatus')
|
||||||
.setDescription('Show the bot and system status.');
|
.setDescription('Show operational status of the bot with additional technical information.');
|
||||||
super(data);
|
const isSystemCommand: boolean = true;
|
||||||
|
super(data, isSystemCommand);
|
||||||
}
|
}
|
||||||
|
|
||||||
async execute(params: BaseSlashCommandParams): BaseSlashCommandReturnType {
|
async execute(params: BaseSlashCommandParams): BaseSlashCommandReturnType {
|
||||||
const { executionId, interaction, client } = params;
|
const { executionId, interaction, client } = params;
|
||||||
const logger = this.getLogger(this.commandName, executionId, interaction);
|
const logger = this.getLogger(this.name, executionId, interaction);
|
||||||
|
|
||||||
if (await notValidGuildId({ interaction, executionId })) {
|
if (await notValidGuildId({ interaction, executionId })) {
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -1,26 +1,17 @@
|
|||||||
import config from 'config';
|
|
||||||
import { GuildQueue, useQueue } from 'discord-player';
|
import { GuildQueue, useQueue } from 'discord-player';
|
||||||
import { EmbedBuilder, GuildMember } from 'discord.js';
|
import { EmbedBuilder, GuildMember } from 'discord.js';
|
||||||
import { Logger } from 'pino';
|
import { BaseComponentInteraction, BaseComponentParams, BaseComponentReturnType } from '../../types/interactionTypes';
|
||||||
import loggerModule from '../../services/logger';
|
|
||||||
import { EmbedOptions } from '../../types/configTypes';
|
|
||||||
import { BaseComponentInteraction } from '../../types/interactionTypes';
|
|
||||||
import { queueDoesNotExist } from '../../utils/validation/queueValidator';
|
import { queueDoesNotExist } from '../../utils/validation/queueValidator';
|
||||||
import { notInSameVoiceChannel, notInVoiceChannel } from '../../utils/validation/voiceChannelValidator';
|
import { notInSameVoiceChannel, notInVoiceChannel } from '../../utils/validation/voiceChannelValidator';
|
||||||
const embedOptions: EmbedOptions = config.get('embedOptions');
|
|
||||||
|
|
||||||
const component: BaseComponentInteraction = {
|
class FiltersDisableButtonComponent extends BaseComponentInteraction {
|
||||||
execute: async ({ interaction, executionId }) => {
|
constructor() {
|
||||||
const logger: Logger = loggerModule.child({
|
super('filters-disable-button');
|
||||||
source: 'filters-disable-button.js',
|
}
|
||||||
module: 'componentInteraction',
|
|
||||||
name: 'filters-disable-button',
|
|
||||||
executionId: executionId,
|
|
||||||
shardId: interaction.guild?.shardId,
|
|
||||||
guildId: interaction.guild?.id
|
|
||||||
});
|
|
||||||
|
|
||||||
logger.debug('Received disable confirmation.');
|
async execute(params: BaseComponentParams): BaseComponentReturnType {
|
||||||
|
const { executionId, interaction } = params;
|
||||||
|
const logger = this.getLogger(this.name, executionId, interaction);
|
||||||
|
|
||||||
const queue: GuildQueue = useQueue(interaction.guild!.id)!;
|
const queue: GuildQueue = useQueue(interaction.guild!.id)!;
|
||||||
|
|
||||||
@@ -56,16 +47,16 @@ const component: BaseComponentInteraction = {
|
|||||||
new EmbedBuilder()
|
new EmbedBuilder()
|
||||||
.setAuthor({
|
.setAuthor({
|
||||||
name: authorName,
|
name: authorName,
|
||||||
iconURL: interaction.user.avatarURL() || embedOptions.info.fallbackIconUrl
|
iconURL: interaction.user.avatarURL() || this.embedOptions.info.fallbackIconUrl
|
||||||
})
|
})
|
||||||
.setDescription(
|
.setDescription(
|
||||||
`**${embedOptions.icons.success} Disabled filters**\nAll audio filters have been disabled.`
|
`**${this.embedOptions.icons.success} Disabled filters**\nAll audio filters have been disabled.`
|
||||||
)
|
)
|
||||||
.setColor(embedOptions.colors.success)
|
.setColor(this.embedOptions.colors.success)
|
||||||
],
|
],
|
||||||
components: []
|
components: []
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
export default component;
|
export default new FiltersDisableButtonComponent();
|
||||||
@@ -1,25 +1,20 @@
|
|||||||
import config from 'config';
|
import config from 'config';
|
||||||
import { GuildQueue, QueueFilters, useQueue } from 'discord-player';
|
import { GuildQueue, QueueFilters, useQueue } from 'discord-player';
|
||||||
import { EmbedBuilder, GuildMember, StringSelectMenuInteraction } from 'discord.js';
|
import { EmbedBuilder, GuildMember, StringSelectMenuInteraction } from 'discord.js';
|
||||||
import { Logger } from 'pino';
|
import { FFmpegFilterOption, FFmpegFilterOptions } from '../../types/configTypes';
|
||||||
import loggerModule from '../../services/logger';
|
import { BaseComponentInteraction, BaseComponentParams, BaseComponentReturnType } from '../../types/interactionTypes';
|
||||||
import { EmbedOptions, FFmpegFilterOption, FFmpegFilterOptions } from '../../types/configTypes';
|
|
||||||
import { BaseComponentInteraction } from '../../types/interactionTypes';
|
|
||||||
import { queueDoesNotExist } from '../../utils/validation/queueValidator';
|
import { queueDoesNotExist } from '../../utils/validation/queueValidator';
|
||||||
import { notInSameVoiceChannel, notInVoiceChannel } from '../../utils/validation/voiceChannelValidator';
|
import { notInSameVoiceChannel, notInVoiceChannel } from '../../utils/validation/voiceChannelValidator';
|
||||||
const embedOptions: EmbedOptions = config.get('embedOptions');
|
|
||||||
const ffmpegFilterOptions: FFmpegFilterOptions = config.get('ffmpegFilterOptions');
|
const ffmpegFilterOptions: FFmpegFilterOptions = config.get('ffmpegFilterOptions');
|
||||||
|
|
||||||
const component: BaseComponentInteraction = {
|
class FiltersSelectMenuComponent extends BaseComponentInteraction {
|
||||||
execute: async ({ interaction, executionId }) => {
|
constructor() {
|
||||||
const logger: Logger = loggerModule.child({
|
super('filters-select-menu');
|
||||||
source: 'filters-select-menu.js',
|
}
|
||||||
module: 'componentInteraction',
|
|
||||||
name: 'filters-select-menu',
|
async execute(params: BaseComponentParams): BaseComponentReturnType {
|
||||||
executionId: executionId,
|
const { executionId, interaction } = params;
|
||||||
shardId: interaction.guild?.shardId,
|
const logger = this.getLogger(this.name, executionId, interaction);
|
||||||
guildId: interaction.guild?.id
|
|
||||||
});
|
|
||||||
|
|
||||||
logger.debug('Received select menu confirmation.');
|
logger.debug('Received select menu confirmation.');
|
||||||
|
|
||||||
@@ -87,7 +82,7 @@ const component: BaseComponentInteraction = {
|
|||||||
})
|
})
|
||||||
.setDescription(
|
.setDescription(
|
||||||
`**${
|
`**${
|
||||||
embedOptions.icons.success
|
this.embedOptions.icons.success
|
||||||
} Filters toggled**\nNow using these filters:\n${selectMenuInteraction.values
|
} Filters toggled**\nNow using these filters:\n${selectMenuInteraction.values
|
||||||
.map((enabledFilter: string) => {
|
.map((enabledFilter: string) => {
|
||||||
const filter: FFmpegFilterOption | undefined =
|
const filter: FFmpegFilterOption | undefined =
|
||||||
@@ -103,11 +98,11 @@ const component: BaseComponentInteraction = {
|
|||||||
})
|
})
|
||||||
.join('\n')}`
|
.join('\n')}`
|
||||||
)
|
)
|
||||||
.setColor(embedOptions.colors.success)
|
.setColor(this.embedOptions.colors.success)
|
||||||
],
|
],
|
||||||
components: []
|
components: []
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
export default component;
|
export default new FiltersSelectMenuComponent();
|
||||||
@@ -1,27 +1,17 @@
|
|||||||
import config from 'config';
|
|
||||||
import { GuildQueue, Track, useQueue } from 'discord-player';
|
import { GuildQueue, Track, useQueue } from 'discord-player';
|
||||||
import { EmbedBuilder, GuildMember } from 'discord.js';
|
import { EmbedBuilder, GuildMember } from 'discord.js';
|
||||||
|
import { BaseComponentInteraction, BaseComponentParams, BaseComponentReturnType } from '../../types/interactionTypes';
|
||||||
import loggerModule from '../../services/logger';
|
|
||||||
import { EmbedOptions } from '../../types/configTypes';
|
|
||||||
import { BaseComponentInteraction } from '../../types/interactionTypes';
|
|
||||||
import { notInSameVoiceChannel, notInVoiceChannel } from '../../utils/validation/voiceChannelValidator';
|
|
||||||
import { queueDoesNotExist, queueNoCurrentTrack } from '../../utils/validation/queueValidator';
|
import { queueDoesNotExist, queueNoCurrentTrack } from '../../utils/validation/queueValidator';
|
||||||
import { Logger } from 'pino';
|
import { notInSameVoiceChannel, notInVoiceChannel } from '../../utils/validation/voiceChannelValidator';
|
||||||
const embedOptions: EmbedOptions = config.get('embedOptions');
|
|
||||||
|
|
||||||
const component: BaseComponentInteraction = {
|
class NowplayingSkipButton extends BaseComponentInteraction {
|
||||||
execute: async ({ interaction, referenceId, executionId }) => {
|
constructor() {
|
||||||
const logger: Logger = loggerModule.child({
|
super('nowplaying-skip-button');
|
||||||
source: 'nowplaying-skip.js',
|
}
|
||||||
module: 'componentInteraction',
|
|
||||||
name: 'nowplaying-skip',
|
|
||||||
executionId: executionId,
|
|
||||||
shardId: interaction.guild?.shardId,
|
|
||||||
guildId: interaction.guild?.id
|
|
||||||
});
|
|
||||||
|
|
||||||
logger.debug(`Received skip confirmation for track id ${referenceId}.`);
|
async execute(params: BaseComponentParams): BaseComponentReturnType {
|
||||||
|
const { executionId, interaction, referenceId } = params;
|
||||||
|
const logger = this.getLogger(this.name, executionId, interaction);
|
||||||
|
|
||||||
const queue: GuildQueue = useQueue(interaction.guild!.id)!;
|
const queue: GuildQueue = useQueue(interaction.guild!.id)!;
|
||||||
|
|
||||||
@@ -46,9 +36,9 @@ const component: BaseComponentInteraction = {
|
|||||||
embeds: [
|
embeds: [
|
||||||
new EmbedBuilder()
|
new EmbedBuilder()
|
||||||
.setDescription(
|
.setDescription(
|
||||||
`**${embedOptions.icons.warning} Oops!**\nThere is nothing currently playing. First add some tracks with **\`/play\`**!`
|
`**${this.embedOptions.icons.warning} Oops!**\nThere is nothing currently playing. First add some tracks with **\`/play\`**!`
|
||||||
)
|
)
|
||||||
.setColor(embedOptions.colors.warning)
|
.setColor(this.embedOptions.colors.warning)
|
||||||
],
|
],
|
||||||
components: []
|
components: []
|
||||||
});
|
});
|
||||||
@@ -62,9 +52,9 @@ const component: BaseComponentInteraction = {
|
|||||||
embeds: [
|
embeds: [
|
||||||
new EmbedBuilder()
|
new EmbedBuilder()
|
||||||
.setDescription(
|
.setDescription(
|
||||||
`**${embedOptions.icons.warning} Oops!**\nThis track has already been skipped or is no longer playing.`
|
`**${this.embedOptions.icons.warning} Oops!**\nThis track has already been skipped or is no longer playing.`
|
||||||
)
|
)
|
||||||
.setColor(embedOptions.colors.warning)
|
.setColor(this.embedOptions.colors.warning)
|
||||||
],
|
],
|
||||||
components: []
|
components: []
|
||||||
});
|
});
|
||||||
@@ -77,7 +67,7 @@ const component: BaseComponentInteraction = {
|
|||||||
: `\`${skippedTrack.duration}\``;
|
: `\`${skippedTrack.duration}\``;
|
||||||
|
|
||||||
if (skippedTrack.raw.live) {
|
if (skippedTrack.raw.live) {
|
||||||
durationFormat = `${embedOptions.icons.liveTrack} \`LIVE\``;
|
durationFormat = `${this.embedOptions.icons.liveTrack} \`LIVE\``;
|
||||||
}
|
}
|
||||||
queue.node.skip();
|
queue.node.skip();
|
||||||
logger.debug('Skipped the track.');
|
logger.debug('Skipped the track.');
|
||||||
@@ -105,28 +95,28 @@ const component: BaseComponentInteraction = {
|
|||||||
new EmbedBuilder()
|
new EmbedBuilder()
|
||||||
.setAuthor({
|
.setAuthor({
|
||||||
name: authorName,
|
name: authorName,
|
||||||
iconURL: interaction.user.avatarURL() || embedOptions.info.fallbackIconUrl
|
iconURL: interaction.user.avatarURL() || this.embedOptions.info.fallbackIconUrl
|
||||||
})
|
})
|
||||||
.setDescription(
|
.setDescription(
|
||||||
`**${embedOptions.icons.skipped} Skipped track**\n**${durationFormat} [${skippedTrack.title}](${
|
`**${this.embedOptions.icons.skipped} Skipped track**\n**${durationFormat} [${
|
||||||
skippedTrack.raw.url ?? skippedTrack.url
|
skippedTrack.title
|
||||||
})**` +
|
}](${skippedTrack.raw.url ?? skippedTrack.url})**` +
|
||||||
`${
|
`${
|
||||||
queue.repeatMode === 0
|
queue.repeatMode === 0
|
||||||
? ''
|
? ''
|
||||||
: `\n\n**${
|
: `\n\n**${
|
||||||
queue.repeatMode === 3
|
queue.repeatMode === 3
|
||||||
? embedOptions.icons.autoplaying
|
? this.embedOptions.icons.autoplaying
|
||||||
: embedOptions.icons.looping
|
: this.embedOptions.icons.looping
|
||||||
} Looping**\nLoop mode is set to ${repeatModeUserString}. You can change it with **\`/loop\`**.`
|
} Looping**\nLoop mode is set to ${repeatModeUserString}. You can change it with **\`/loop\`**.`
|
||||||
}`
|
}`
|
||||||
)
|
)
|
||||||
.setThumbnail(skippedTrack.thumbnail)
|
.setThumbnail(skippedTrack.thumbnail)
|
||||||
.setColor(embedOptions.colors.success)
|
.setColor(this.embedOptions.colors.success)
|
||||||
],
|
],
|
||||||
components: []
|
components: []
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
export default component;
|
export default new NowplayingSkipButton();
|
||||||
@@ -13,36 +13,6 @@ import loggerModule from '../services/logger';
|
|||||||
import { ExtendedClient } from './clientTypes';
|
import { ExtendedClient } from './clientTypes';
|
||||||
import { BotOptions, EmbedOptions } from './configTypes';
|
import { BotOptions, EmbedOptions } from './configTypes';
|
||||||
|
|
||||||
interface BaseInteractionParams {
|
|
||||||
executionId: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface BaseSlashCommandParams extends BaseInteractionParams {
|
|
||||||
interaction: ChatInputCommandInteraction;
|
|
||||||
client?: ExtendedClient;
|
|
||||||
}
|
|
||||||
|
|
||||||
export type BaseSlashCommandReturnType = Promise<Message<boolean> | void>;
|
|
||||||
|
|
||||||
interface BaseAutocompleteParams extends BaseInteractionParams {
|
|
||||||
interaction: AutocompleteInteraction;
|
|
||||||
}
|
|
||||||
|
|
||||||
interface BaseComponentParams extends BaseInteractionParams {
|
|
||||||
interaction: MessageComponentInteraction;
|
|
||||||
referenceId?: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Interaction types
|
|
||||||
|
|
||||||
export interface BaseAutocompleteInteraction {
|
|
||||||
execute(params: BaseAutocompleteParams): Promise<ApplicationCommandOptionChoiceData | void>;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface BaseComponentInteraction {
|
|
||||||
execute(params: BaseComponentParams): Promise<Message<boolean> | void>;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface ShardInfo {
|
export interface ShardInfo {
|
||||||
shardId: number;
|
shardId: number;
|
||||||
memUsage: number;
|
memUsage: number;
|
||||||
@@ -66,8 +36,37 @@ export class CustomError extends Error {
|
|||||||
code?: string;
|
code?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
interface BaseInteractionParams {
|
||||||
|
executionId: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface BaseSlashCommandParams extends BaseInteractionParams {
|
||||||
|
interaction: ChatInputCommandInteraction;
|
||||||
|
client?: ExtendedClient;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface BaseAutocompleteParams extends BaseInteractionParams {
|
||||||
|
interaction: AutocompleteInteraction;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface BaseComponentParams extends BaseInteractionParams {
|
||||||
|
interaction: MessageComponentInteraction;
|
||||||
|
referenceId?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export type BaseSlashCommandReturnType = Promise<Message<boolean> | void>;
|
||||||
|
|
||||||
|
export type BaseAutocompleteReturnType = Promise<ApplicationCommandOptionChoiceData | void>;
|
||||||
|
|
||||||
|
export type BaseComponentReturnType = Promise<Message<boolean> | void>;
|
||||||
|
|
||||||
abstract class BaseInteraction {
|
abstract class BaseInteraction {
|
||||||
protected getLoggerBase(module: string, name: string, executionId: string, interaction: Interaction): Logger {
|
protected getLoggerBase(
|
||||||
|
module: string,
|
||||||
|
name: string,
|
||||||
|
executionId: string,
|
||||||
|
interaction: Interaction | MessageComponentInteraction
|
||||||
|
): Logger {
|
||||||
return loggerModule.child({
|
return loggerModule.child({
|
||||||
module: module,
|
module: module,
|
||||||
name: name,
|
name: name,
|
||||||
@@ -89,7 +88,7 @@ export abstract class BaseSlashCommandInteraction extends BaseInteraction {
|
|||||||
isBeta: boolean;
|
isBeta: boolean;
|
||||||
embedOptions: EmbedOptions;
|
embedOptions: EmbedOptions;
|
||||||
botOptions: BotOptions;
|
botOptions: BotOptions;
|
||||||
commandName: string;
|
name: string;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
data: Omit<SlashCommandBuilder, 'addSubcommand' | 'addSubcommandGroup'>,
|
data: Omit<SlashCommandBuilder, 'addSubcommand' | 'addSubcommandGroup'>,
|
||||||
@@ -104,12 +103,46 @@ export abstract class BaseSlashCommandInteraction extends BaseInteraction {
|
|||||||
this.isBeta = isBeta;
|
this.isBeta = isBeta;
|
||||||
this.embedOptions = config.get('embedOptions');
|
this.embedOptions = config.get('embedOptions');
|
||||||
this.botOptions = config.get('botOptions');
|
this.botOptions = config.get('botOptions');
|
||||||
this.commandName = data.name;
|
this.name = data.name;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected getLogger(name: string, executionId: string, interaction: Interaction): Logger {
|
protected getLogger(name: string, executionId: string, interaction: ChatInputCommandInteraction): Logger {
|
||||||
return super.getLoggerBase('slashCommand', name, executionId, interaction);
|
return super.getLoggerBase('slashCommandInteraction', name, executionId, interaction);
|
||||||
}
|
}
|
||||||
|
|
||||||
abstract execute(params: BaseSlashCommandParams): BaseSlashCommandReturnType;
|
abstract execute(params: BaseSlashCommandParams): BaseSlashCommandReturnType;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export abstract class BaseAutocompleteInteraction extends BaseInteraction {
|
||||||
|
name: string;
|
||||||
|
|
||||||
|
constructor(name: string) {
|
||||||
|
super();
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected getLogger(name: string, executionId: string, interaction: AutocompleteInteraction): Logger {
|
||||||
|
return super.getLoggerBase('autocompleteInteraction', name, executionId, interaction);
|
||||||
|
}
|
||||||
|
|
||||||
|
abstract execute(params: BaseAutocompleteParams): BaseAutocompleteReturnType;
|
||||||
|
}
|
||||||
|
|
||||||
|
export abstract class BaseComponentInteraction extends BaseInteraction {
|
||||||
|
embedOptions: EmbedOptions;
|
||||||
|
botOptions: BotOptions;
|
||||||
|
name: string;
|
||||||
|
|
||||||
|
constructor(name: string) {
|
||||||
|
super();
|
||||||
|
this.embedOptions = config.get('embedOptions');
|
||||||
|
this.botOptions = config.get('botOptions');
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected getLogger(name: string, executionId: string, interaction: MessageComponentInteraction): Logger {
|
||||||
|
return super.getLoggerBase('componentInteraction', name, executionId, interaction);
|
||||||
|
}
|
||||||
|
|
||||||
|
abstract execute(params: BaseComponentParams): BaseComponentReturnType;
|
||||||
|
}
|
||||||
Reference in new issue
Block a user