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