fix: more type annotation

This commit is contained in:
Marius Begby committed 2023-08-30 14:12:55 +02:00
1 parent 3ac692d8eb
commit 2560f0fe9a
65 files changed
+408 -343

No files matched your search

@@ -1,14 +1,17 @@
import { AutocompleteInteraction } from 'discord.js';
import { Logger } from 'pino';
import loggerModule from '../services/logger';
export const handleAutocomplete = async (interaction: AutocompleteInteraction, executionId: string) => {
const logger = loggerModule.child({
// TODO: Define TS Type for handlers, and require logger constant?
const logger: Logger = loggerModule.child({
source: 'interactionCutocompleteHandler.ts',
module: 'handler',
name: 'interactionAutocompleteHandler',
executionId: executionId
});
// TODO: Create TS Type for autocompleteModule
const autocompleteModule = await import(`../interactions/autocomplete/${interaction.commandName}.js`);
const { default: autocomplete } = autocompleteModule;
+5 -3
View File
@@ -1,14 +1,15 @@
import { ChatInputCommandInteraction } from 'discord.js';
import { Logger } from 'pino';
import loggerModule from '../services/logger';
import { Command, ExtendedClient } from '../types/clientTypes';
import { cannotSendMessageInChannel } from '../utils/validation/permissionValidator';
import loggerModule from '../services/logger';
export const handleCommand = async (
interaction: ChatInputCommandInteraction,
client: ExtendedClient,
executionId: string
) => {
const logger = loggerModule.child({
const logger: Logger = loggerModule.child({
source: 'interactionCommandHandler.ts',
module: 'handler',
name: 'interactionCommandHandler',
@@ -18,7 +19,8 @@ export const handleCommand = async (
await interaction.deferReply();
logger.debug('Interaction deferred.');
const command = client.commands?.get(interaction.commandName) as Command;
// TODO: Update TS Type for command
const command: Command = client.commands?.get(interaction.commandName) as Command;
if (!command) {
logger.warn(`Interaction created but command '${interaction.commandName}' was not found.`);
return;
+5 -3
View File
@@ -1,9 +1,10 @@
import { MessageComponentInteraction } from 'discord.js';
import { Logger } from 'pino';
import loggerModule from '../services/logger';
import { cannotSendMessageInChannel } from '../utils/validation/permissionValidator';
export const handleComponent = async (interaction: MessageComponentInteraction, executionId: string) => {
const logger = loggerModule.child({
const logger: Logger = loggerModule.child({
source: 'interactionComponentHandler.js',
module: 'handler',
name: 'interactionComponentHandler',
@@ -13,8 +14,8 @@ export const handleComponent = async (interaction: MessageComponentInteraction,
await interaction.deferReply();
logger.debug('Interaction deferred.');
const componentId = interaction.customId.split('_')[0];
const referenceId = interaction.customId.split('_')[1];
const componentId: string = interaction.customId.split('_')[0];
const referenceId: string = interaction.customId.split('_')[1];
logger.debug(`Parsed componentId: ${componentId}`);
@@ -22,6 +23,7 @@ export const handleComponent = async (interaction: MessageComponentInteraction,
return;
}
// TODO: Create TS Type for component
const componentModule = await import(`../interactions/components/${componentId}.js`);
const { default: component } = componentModule;
+8 -4
View File
@@ -1,25 +1,29 @@
import config from 'config';
import { ChatInputCommandInteraction, EmbedBuilder, Interaction, MessageComponentInteraction } from 'discord.js';
import { BotOptions, EmbedOptions } from '../types/configTypes';
import { ChatInputCommandInteraction, EmbedBuilder, Interaction, InteractionReplyOptions, MessageComponentInteraction } from 'discord.js';
import { Logger } from 'pino';
import loggerModule from '../services/logger';
import { BotOptions, EmbedOptions } from '../types/configTypes';
import { CustomError } from '../types/interactionTypes';
const embedOptions: EmbedOptions = config.get('embedOptions');
const botOptions: BotOptions = config.get('botOptions');
// TODO: Update TS Type for handlError
export const handleError = async (
interaction: Interaction,
error: CustomError,
interactionIdentifier: string,
executionId: string
) => {
const logger = loggerModule.child({
const logger: Logger = loggerModule.child({
source: 'interactionErrorHandler.ts',
module: 'handler',
name: 'interactionErrorHandler',
executionId: executionId
});
const errorReply = {
// TODO: Extract replies for embeds
const errorReply: InteractionReplyOptions = {
embeds: [
new EmbedBuilder()
.setDescription(