refactor: auto format

This commit is contained in:
Baipyrus 2024-04-04 07:42:25 +02:00
parent 4bd3e83add
commit d7c26f7bee

View File

@ -1,139 +1,139 @@
import { import {
SlashCommandBuilder, SlashCommandBuilder,
PermissionFlagsBits, PermissionFlagsBits,
ModalSubmitInteraction, ModalSubmitInteraction,
AutocompleteInteraction, AutocompleteInteraction,
ChatInputCommandInteraction ChatInputCommandInteraction
} from 'discord.js'; } from 'discord.js';
/** @param {ChatInputCommandInteraction} interaction */ /** @param {ChatInputCommandInteraction} interaction */
async function createResponse(interaction) {} async function createResponse(interaction) {}
/** @param {ChatInputCommandInteraction} interaction */ /** @param {ChatInputCommandInteraction} interaction */
async function addResponse(interaction) {} async function addResponse(interaction) {}
/** @param {ChatInputCommandInteraction} interaction */ /** @param {ChatInputCommandInteraction} interaction */
async function removeResponse(interaction) {} async function removeResponse(interaction) {}
/** @param {ChatInputCommandInteraction} interaction */ /** @param {ChatInputCommandInteraction} interaction */
async function listResponse(interaction) {} async function listResponse(interaction) {}
/** @param {ChatInputCommandInteraction} interaction */ /** @param {ChatInputCommandInteraction} interaction */
async function infoResponse(interaction) {} async function infoResponse(interaction) {}
/** @param {AutocompleteInteraction} interaction */ /** @param {AutocompleteInteraction} interaction */
async function addAutocomplete(interaction) {} async function addAutocomplete(interaction) {}
/** @param {AutocompleteInteraction} interaction */ /** @param {AutocompleteInteraction} interaction */
async function removeAutocomplete(interaction) {} async function removeAutocomplete(interaction) {}
/** @param {AutocompleteInteraction} interaction */ /** @param {AutocompleteInteraction} interaction */
async function infoAutocomplete(interaction) {} async function infoAutocomplete(interaction) {}
export const data = new SlashCommandBuilder() export const data = new SlashCommandBuilder()
.setName('response') .setName('response')
.setDMPermission(false) .setDMPermission(false)
.setDefaultMemberPermissions(PermissionFlagsBits.ManageMessages) .setDefaultMemberPermissions(PermissionFlagsBits.ManageMessages)
.setDescription('Event based responses to specific messages with keywords.') .setDescription('Event based responses to specific messages with keywords.')
.addSubcommand((subcommand) => .addSubcommand((subcommand) =>
subcommand subcommand
.setName('create') .setName('create')
.setDescription('Creates a new event based response.') .setDescription('Creates a new event based response.')
.addStringOption((option) => .addStringOption((option) =>
option option
.setName('keyword') .setName('keyword')
.setDescription('The keyword to trigger the response.') .setDescription('The keyword to trigger the response.')
.setRequired(true) .setRequired(true)
) )
) )
.addSubcommand((subcommand) => .addSubcommand((subcommand) =>
subcommand subcommand
.setName('add') .setName('add')
.setDescription('Registers a response to a keyword.') .setDescription('Registers a response to a keyword.')
.addStringOption((option) => .addStringOption((option) =>
option option
.setName('keyword') .setName('keyword')
.setDescription('The keyword to trigger the response.') .setDescription('The keyword to trigger the response.')
.setAutocomplete(true) .setAutocomplete(true)
.setRequired(true) .setRequired(true)
) )
) )
.addSubcommand((subcommand) => .addSubcommand((subcommand) =>
subcommand subcommand
.setName('remove') .setName('remove')
.setDescription('Unregisters a response to a keyword.') .setDescription('Unregisters a response to a keyword.')
.addStringOption((option) => .addStringOption((option) =>
option option
.setName('type') .setName('type')
.setDescription('The type of data to be removed.') .setDescription('The type of data to be removed.')
.setRequired(true) .setRequired(true)
.addChoices( .addChoices(
{ name: 'Keyword', value: 'keyword' }, { name: 'Keyword', value: 'keyword' },
{ name: 'Response', value: 'response' } { name: 'Response', value: 'response' }
) )
) )
.addStringOption((option) => .addStringOption((option) =>
option option
.setName('name') .setName('name')
.setDescription('The name of the data to be removed.') .setDescription('The name of the data to be removed.')
.setAutocomplete(true) .setAutocomplete(true)
.setRequired(true) .setRequired(true)
) )
) )
.addSubcommand((subcommand) => .addSubcommand((subcommand) =>
subcommand.setName('list').setDescription('Lists all registered keywords.') subcommand.setName('list').setDescription('Lists all registered keywords.')
) )
.addSubcommand((subcommand) => .addSubcommand((subcommand) =>
subcommand subcommand
.setName('info') .setName('info')
.setDescription('Shows information about a registered keyword.') .setDescription('Shows information about a registered keyword.')
.addStringOption((option) => .addStringOption((option) =>
option option
.setName('keyword') .setName('keyword')
.setDescription('The keyword to show the details of.') .setDescription('The keyword to show the details of.')
.setAutocomplete(true) .setAutocomplete(true)
.setRequired(true) .setRequired(true)
) )
); );
/** @param {ModalSubmitInteraction} interaction */ /** @param {ModalSubmitInteraction} interaction */
export async function modalSubmit(interaction) { export async function modalSubmit(interaction) {
// Only executable in 'add' subcommand // Only executable in 'add' subcommand
} }
/** @param {AutocompleteInteraction} interaction */ /** @param {AutocompleteInteraction} interaction */
export async function autocomplete(interaction) { export async function autocomplete(interaction) {
const { options } = interaction; const { options } = interaction;
switch (options.getSubcommand()) { switch (options.getSubcommand()) {
case 'add': case 'add':
addAutocomplete(interaction); addAutocomplete(interaction);
break; break;
case 'remove': case 'remove':
removeAutocomplete(interaction); removeAutocomplete(interaction);
break; break;
case 'info': case 'info':
infoAutocomplete(interaction); infoAutocomplete(interaction);
break; break;
} }
} }
/** @param {ChatInputCommandInteraction} interaction */ /** @param {ChatInputCommandInteraction} interaction */
export async function execute(interaction) { export async function execute(interaction) {
const { options } = interaction; const { options } = interaction;
switch (options.getSubcommand()) { switch (options.getSubcommand()) {
case 'create': case 'create':
createResponse(interaction); createResponse(interaction);
break; break;
case 'add': case 'add':
addResponse(interaction); addResponse(interaction);
break; break;
case 'remove': case 'remove':
removeResponse(interaction); removeResponse(interaction);
break; break;
case 'list': case 'list':
listResponse(interaction); listResponse(interaction);
break; break;
case 'info': case 'info':
infoResponse(interaction); infoResponse(interaction);
break; break;
} }
} }