fix: annotations for events

This commit is contained in:
Marius Begby committed 2023-08-27 02:46:50 +02:00
1 parent 39e818283d
commit b118ebdfb0
26 files changed
+231 -173

No files matched your search

+13 -12
View File
@@ -1,42 +1,43 @@
import config from 'config';
import { EmbedOptions } from '../../types/configTypes';
import { EmbedOptions, LoadTestOptions, SystemOptions } from '../../types/configTypes';
const embedOptions: EmbedOptions = config.get('embedOptions');
const systemOptions = config.get('systemOptions');
const presenceStatusOptions = config.get('presenceStatusOptions');
const loadTestOptions = config.get('loadTestOptions');
const systemOptions: SystemOptions = config.get('systemOptions');
const presenceStatusOptions: PresenceData = config.get('presenceStatusOptions');
const loadTestOptions: LoadTestOptions = config.get('loadTestOptions');
import { postBotStats } from '../../utils/other/postBotStats';
import { startLoadTest } from '../../utils/other/startLoadTest';
import { Events, EmbedBuilder } from 'discord.js';
import { Events, EmbedBuilder, PresenceData, BaseGuildTextChannel } from 'discord.js';
import { v4 as uuidv4 } from 'uuid';
import loggerModule from '../../services/logger';
import { ExtendedClient } from '../../types/clientTypes';
module.exports = {
name: Events.ClientReady,
isDebug: false,
once: false,
execute: async (client) => {
execute: async (client: ExtendedClient) => {
const executionId = uuidv4();
const logger = loggerModule.child({
source: 'ready.js',
module: 'event',
name: 'clientReady',
executionId: executionId,
shardId: client.shard.ids[0]
shardId: client.shard?.ids[0]
});
logger.debug('Client \'ready\' event received after \'allShardsReady\' event.');
await client.user.setPresence(presenceStatusOptions);
logger.debug("Client 'ready' event received after 'allShardsReady' event.");
await client.user?.setPresence(presenceStatusOptions);
if (loadTestOptions.enabled) {
// Only call function from shard with id 0
// The function uses broadcastEval() to call itself on all shards
if (client.shard.ids[0] === 0) {
if (client.shard?.ids[0] === 0) {
logger.info('Initiating load test for bot client.');
await startLoadTest({ client, executionId });
}
}
const channel = await client.channels.cache.get(systemOptions.systemMessageChannelId);
const channel = (await client.channels.cache.get(systemOptions.systemMessageChannelId)) as BaseGuildTextChannel;
// Check if the channel exists in curent shard and send a message
if (channel) {
@@ -45,7 +46,7 @@ module.exports = {
embeds: [
new EmbedBuilder()
.setDescription(
`**${embedOptions.icons.success} All shards ready**\n**${client.user.tag}** is now **\`online\`**!`
`**${embedOptions.icons.success} All shards ready**\n**${client.user?.tag}** is now **\`online\`**!`
)
.setColor(embedOptions.colors.success)
]