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

+3 -2
View File
@@ -2,14 +2,15 @@ import { Events } from 'discord.js';
import { v4 as uuidv4 } from 'uuid';
import loggerModule from '../../services/logger';
import { Logger } from 'pino';
module.exports = {
name: Events.Debug,
isDebug: true,
once: false,
execute: async (message: string) => {
const executionId = uuidv4();
const logger = loggerModule.child({
const executionId: string = uuidv4();
const logger: Logger = loggerModule.child({
source: 'debug.js',
module: 'event',
name: 'clientDebug',
+4 -3
View File
@@ -5,6 +5,7 @@ import { v4 as uuidv4 } from 'uuid';
import loggerModule from '../../services/logger';
import { ExtendedClient } from '../../types/clientTypes';
import { EmbedOptions, SystemOptions } from '../../types/configTypes';
import { Logger } from 'pino';
const embedOptions: EmbedOptions = config.get('embedOptions');
const systemOptions: SystemOptions = config.get('systemOptions');
@@ -13,8 +14,8 @@ module.exports = {
isDebug: false,
once: false,
execute: async (client: ExtendedClient) => {
const executionId = uuidv4();
const logger = loggerModule.child({
const executionId: string = uuidv4();
const logger: Logger = loggerModule.child({
source: 'disconnect.js',
module: 'event',
name: 'clientDisconnect',
@@ -26,7 +27,7 @@ module.exports = {
// send message to system message channel for event
if (systemOptions.systemMessageChannelId && systemOptions.systemUserId) {
const channel = (await client.channels.cache.get(
const channel: BaseGuildTextChannel = (await client.channels.cache.get(
systemOptions.systemMessageChannelId
)) as BaseGuildTextChannel;
if (channel) {
+3 -2
View File
@@ -2,14 +2,15 @@ import { Events } from 'discord.js';
import { v4 as uuidv4 } from 'uuid';
import loggerModule from '../../services/logger';
import { Logger } from 'pino';
module.exports = {
name: Events.Error,
isDebug: false,
once: false,
execute: async (error: Error) => {
const executionId = uuidv4();
const logger = loggerModule.child({
const executionId: string = uuidv4();
const logger: Logger = loggerModule.child({
source: 'error.js',
module: 'event',
name: 'clientError',
+3 -2
View File
@@ -2,14 +2,15 @@ import { Events, Guild } from 'discord.js';
import { v4 as uuidv4 } from 'uuid';
import loggerModule from '../../services/logger';
import { Logger } from 'pino';
module.exports = {
name: Events.GuildCreate,
isDebug: false,
once: false,
execute: async (guild: Guild) => {
const executionId = uuidv4();
const logger = loggerModule.child({
const executionId: string = uuidv4();
const logger: Logger = loggerModule.child({
source: 'guildCreate.js',
module: 'event',
name: 'guildCreate',
+3 -2
View File
@@ -2,14 +2,15 @@ import { Events, Guild } from 'discord.js';
import { v4 as uuidv4 } from 'uuid';
import loggerModule from '../../services/logger';
import { Logger } from 'pino';
module.exports = {
name: Events.GuildDelete,
isDebug: false,
once: false,
execute: async (guild: Guild) => {
const executionId = uuidv4();
const logger = loggerModule.child({
const executionId: string = uuidv4();
const logger: Logger = loggerModule.child({
source: 'guildDelete.js',
module: 'event',
name: 'guildDelete',
+6 -3
View File
@@ -2,6 +2,7 @@ import config from 'config';
import { BaseGuildTextChannel, EmbedBuilder, Events, PresenceData } from 'discord.js';
import { v4 as uuidv4 } from 'uuid';
import { Logger } from 'pino';
import loggerModule from '../../services/logger';
import { ExtendedClient } from '../../types/clientTypes';
import { EmbedOptions, LoadTestOptions, SystemOptions } from '../../types/configTypes';
@@ -17,8 +18,8 @@ module.exports = {
isDebug: false,
once: false,
execute: async (client: ExtendedClient) => {
const executionId = uuidv4();
const logger = loggerModule.child({
const executionId: string = uuidv4();
const logger: Logger = loggerModule.child({
source: 'ready.js',
module: 'event',
name: 'clientReady',
@@ -38,7 +39,9 @@ module.exports = {
}
}
const channel = (await client.channels.cache.get(systemOptions.systemMessageChannelId)) as BaseGuildTextChannel;
const channel: BaseGuildTextChannel = (await client.channels.cache.get(
systemOptions.systemMessageChannelId
)) as BaseGuildTextChannel;
// Check if the channel exists in curent shard and send a message
if (channel) {
+4 -3
View File
@@ -2,6 +2,7 @@ import config from 'config';
import { BaseGuildTextChannel, EmbedBuilder } from 'discord.js';
import { v4 as uuidv4 } from 'uuid';
import { Logger } from 'pino';
import loggerModule from '../../services/logger';
import { ExtendedClient } from '../../types/clientTypes';
import { EmbedOptions, SystemOptions } from '../../types/configTypes';
@@ -13,8 +14,8 @@ module.exports = {
isDebug: false,
once: false,
execute: async (client: ExtendedClient) => {
const executionId = uuidv4();
const logger = loggerModule.child({
const executionId: string = uuidv4();
const logger: Logger = loggerModule.child({
source: 'reconnecting.js',
module: 'event',
name: 'clientReconnecting',
@@ -27,7 +28,7 @@ module.exports = {
// send message to system message channel for event
if (systemOptions.systemMessageChannelId && systemOptions.systemUserId) {
if (systemOptions.systemMessageChannelId && systemOptions.systemUserId) {
const channel = (await client.channels.cache.get(
const channel: BaseGuildTextChannel = (await client.channels.cache.get(
systemOptions.systemMessageChannelId
)) as BaseGuildTextChannel;
if (channel) {
+3 -3
View File
@@ -1,6 +1,6 @@
import { Events } from 'discord.js';
import { Logger } from 'pino';
import { v4 as uuidv4 } from 'uuid';
import loggerModule from '../../services/logger';
module.exports = {
@@ -8,8 +8,8 @@ module.exports = {
isDebug: false,
once: false,
execute: async (warning: string) => {
const executionId = uuidv4();
const logger = loggerModule.child({
const executionId: string = uuidv4();
const logger: Logger = loggerModule.child({
source: 'warn.js',
module: 'event',
name: 'clientWarn',
+5 -5
View File
@@ -6,8 +6,8 @@ import {
InteractionType,
MessageComponentInteraction
} from 'discord.js';
import { Logger } from 'pino';
import { v4 as uuidv4 } from 'uuid';
import { handleAutocomplete } from '../../handlers/interactionAutocompleteHandler';
import { handleCommand } from '../../handlers/interactionCommandHandler';
import { handleComponent } from '../../handlers/interactionComponentHandler';
@@ -21,8 +21,8 @@ module.exports = {
isDebug: false,
execute: async (interaction: Interaction, { client }: { client: ExtendedClient }) => {
const inputTime: number = new Date().getTime();
const executionId = uuidv4();
const logger = loggerModule.child({
const executionId: string = uuidv4();
const logger: Logger = loggerModule.child({
source: 'interactionCreate.js',
module: 'event',
name: 'interactionCreate',
@@ -33,7 +33,7 @@ module.exports = {
logger.debug('Interaction received.');
let interactionIdentifier = 'Unknown';
let interactionIdentifier: string = 'Unknown';
if (
interaction.type === InteractionType.ApplicationCommand ||
interaction.type === InteractionType.ApplicationCommandAutocomplete
@@ -73,7 +73,7 @@ module.exports = {
const outputTime: number = new Date().getTime();
const executionTime: number = outputTime - inputTime;
const interactionType = InteractionType[interaction.type];
const interactionType: string = InteractionType[interaction.type];
logger.info(
{
+3 -3
View File
@@ -1,5 +1,5 @@
import { Logger } from 'pino';
import { v4 as uuidv4 } from 'uuid';
import loggerModule from '../../services/logger';
module.exports = {
@@ -7,8 +7,8 @@ module.exports = {
isDebug: true,
isPlayerEvent: false,
execute: async (message: string) => {
const executionId = uuidv4();
const logger = loggerModule.child({
const executionId: string = uuidv4();
const logger: Logger = loggerModule.child({
source: 'generalDebug.js',
module: 'event',
name: 'playerGeneralDebug',
+4 -4
View File
@@ -1,7 +1,7 @@
import config from 'config';
import { BaseGuildTextChannel, EmbedBuilder } from 'discord.js';
import { Logger } from 'pino';
import { v4 as uuidv4 } from 'uuid';
import loggerModule from '../../services/logger';
import { BotOptions, EmbedOptions, SystemOptions } from '../../types/configTypes';
import { ExtendedGuildQueuePlayerNode } from '../../types/eventTypes';
@@ -15,8 +15,8 @@ module.exports = {
isDebug: false,
isPlayerEvent: true,
execute: async (queue: ExtendedGuildQueuePlayerNode, error: Error) => {
const executionId = uuidv4();
const logger = loggerModule.child({
const executionId: string = uuidv4();
const logger: Logger = loggerModule.child({
source: 'generalError.js',
module: 'event',
name: 'playerGeneralError',
@@ -39,7 +39,7 @@ module.exports = {
});
if (systemOptions.systemMessageChannelId && systemOptions.systemUserId) {
const channel = (await queue.metadata?.client.channels.cache.get(
const channel: BaseGuildTextChannel = (await queue.metadata?.client.channels.cache.get(
systemOptions.systemMessageChannelId
)) as BaseGuildTextChannel;
if (channel) {
+3 -3
View File
@@ -1,5 +1,5 @@
import { Logger } from 'pino';
import { v4 as uuidv4 } from 'uuid';
import loggerModule from '../../services/logger';
module.exports = {
@@ -7,8 +7,8 @@ module.exports = {
isDebug: true,
isPlayerEvent: true,
execute: async (message: string) => {
const executionId = uuidv4();
const logger = loggerModule.child({
const executionId: string = uuidv4();
const logger: Logger = loggerModule.child({
source: 'playerDebug.js',
module: 'event',
name: 'playerDebug',
+4 -4
View File
@@ -1,7 +1,7 @@
import config from 'config';
import { BaseGuildTextChannel, EmbedBuilder } from 'discord.js';
import { Logger } from 'pino';
import { v4 as uuidv4 } from 'uuid';
import loggerModule from '../../services/logger';
import { BotOptions, EmbedOptions, SystemOptions } from '../../types/configTypes';
import { ExtendedGuildQueuePlayerNode } from '../../types/eventTypes';
@@ -15,8 +15,8 @@ module.exports = {
isDebug: false,
isPlayerEvent: true,
execute: async (queue: ExtendedGuildQueuePlayerNode, error: Error) => {
const executionId = uuidv4();
const logger = loggerModule.child({
const executionId: string = uuidv4();
const logger: Logger = loggerModule.child({
source: 'playerError.js',
module: 'event',
name: 'playerError',
@@ -39,7 +39,7 @@ module.exports = {
});
if (systemOptions.systemMessageChannelId && systemOptions.systemUserId) {
const channel = (await queue.metadata?.client.channels.cache.get(
const channel: BaseGuildTextChannel = (await queue.metadata?.client.channels.cache.get(
systemOptions.systemMessageChannelId
)) as BaseGuildTextChannel;
if (channel) {
+4 -4
View File
@@ -1,8 +1,8 @@
import config from 'config';
import { Track } from 'discord-player';
import { BaseGuildTextChannel, EmbedBuilder } from 'discord.js';
import { Logger } from 'pino';
import { v4 as uuidv4 } from 'uuid';
import loggerModule from '../../services/logger';
import { BotOptions, EmbedOptions, SystemOptions } from '../../types/configTypes';
import { ExtendedGuildQueuePlayerNode } from '../../types/eventTypes';
@@ -16,8 +16,8 @@ module.exports = {
isDebug: false,
isPlayerEvent: true,
execute: async (queue: ExtendedGuildQueuePlayerNode, track: Track) => {
const executionId = uuidv4();
const logger = loggerModule.child({
const executionId: string = uuidv4();
const logger: Logger = loggerModule.child({
source: 'playerSkip.js',
module: 'event',
name: 'playerSkip',
@@ -40,7 +40,7 @@ module.exports = {
});
if (systemOptions.systemMessageChannelId && systemOptions.systemUserId) {
const channel = (await queue.metadata?.client.channels.cache.get(
const channel: BaseGuildTextChannel = (await queue.metadata?.client.channels.cache.get(
systemOptions.systemMessageChannelId
)) as BaseGuildTextChannel;
if (channel) {
+3 -3
View File
@@ -1,6 +1,6 @@
import { Track } from 'discord-player';
import { Logger } from 'pino';
import { v4 as uuidv4 } from 'uuid';
import loggerModule from '../../services/logger';
import { ExtendedGuildQueuePlayerNode } from '../../types/eventTypes';
@@ -9,8 +9,8 @@ module.exports = {
isDebug: false,
isPlayerEvent: true,
execute: async (queue: ExtendedGuildQueuePlayerNode, track: Track) => {
const executionId = uuidv4();
const logger = loggerModule.child({
const executionId: string = uuidv4();
const logger: Logger = loggerModule.child({
source: 'playerStart.js',
module: 'event',
name: 'playerStart',
+3 -3
View File
@@ -1,13 +1,13 @@
import { Logger } from 'pino';
import { v4 as uuidv4 } from 'uuid';
import loggerModule from '../../services/logger';
module.exports = {
name: 'uncaughtException',
isDebug: false,
execute: async (error: Error) => {
const executionId = uuidv4();
const logger = loggerModule.child({
const executionId: string = uuidv4();
const logger: Logger = loggerModule.child({
source: 'uncaughtException.js',
module: 'event',
name: 'uncaughtException',
+3 -3
View File
@@ -1,13 +1,13 @@
import { Logger } from 'pino';
import { v4 as uuidv4 } from 'uuid';
import loggerModule from '../../services/logger';
module.exports = {
name: 'unhandledRejection',
isDebug: false,
execute: async (error: Error) => {
const executionId = uuidv4();
const logger = loggerModule.child({
const executionId: string = uuidv4();
const logger: Logger = loggerModule.child({
source: 'unhandledRejection.js',
module: 'event',
name: 'unhandledRejection',