feat!: Extract logic for autocomplete and component interactions

This commit is contained in:
Marius Begby committed 2023-08-28 13:44:30 +02:00
1 parent f16a18deb5
commit 1ec1281e98
29 files changed
+694 -442

No files matched your search

+6 -3
View File
@@ -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;
+6 -3
View File
@@ -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;
+6 -3
View File
@@ -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;