From dc9c33f0d4bf4f32f0b81c13ff6b69760dcd5cf1 Mon Sep 17 00:00:00 2001 From: ITOH <72305210+itohatweb@users.noreply.github.com> Date: Fri, 9 Apr 2021 22:22:06 +0200 Subject: [PATCH] f --- src/handlers/channels/CHANNEL_DELETE.ts | 2 +- src/handlers/guilds/GUILD_DELETE.ts | 6 +++--- src/handlers/members/GUILD_MEMBER_UPDATE.ts | 4 ++-- src/handlers/misc/READY.ts | 8 ++++---- src/handlers/misc/USER_UPDATE.ts | 2 +- src/handlers/roles/GUILD_ROLE_DELETE.ts | 4 ++-- src/helpers/channels/create_channel.ts | 2 +- src/helpers/channels/edit_channel.ts | 4 ++-- src/helpers/commands/send_interaction_response.ts | 2 +- src/helpers/emojis/get_emojis.ts | 2 +- src/helpers/members/get_members.ts | 4 ++-- src/helpers/messages/add_reactions.ts | 2 +- src/rest/cleanup_queues.ts | 2 +- src/rest/process_queue.ts | 4 ++-- src/rest/process_rate_limited_paths.ts | 4 ++-- src/structures/channel.ts | 2 +- src/structures/guild.ts | 2 +- src/structures/member.ts | 6 +++--- src/structures/message.ts | 2 +- src/structures/role.ts | 2 +- src/structures/template.ts | 2 +- src/util/utils.ts | 12 ++++++------ 22 files changed, 40 insertions(+), 40 deletions(-) diff --git a/src/handlers/channels/CHANNEL_DELETE.ts b/src/handlers/channels/CHANNEL_DELETE.ts index 1c5662f7b..4e41719c6 100644 --- a/src/handlers/channels/CHANNEL_DELETE.ts +++ b/src/handlers/channels/CHANNEL_DELETE.ts @@ -32,7 +32,7 @@ export async function handleChannelDelete(data: DiscordGatewayPayload) { await cacheHandlers.delete("channels", payload.id); cacheHandlers.forEach("messages", (message) => { - eventHandlers.debug( + eventHandlers.debug?.( "loop", `Running forEach messages loop in CHANNEL_DELTE file.`, ); diff --git a/src/handlers/guilds/GUILD_DELETE.ts b/src/handlers/guilds/GUILD_DELETE.ts index 6d753f71a..54c8b0b3b 100644 --- a/src/handlers/guilds/GUILD_DELETE.ts +++ b/src/handlers/guilds/GUILD_DELETE.ts @@ -27,7 +27,7 @@ export async function handleGuildDelete( } cacheHandlers.forEach("messages", (message) => { - eventHandlers.debug( + eventHandlers.debug?.( "loop", `1. Running forEach messages loop in CHANNEL_DELTE file.`, ); @@ -37,7 +37,7 @@ export async function handleGuildDelete( }); cacheHandlers.forEach("channels", (channel) => { - eventHandlers.debug( + eventHandlers.debug?.( "loop", `2. Running forEach channels loop in CHANNEL_DELTE file.`, ); @@ -47,7 +47,7 @@ export async function handleGuildDelete( }); cacheHandlers.forEach("members", (member) => { - eventHandlers.debug( + eventHandlers.debug?.( "loop", `3. Running forEach members loop in CHANNEL_DELTE file.`, ); diff --git a/src/handlers/members/GUILD_MEMBER_UPDATE.ts b/src/handlers/members/GUILD_MEMBER_UPDATE.ts index a2846fe8b..443554894 100644 --- a/src/handlers/members/GUILD_MEMBER_UPDATE.ts +++ b/src/handlers/members/GUILD_MEMBER_UPDATE.ts @@ -46,7 +46,7 @@ export async function handleGuildMemberUpdate(data: DiscordGatewayPayload) { const roleIds = guildMember.roles || []; roleIds.forEach((id) => { - eventHandlers.debug( + eventHandlers.debug?.( "loop", `1. Running forEach loop in GUILD_MEMBER_UPDATE file.`, ); @@ -56,7 +56,7 @@ export async function handleGuildMemberUpdate(data: DiscordGatewayPayload) { }); payload.roles.forEach((id) => { - eventHandlers.debug( + eventHandlers.debug?.( "loop", `2. Running forEach loop in GUILD_MEMBER_UPDATE file.`, ); diff --git a/src/handlers/misc/READY.ts b/src/handlers/misc/READY.ts index 818eac211..ef84f303e 100644 --- a/src/handlers/misc/READY.ts +++ b/src/handlers/misc/READY.ts @@ -33,7 +33,7 @@ export async function handleReady( // Start ready check in 2 seconds setTimeout(async () => { - eventHandlers.debug( + eventHandlers.debug?.( "loop", `1. Running setTimeout in READY file.`, ); @@ -60,7 +60,7 @@ async function checkReady(payload: DiscordReady, shardId: number, now: number) { } else { // Not all guilds were loaded but 10 seconds haven't passed so check again setTimeout(async () => { - eventHandlers.debug( + eventHandlers.debug?.( "loop", `2. Running setTimeout in READY file.`, ); @@ -84,7 +84,7 @@ async function loaded(shardId: number) { // Still some shards are loading so wait another 2 seconds for them if (ws.shards.some((shard) => !shard.ready)) { setTimeout(async () => { - eventHandlers.debug( + eventHandlers.debug?.( "loop", `3. Running setTimeout in CHANNEL_DELTE file.`, ); @@ -96,7 +96,7 @@ async function loaded(shardId: number) { // All the members that came in on guild creates should now be processed 1 by 1 for (const [guildId, members] of initialMemberLoadQueue.entries()) { - eventHandlers.debug( + eventHandlers.debug?.( "loop", "Running for of loop in READY file for loading members.", ); diff --git a/src/handlers/misc/USER_UPDATE.ts b/src/handlers/misc/USER_UPDATE.ts index cac495ab7..ab7ee0f8b 100644 --- a/src/handlers/misc/USER_UPDATE.ts +++ b/src/handlers/misc/USER_UPDATE.ts @@ -10,7 +10,7 @@ export async function handleUserUpdate(data: DiscordGatewayPayload) { if (!member) return; Object.entries(userData).forEach(([key, value]) => { - eventHandlers.debug( + eventHandlers.debug?.( "loop", `Running forEach loop in USER_UPDATE file.`, ); diff --git a/src/handlers/roles/GUILD_ROLE_DELETE.ts b/src/handlers/roles/GUILD_ROLE_DELETE.ts index 0d1e785f1..ca22ac66f 100644 --- a/src/handlers/roles/GUILD_ROLE_DELETE.ts +++ b/src/handlers/roles/GUILD_ROLE_DELETE.ts @@ -15,7 +15,7 @@ export async function handleGuildRoleDelete(data: DiscordGatewayPayload) { // For bots without GUILD_MEMBERS member.roles is never updated breaking permissions checking. cacheHandlers.forEach("members", (member) => { - eventHandlers.debug( + eventHandlers.debug?.( "loop", `1. Running forEach members loop in GUILD_ROLE_DELETE file.`, ); @@ -23,7 +23,7 @@ export async function handleGuildRoleDelete(data: DiscordGatewayPayload) { if (!member.guilds.has(guild.id)) return; member.guilds.forEach((g) => { - eventHandlers.debug( + eventHandlers.debug?.( "loop", `2. Running forEach loop in CHANNEL_DELTE file.`, ); diff --git a/src/helpers/channels/create_channel.ts b/src/helpers/channels/create_channel.ts index 7d928cfee..f6815e7f2 100644 --- a/src/helpers/channels/create_channel.ts +++ b/src/helpers/channels/create_channel.ts @@ -20,7 +20,7 @@ export async function createChannel( const requiredPerms: Set = new Set(["MANAGE_CHANNELS"]); options?.permissionOverwrites?.forEach((overwrite) => { - eventHandlers.debug( + eventHandlers.debug?.( "loop", `Running forEach loop in create_channel file.`, ); diff --git a/src/helpers/channels/edit_channel.ts b/src/helpers/channels/edit_channel.ts index 9ec0f2ad7..ec8b39fde 100644 --- a/src/helpers/channels/edit_channel.ts +++ b/src/helpers/channels/edit_channel.ts @@ -78,7 +78,7 @@ function processEditChannelQueue() { const now = Date.now(); editChannelNameTopicQueue.forEach((request) => { - eventHandlers.debug( + eventHandlers.debug?.( "loop", `Running forEach loop in edit_channel file.`, ); @@ -102,7 +102,7 @@ function processEditChannelQueue() { if (editChannelNameTopicQueue.size) { setTimeout(() => { - eventHandlers.debug( + eventHandlers.debug?.( "loop", `Running setTimeout in EDIT_CHANNEL file.`, ); diff --git a/src/helpers/commands/send_interaction_response.ts b/src/helpers/commands/send_interaction_response.ts index 9fd4d20d3..775036da8 100644 --- a/src/helpers/commands/send_interaction_response.ts +++ b/src/helpers/commands/send_interaction_response.ts @@ -26,7 +26,7 @@ export async function sendInteractionResponse( cache.executedSlashCommands.set(token, id); setTimeout( () => { - eventHandlers.debug( + eventHandlers.debug?.( "loop", `Running setTimeout in send_interaction_response file.`, ); diff --git a/src/helpers/emojis/get_emojis.ts b/src/helpers/emojis/get_emojis.ts index 45e4ea492..4269a7c07 100644 --- a/src/helpers/emojis/get_emojis.ts +++ b/src/helpers/emojis/get_emojis.ts @@ -19,7 +19,7 @@ export async function getEmojis(guildId: string, addToCache = true) { if (!guild) throw new Error(Errors.GUILD_NOT_FOUND); result.forEach((emoji) => { - eventHandlers.debug( + eventHandlers.debug?.( "loop", `Running forEach loop in get_emojis file.`, ); diff --git a/src/helpers/members/get_members.ts b/src/helpers/members/get_members.ts index 3a7f14ae3..e322417af 100644 --- a/src/helpers/members/get_members.ts +++ b/src/helpers/members/get_members.ts @@ -32,7 +32,7 @@ export async function getMembers(guildId: string, options?: GetMemberOptions) { (options?.limit ?? guild.memberCount) > members.size && membersLeft > 0 ) { - eventHandlers.debug("loop", "Running while loop in getMembers function."); + eventHandlers.debug?.("loop", "Running while loop in getMembers function."); if (options?.limit && options.limit > 1000) { console.log( @@ -67,7 +67,7 @@ export async function getMembers(guildId: string, options?: GetMemberOptions) { if (!memberStructures.length) break; memberStructures.forEach((member) => { - eventHandlers.debug( + eventHandlers.debug?.( "loop", `Running forEach loop in get_members file.`, ); diff --git a/src/helpers/messages/add_reactions.ts b/src/helpers/messages/add_reactions.ts index 5e20d3f3a..6a619c63e 100644 --- a/src/helpers/messages/add_reactions.ts +++ b/src/helpers/messages/add_reactions.ts @@ -14,7 +14,7 @@ export async function addReactions( ); } else { for (const reaction of reactions) { - eventHandlers.debug( + eventHandlers.debug?.( "loop", "Running for of loop in addReactions function.", ); diff --git a/src/rest/cleanup_queues.ts b/src/rest/cleanup_queues.ts index dc768270e..15de9fd46 100644 --- a/src/rest/cleanup_queues.ts +++ b/src/rest/cleanup_queues.ts @@ -3,7 +3,7 @@ import { rest } from "./rest.ts"; /** Cleans up the queues by checking if there is nothing left and removing it. */ export function cleanupQueues() { for (const [key, queue] of rest.pathQueues) { - rest.eventHandlers.debug( + rest.eventHandlers.debug?.( "loop", "Running for of loop in cleanupQueues function.", ); diff --git a/src/rest/process_queue.ts b/src/rest/process_queue.ts index 75680ae21..75d600333 100644 --- a/src/rest/process_queue.ts +++ b/src/rest/process_queue.ts @@ -9,14 +9,14 @@ export async function processQueue(id: string) { if (!queue) return; while (queue.length) { - rest.eventHandlers.debug( + rest.eventHandlers.debug?.( "loop", "Running while loop in processQueue function.", ); // IF THE BOT IS GLOBALLY RATELIMITED TRY AGAIN if (rest.globallyRateLimited) { setTimeout(() => { - eventHandlers.debug( + eventHandlers.debug?.( "loop", `Running setTimeout in processQueue function.`, ); diff --git a/src/rest/process_rate_limited_paths.ts b/src/rest/process_rate_limited_paths.ts index 1209b5ca2..338b35b21 100644 --- a/src/rest/process_rate_limited_paths.ts +++ b/src/rest/process_rate_limited_paths.ts @@ -6,7 +6,7 @@ export function processRateLimitedPaths() { const now = Date.now(); rest.ratelimitedPaths.forEach((value, key) => { - rest.eventHandlers.debug( + rest.eventHandlers.debug?.( "loop", `Running forEach loop in process_rate_limited_paths file.`, ); @@ -26,7 +26,7 @@ export function processRateLimitedPaths() { rest.processingRateLimitedPaths = true; // RECHECK IN 1 SECOND setTimeout(() => { - eventHandlers.debug( + eventHandlers.debug?.( "loop", `Running setTimeout in processRateLimitedPaths function.`, ); diff --git a/src/structures/channel.ts b/src/structures/channel.ts index 6dd4014bc..d48c5606b 100644 --- a/src/structures/channel.ts +++ b/src/structures/channel.ts @@ -82,7 +82,7 @@ export async function createChannelStruct( const props: Record = {}; Object.keys(rest).forEach((key) => { - eventHandlers.debug( + eventHandlers.debug?.( "loop", `Running forEach loop in createChannelStruct function.`, ); diff --git a/src/structures/guild.ts b/src/structures/guild.ts index adb6d37bc..7756fd9be 100644 --- a/src/structures/guild.ts +++ b/src/structures/guild.ts @@ -147,7 +147,7 @@ export async function createGuildStruct( const props: Record> = {}; for (const key of Object.keys(rest)) { - eventHandlers.debug( + eventHandlers.debug?.( "loop", `Running for of loop in createGuildStruct function.`, ); diff --git a/src/structures/member.ts b/src/structures/member.ts index 32e5d5020..6851d44d4 100644 --- a/src/structures/member.ts +++ b/src/structures/member.ts @@ -88,7 +88,7 @@ export async function createMemberStruct( const props: Record> = {}; for (const key of Object.keys(rest)) { - eventHandlers.debug( + eventHandlers.debug?.( "loop", `Running for of loop for Object.keys(rest) in createMemberStruct function.`, ); @@ -97,7 +97,7 @@ export async function createMemberStruct( } for (const key of Object.keys(user)) { - eventHandlers.debug( + eventHandlers.debug?.( "loop", `Running for of for Object.keys(user) loop in createMemberStruct function.`, ); @@ -114,7 +114,7 @@ export async function createMemberStruct( const cached = await cacheHandlers.get("members", user.id); if (cached) { for (const [id, guild] of cached.guilds.entries()) { - eventHandlers.debug( + eventHandlers.debug?.( "loop", `Running for of for cached.guilds.entries() loop in createMemberStruct function.`, ); diff --git a/src/structures/message.ts b/src/structures/message.ts index 2a4566554..23e466c57 100644 --- a/src/structures/message.ts +++ b/src/structures/message.ts @@ -130,7 +130,7 @@ export async function createMessageStruct(data: DiscordMessage) { const props: Record> = {}; for (const key of Object.keys(rest)) { - eventHandlers.debug( + eventHandlers.debug?.( "loop", `Running for of loop in createMessageStruct function.`, ); diff --git a/src/structures/role.ts b/src/structures/role.ts index a0aa5de35..2db7cc88e 100644 --- a/src/structures/role.ts +++ b/src/structures/role.ts @@ -75,7 +75,7 @@ export async function createRoleStruct(data: DiscordGuildRoleCreate) { const props: Record> = {}; for (const key of Object.keys(rest)) { - eventHandlers.debug( + eventHandlers.debug?.( "loop", `Running for of loop in createRoleStruct function.`, ); diff --git a/src/structures/template.ts b/src/structures/template.ts index 92943bd71..dc801de2f 100644 --- a/src/structures/template.ts +++ b/src/structures/template.ts @@ -26,7 +26,7 @@ export function createTemplateStruct( const restProps: Record> = {}; for (const key of Object.keys(rest)) { - eventHandlers.debug( + eventHandlers.debug?.( "loop", `Running for of loop in createTemplateStruct function.`, ); diff --git a/src/util/utils.ts b/src/util/utils.ts index cacedbd51..6536f3423 100644 --- a/src/util/utils.ts +++ b/src/util/utils.ts @@ -12,7 +12,7 @@ export function editBotStatus( data: Pick, ) { ws.shards.forEach((shard) => { - eventHandlers.debug( + eventHandlers.debug?.( "loop", `Running forEach loop in editBotStatus function.`, ); @@ -85,7 +85,7 @@ export function camelKeysToSnakeCase( const convertedObject: Record = {}; Object.keys(obj).forEach((key) => { - eventHandlers.debug( + eventHandlers.debug?.( "loop", `Running forEach loop in camelKeysToSnakeCase function.`, ); @@ -111,7 +111,7 @@ export function snakeKeysToCamelCase( const convertedObject: Record = {}; Object.keys(obj).forEach((key) => { - eventHandlers.debug( + eventHandlers.debug?.( "loop", `Running forEach loop in snakeKeysToCamelCase function.`, ); @@ -134,7 +134,7 @@ function validateSlashOptionChoices( optionType: SlashCommandOptionType, ) { for (const choice of choices) { - eventHandlers.debug( + eventHandlers.debug?.( "loop", `Running for of loop in validateSlashOptionChoices function.`, ); @@ -158,7 +158,7 @@ function validateSlashOptionChoices( /** @private */ function validateSlashOptions(options: SlashCommandOption[]) { for (const option of options) { - eventHandlers.debug( + eventHandlers.debug?.( "loop", `Running for of loop in validateSlashOptions function.`, ); @@ -192,7 +192,7 @@ export function validateSlashCommands( create = false, ) { for (const command of commands) { - eventHandlers.debug( + eventHandlers.debug?.( "loop", `Running for of loop in validateSlashCommands function.`, );