refactor: auto format

This commit is contained in:
Baipyrus 2024-04-03 19:32:16 +02:00
parent 79d69b7360
commit 73fe43a392
3 changed files with 208 additions and 208 deletions

View File

@ -1,138 +1,138 @@
import { import {
SlashCommandBuilder, SlashCommandBuilder,
PermissionFlagsBits, PermissionFlagsBits,
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;
} }
} }

View File

@ -1,33 +1,33 @@
import { DataTypes, Deferrable, Sequelize } from 'sequelize'; import { DataTypes, Deferrable, Sequelize } from 'sequelize';
/** /**
* @typedef {Object} Keyword * @typedef {Object} Keyword
* @property {string} id A universally unique id, generated by sequelize. * @property {string} id A universally unique id, generated by sequelize.
* @property {string} guild A Discord guild ID as a foreign key reference. * @property {string} guild A Discord guild ID as a foreign key reference.
* @property {string} name The name of the keyword. * @property {string} name The name of the keyword.
*/ */
/** /**
* The definition of the `Keyword` table in the database. * The definition of the `Keyword` table in the database.
* @param {Sequelize} sequelize * @param {Sequelize} sequelize
*/ */
export default function (sequelize) { export default function (sequelize) {
return sequelize.define('Keywords', { return sequelize.define('Keywords', {
id: { id: {
defaultValue: DataTypes.UUIDV4, defaultValue: DataTypes.UUIDV4,
type: DataTypes.UUID, type: DataTypes.UUID,
primaryKey: true primaryKey: true
}, },
guild: { guild: {
type: DataTypes.STRING, type: DataTypes.STRING,
references: { references: {
deferrable: Deferrable.INITIALLY_IMMEDIATE, deferrable: Deferrable.INITIALLY_IMMEDIATE,
model: 'Guilds', model: 'Guilds',
key: 'id' key: 'id'
} }
}, },
name: { name: {
type: DataTypes.STRING type: DataTypes.STRING
} }
}); });
} }

View File

@ -1,37 +1,37 @@
import { DataTypes, Deferrable, Sequelize } from 'sequelize'; import { DataTypes, Deferrable, Sequelize } from 'sequelize';
/** /**
* @typedef {Object} Response * @typedef {Object} Response
* @property {string} id A universally unique id, generated by sequelize. * @property {string} id A universally unique id, generated by sequelize.
* @property {string} keyword A universally unique id referencing a `Keyword`. * @property {string} keyword A universally unique id referencing a `Keyword`.
* @property {string} name The name of the response. * @property {string} name The name of the response.
* @property {string} response The response data itself. * @property {string} response The response data itself.
*/ */
/** /**
* The definition of the `Response` table in the database. * The definition of the `Response` table in the database.
* @param {Sequelize} sequelize * @param {Sequelize} sequelize
*/ */
export default function (sequelize) { export default function (sequelize) {
return sequelize.define('Responses', { return sequelize.define('Responses', {
id: { id: {
defaultValue: DataTypes.UUIDV4, defaultValue: DataTypes.UUIDV4,
type: DataTypes.UUID, type: DataTypes.UUID,
primaryKey: true primaryKey: true
}, },
keyword: { keyword: {
type: DataTypes.UUID, type: DataTypes.UUID,
references: { references: {
deferrable: Deferrable.INITIALLY_IMMEDIATE, deferrable: Deferrable.INITIALLY_IMMEDIATE,
model: 'Keywords', model: 'Keywords',
key: 'id' key: 'id'
} }
}, },
name: { name: {
type: DataTypes.STRING type: DataTypes.STRING
}, },
response: { response: {
type: DataTypes.STRING type: DataTypes.STRING
} }
}); });
} }