From 9980856eefd09704ef457f56d47e1519e01f4cef Mon Sep 17 00:00:00 2001 From: ITOH Date: Thu, 31 Mar 2022 14:16:34 +0200 Subject: [PATCH] refactor!: fix some spelling mistakes (#2144) * refactor!: fix some spelling mistakes This fixes some spelling mistakes around the code base. Note not all are fixed. * subComponent --- bot.ts | 8 +- gateway/createShard.ts | 2 +- gateway/handleOnMessage.ts | 2 +- gateway/identify.ts | 2 +- gateway/resharder.ts | 12 +- gateway/shard.ts | 2 +- helpers/channels/createChannel.ts | 2 +- helpers/channels/editChannel.ts | 2 +- helpers/discovery/editDiscovery.ts | 2 +- helpers/guilds/getAuditLogs.ts | 2 +- .../commands/editInteractionResponse.ts | 52 +++---- .../followups/editFollowupMessage.ts | 52 +++---- .../interactions/sendInteractionResponse.ts | 58 ++++---- helpers/invites/createInvite.ts | 2 +- helpers/messages/editMessage.ts | 54 +++---- helpers/messages/sendMessage.ts | 52 +++---- helpers/webhooks/editWebhookMessage.ts | 52 +++---- plugins/cache/src/setupCacheRemovals.ts | 2 +- plugins/cache/src/sweepers.ts | 2 +- plugins/fileloader/README.md | 2 +- plugins/helpers/src/sendDirectMessage.ts | 2 +- plugins/permissions/src/components.ts | 52 +++---- plugins/permissions/src/permissions.ts | 6 +- rest/checkRateLimits.ts | 4 +- rest/processGlobalQueue.ts | 4 +- rest/processQueue.ts | 4 +- rest/processRateLimitedPaths.ts | 6 +- rest/processRequestHeaders.ts | 20 +-- rest/rest.ts | 2 +- rest/restManager.ts | 2 +- rest/runMethod.ts | 2 +- rest/simplifyUrl.ts | 4 +- template/beginner/src/utils/logger.ts | 54 +++---- .../interactions/executeSlashCommand.ts | 2 +- template/bigbot/src/bot/mod.ts | 4 +- template/bigbot/src/bot/types/command.ts | 2 +- template/bigbot/src/utils/Components.ts | 2 +- template/bigbot/src/utils/helpers.ts | 4 +- template/bigbot/src/utils/logger.ts | 54 +++---- template/bigbot/src/utils/options.ts | 2 +- template/bigbot/src/utils/permLevels.ts | 6 +- .../minimal/src/events/interactionCreate.ts | 2 +- template/minimal/src/utils/logger.ts | 54 +++---- transformers/auditLogEntry.ts | 133 ++++++++++++++++++ transformers/mod.ts | 2 +- transformers/toggles/guild.ts | 8 +- transformers/toggles/role.ts | 4 +- types/discord.ts | 40 ++---- types/shared.ts | 16 +-- util/collection.ts | 2 +- 50 files changed, 493 insertions(+), 370 deletions(-) create mode 100644 transformers/auditLogEntry.ts diff --git a/bot.ts b/bot.ts index e0de5d662..be98f4975 100644 --- a/bot.ts +++ b/bot.ts @@ -55,7 +55,7 @@ import { transformAttachment } from "./transformers/attachment.ts"; import { transformEmbed } from "./transformers/embed.ts"; import { transformComponent } from "./transformers/component.ts"; import { transformWebhook } from "./transformers/webhook.ts"; -import { transformAuditlogEntry } from "./transformers/auditlogEntry.ts"; +import { transformAuditLogEntry } from "./transformers/auditLogEntry.ts"; import { transformApplicationCommandPermission } from "./transformers/applicationCommandPermission.ts"; import { calculateBits, calculatePermissions } from "./util/permissions.ts"; import { transformScheduledEvent } from "./transformers/scheduledEvent.ts"; @@ -120,7 +120,7 @@ import { Embed } from "./transformers/embed.ts"; import { Webhook } from "./transformers/webhook.ts"; import { Component } from "./transformers/component.ts"; import { ApplicationCommand } from "./transformers/applicationCommand.ts"; -import { AuditLogEntry } from "./transformers/auditlogEntry.ts"; +import { AuditLogEntry } from "./transformers/auditLogEntry.ts"; import { ApplicationCommandOption } from "./transformers/applicationCommandOption.ts"; import { ApplicationCommandPermission } from "./transformers/applicationCommandPermission.ts"; import { WelcomeScreen } from "./transformers/welcomeScreen.ts"; @@ -411,7 +411,7 @@ export interface Transformers { embed: (bot: Bot, payload: DiscordEmbed) => Embed; component: (bot: Bot, payload: DiscordComponent) => Component; webhook: (bot: Bot, payload: DiscordWebhook) => Webhook; - auditlogEntry: (bot: Bot, payload: DiscordAuditLogEntry) => AuditLogEntry; + auditLogEntry: (bot: Bot, payload: DiscordAuditLogEntry) => AuditLogEntry; applicationCommand: (bot: Bot, payload: DiscordApplicationCommand) => ApplicationCommand; applicationCommandOption: (bot: Bot, payload: DiscordApplicationCommandOption) => ApplicationCommandOption; applicationCommandPermission: ( @@ -460,7 +460,7 @@ export function createTransformers(options: Partial) { voiceState: options.voiceState || transformVoiceState, snowflake: options.snowflake || snowflakeToBigint, webhook: options.webhook || transformWebhook, - auditlogEntry: options.auditlogEntry || transformAuditlogEntry, + auditLogEntry: options.auditLogEntry || transformAuditLogEntry, applicationCommand: options.applicationCommand || transformApplicationCommand, applicationCommandOption: options.applicationCommandOption || diff --git a/gateway/createShard.ts b/gateway/createShard.ts index 256ab926d..b120ef805 100644 --- a/gateway/createShard.ts +++ b/gateway/createShard.ts @@ -27,7 +27,7 @@ export function createShard(gateway: GatewayManager, shardId: number) { return; case 3063: // Resharded case 3064: // Resuming - case 3065: // Reidentifying + case 3065: // Re-identifying case 3066: // Missing ACK // Will restart shard manually return gateway.debug("GW CLOSED_RECONNECT", { shardId, payload: event }); diff --git a/gateway/handleOnMessage.ts b/gateway/handleOnMessage.ts index d9d96940f..e13d32321 100644 --- a/gateway/handleOnMessage.ts +++ b/gateway/handleOnMessage.ts @@ -73,7 +73,7 @@ export async function handleOnMessage(gateway: GatewayManager, message: any, sha // We need to wait for a random amount of time between 1 and 5: https://discord.com/developers/docs/topics/gateway#resuming await delay(Math.floor((Math.random() * 4 + 1) * 1000)); - // When d is false we need to reidentify + // When d is false we need to re-identify if (!messageData.d) { await gateway.identify(gateway, shardId, gateway.maxShards); break; diff --git a/gateway/identify.ts b/gateway/identify.ts index d86ab0d5c..d72de5544 100644 --- a/gateway/identify.ts +++ b/gateway/identify.ts @@ -7,7 +7,7 @@ export function identify(gateway: GatewayManager, shardId: number, maxShards: nu // Need to clear the old heartbeat interval const oldShard = gateway.shards.get(shardId); if (oldShard) { - gateway.closeWS(oldShard.ws, 3065, "Reidentifying closure of old shard"); + gateway.closeWS(oldShard.ws, 3065, "Re-identifying closure of old shard"); clearInterval(oldShard.heartbeat.intervalId); } diff --git a/gateway/resharder.ts b/gateway/resharder.ts index f788a441f..0aa097bcf 100644 --- a/gateway/resharder.ts +++ b/gateway/resharder.ts @@ -36,7 +36,7 @@ export async function resharder( } // USE ANY CUSTOMIZED OPTIONS FROM OLD GATEWAY - // @ts-ignore TODO: fix this dynamica assignment + // @ts-ignore TODO: fix this dynamical assignment gateway[key] = oldGateway[key as keyof typeof oldGateway]; } @@ -83,7 +83,7 @@ export async function resharder( }) as Promise; } -/** Handler that by default will check all new shards are online in the new gateway. The handler can be overriden if you have multiple servers to communicate through redis pubsub or whatever you prefer. */ +/** Handler that by default will check all new shards are online in the new gateway. The handler can be overridden if you have multiple servers to communicate through redis pubsub or whatever you prefer. */ export async function resharderIsPending( gateway: GatewayManager, oldGateway: GatewayManager, @@ -98,7 +98,7 @@ export async function resharderIsPending( return false; } -/** Handler that by default closes all shards in the old gateway. Can be overriden if you have multiple servers and you want to communicate through redis pubsub or whatever you prefer. */ +/** Handler that by default closes all shards in the old gateway. Can be overridden if you have multiple servers and you want to communicate through redis pubsub or whatever you prefer. */ export async function resharderCloseOldShards(oldGateway: GatewayManager) { // SHUT DOWN ALL SHARDS IF NOTHING IN QUEUE oldGateway.shards.forEach((shard) => { @@ -122,7 +122,7 @@ export async function resharderCloseOldShards(oldGateway: GatewayManager) { }); } -/** Handler that by default will check to see if resharding should occur. Can be overriden if you have multiple servers and you want to communicate through redis pubsub or whatever you prefer. */ +/** Handler that by default will check to see if resharding should occur. Can be overridden if you have multiple servers and you want to communicate through redis pubsub or whatever you prefer. */ export async function startReshardingChecks(gateway: GatewayManager) { gateway.debug("GW DEBUG", "[Resharding] Checking if resharding is needed."); @@ -144,9 +144,9 @@ export async function startReshardingChecks(gateway: GatewayManager) { return gateway.resharding.resharder(gateway, results); } -/** Handler that by default will save the new shard id for each guild this becomes ready in new gateway. This can be overriden to save the shard ids in a redis cache layer or whatever you prefer. These ids will be used later to update all guilds. */ +/** Handler that by default will save the new shard id for each guild this becomes ready in new gateway. This can be overridden to save the shard ids in a redis cache layer or whatever you prefer. These ids will be used later to update all guilds. */ export async function markNewGuildShardId(guildIds: bigint[], shardId: number) { - // PLACEHOLDER TO LET YOU MARK A GUILD ID AND SHARDID FOR LATER USE ONCE RESHARDED + // PLACEHOLDER TO LET YOU MARK A GUILD ID AND SHARD ID FOR LATER USE ONCE RESHARDED } /** Handler that by default does not do anything since by default the library will not cache. */ diff --git a/gateway/shard.ts b/gateway/shard.ts index 188cd46bf..1b9d3ae26 100644 --- a/gateway/shard.ts +++ b/gateway/shard.ts @@ -30,7 +30,7 @@ export interface DiscordenoShard { /** The id of the interval, useful for stopping the interval if ws closed. */ intervalId: number; }; - /** The items/requestst that are in queue to be sent to this shard websocket. */ + /** The items/requests that are in queue to be sent to this shard websocket. */ queue: WebSocketRequest[]; /** Whether or not the queue for this shard is being processed. */ processingQueue: boolean; diff --git a/helpers/channels/createChannel.ts b/helpers/channels/createChannel.ts index 22c5d6cf3..4d5306bdf 100644 --- a/helpers/channels/createChannel.ts +++ b/helpers/channels/createChannel.ts @@ -5,7 +5,7 @@ import { OverwriteReadable } from "./editChannelOverwrite.ts"; /** Create a channel in your server. Bot needs MANAGE_CHANNEL permissions in the server. */ export async function createChannel(bot: Bot, guildId: bigint, options?: CreateGuildChannel, reason?: string) { - // BITRATES ARE IN THOUSANDS SO IF USER PROVIDES 32 WE CONVERT TO 32000 + // BITRATE IS IN THOUSANDS SO IF USER PROVIDES 32 WE CONVERT TO 32000 if (options?.bitrate && options.bitrate < 1000) options.bitrate *= 1000; const result = await bot.rest.runMethod( diff --git a/helpers/channels/editChannel.ts b/helpers/channels/editChannel.ts index d62e3ba00..b15defca4 100644 --- a/helpers/channels/editChannel.ts +++ b/helpers/channels/editChannel.ts @@ -9,7 +9,7 @@ export async function editChannel(bot: Bot, channelId: bigint, options: ModifyCh if (options.name || options.topic) { const request = editChannelNameTopicQueue.get(channelId); if (!request) { - // If this hasnt been done before simply add 1 for it + // If this hasn't been done before simply add 1 for it editChannelNameTopicQueue.set(channelId, { channelId: channelId, amount: 1, diff --git a/helpers/discovery/editDiscovery.ts b/helpers/discovery/editDiscovery.ts index d469ef6d9..86b9e0c88 100644 --- a/helpers/discovery/editDiscovery.ts +++ b/helpers/discovery/editDiscovery.ts @@ -33,7 +33,7 @@ export async function editDiscovery(bot: Bot, guildId: bigint, data: ModifyGuild export interface ModifyGuildDiscoveryMetadata { /** The id of the primary discovery category. Default: 0 */ primaryCategoryId?: number | null; - /** Up to 10 discovery search kekywords. Default: null */ + /** Up to 10 discovery search keywords. Default: null */ keywords?: string[] | null; /** Whether guild info is shown when custom emojis are clicked. Default: true */ emojiDiscoverabilityEnabled?: boolean | null; diff --git a/helpers/guilds/getAuditLogs.ts b/helpers/guilds/getAuditLogs.ts index 50b953eda..befc4c089 100644 --- a/helpers/guilds/getAuditLogs.ts +++ b/helpers/guilds/getAuditLogs.ts @@ -24,7 +24,7 @@ export async function getAuditLogs(bot: Bot, guildId: bigint, options?: GetGuild return { users: auditlog.users.map((user) => bot.transformers.user(bot, user)), webhook: auditlog.webhooks.map((hook) => bot.transformers.webhook(bot, hook)), - auditLogEntries: auditlog.audit_log_entries.map((entry) => bot.transformers.auditlogEntry(bot, entry)), + auditLogEntries: auditlog.audit_log_entries.map((entry) => bot.transformers.auditLogEntry(bot, entry)), integrations: auditlog.integrations.map((integration) => ({ id: integration.id ? bot.transformers.snowflake(integration.id) : undefined, name: integration.name, diff --git a/helpers/interactions/commands/editInteractionResponse.ts b/helpers/interactions/commands/editInteractionResponse.ts index f740ef01d..e4df9e9df 100644 --- a/helpers/interactions/commands/editInteractionResponse.ts +++ b/helpers/interactions/commands/editInteractionResponse.ts @@ -42,27 +42,27 @@ export async function editInteractionResponse( })), components: options.components?.map((component) => ({ type: component.type, - components: component.components.map((subcomponent) => { - if (subcomponent.type === MessageComponentTypes.InputText) { + components: component.components.map((subComponent) => { + if (subComponent.type === MessageComponentTypes.InputText) { return { - type: subcomponent.type, - style: subcomponent.style, - custom_id: subcomponent.customId, - label: subcomponent.label, - placeholder: subcomponent.placeholder, - min_length: subcomponent.minLength ?? subcomponent.required === false ? 0 : subcomponent.minLength, - max_length: subcomponent.maxLength, + type: subComponent.type, + style: subComponent.style, + custom_id: subComponent.customId, + label: subComponent.label, + placeholder: subComponent.placeholder, + min_length: subComponent.minLength ?? subComponent.required === false ? 0 : subComponent.minLength, + max_length: subComponent.maxLength, }; } - if (subcomponent.type === MessageComponentTypes.SelectMenu) { + if (subComponent.type === MessageComponentTypes.SelectMenu) { return { - type: subcomponent.type, - custom_id: subcomponent.customId, - placeholder: subcomponent.placeholder, - min_values: subcomponent.minValues, - max_values: subcomponent.maxValues, - options: subcomponent.options.map((option) => ({ + type: subComponent.type, + custom_id: subComponent.customId, + placeholder: subComponent.placeholder, + min_values: subComponent.minValues, + max_values: subComponent.maxValues, + options: subComponent.options.map((option) => ({ label: option.label, value: option.value, description: option.description, @@ -79,19 +79,19 @@ export async function editInteractionResponse( } return { - type: subcomponent.type, - custom_id: subcomponent.customId, - label: subcomponent.label, - style: subcomponent.style, - emoji: "emoji" in subcomponent && subcomponent.emoji + type: subComponent.type, + custom_id: subComponent.customId, + label: subComponent.label, + style: subComponent.style, + emoji: "emoji" in subComponent && subComponent.emoji ? { - id: subcomponent.emoji.id?.toString(), - name: subcomponent.emoji.name, - animated: subcomponent.emoji.animated, + id: subComponent.emoji.id?.toString(), + name: subComponent.emoji.name, + animated: subComponent.emoji.animated, } : undefined, - url: "url" in subcomponent ? subcomponent.url : undefined, - disabled: "disabled" in subcomponent ? subcomponent.disabled : undefined, + url: "url" in subComponent ? subComponent.url : undefined, + disabled: "disabled" in subComponent ? subComponent.disabled : undefined, }; }), })), diff --git a/helpers/interactions/followups/editFollowupMessage.ts b/helpers/interactions/followups/editFollowupMessage.ts index 086a91ced..02a309a1d 100644 --- a/helpers/interactions/followups/editFollowupMessage.ts +++ b/helpers/interactions/followups/editFollowupMessage.ts @@ -39,27 +39,27 @@ export async function editFollowupMessage( })), components: options.components?.map((component) => ({ type: component.type, - components: component.components.map((subcomponent) => { - if (subcomponent.type === MessageComponentTypes.InputText) { + components: component.components.map((subComponent) => { + if (subComponent.type === MessageComponentTypes.InputText) { return { - type: subcomponent.type, - style: subcomponent.style, - custom_id: subcomponent.customId, - label: subcomponent.label, - placeholder: subcomponent.placeholder, - min_length: subcomponent.minLength ?? subcomponent.required === false ? 0 : subcomponent.minLength, - max_length: subcomponent.maxLength, + type: subComponent.type, + style: subComponent.style, + custom_id: subComponent.customId, + label: subComponent.label, + placeholder: subComponent.placeholder, + min_length: subComponent.minLength ?? subComponent.required === false ? 0 : subComponent.minLength, + max_length: subComponent.maxLength, }; } - if (subcomponent.type === MessageComponentTypes.SelectMenu) { + if (subComponent.type === MessageComponentTypes.SelectMenu) { return { - type: subcomponent.type, - custom_id: subcomponent.customId, - placeholder: subcomponent.placeholder, - min_values: subcomponent.minValues, - max_values: subcomponent.maxValues, - options: subcomponent.options.map((option) => ({ + type: subComponent.type, + custom_id: subComponent.customId, + placeholder: subComponent.placeholder, + min_values: subComponent.minValues, + max_values: subComponent.maxValues, + options: subComponent.options.map((option) => ({ label: option.label, value: option.value, description: option.description, @@ -76,19 +76,19 @@ export async function editFollowupMessage( } return { - type: subcomponent.type, - custom_id: subcomponent.customId, - label: subcomponent.label, - style: subcomponent.style, - emoji: subcomponent.emoji + type: subComponent.type, + custom_id: subComponent.customId, + label: subComponent.label, + style: subComponent.style, + emoji: subComponent.emoji ? { - id: subcomponent.emoji.id?.toString(), - name: subcomponent.emoji.name, - animated: subcomponent.emoji.animated, + id: subComponent.emoji.id?.toString(), + name: subComponent.emoji.name, + animated: subComponent.emoji.animated, } : undefined, - url: subcomponent.url, - disabled: subcomponent.disabled, + url: subComponent.url, + disabled: subComponent.disabled, }; }), })), diff --git a/helpers/interactions/sendInteractionResponse.ts b/helpers/interactions/sendInteractionResponse.ts index f75dcbe6a..f1b953453 100644 --- a/helpers/interactions/sendInteractionResponse.ts +++ b/helpers/interactions/sendInteractionResponse.ts @@ -37,27 +37,27 @@ export async function sendInteractionResponse( title: options.data.title, components: options.data.components?.map((component) => ({ type: component.type, - components: component.components.map((subcomponent) => { - if (subcomponent.type === MessageComponentTypes.InputText) { + components: component.components.map((subComponent) => { + if (subComponent.type === MessageComponentTypes.InputText) { return { - type: subcomponent.type, - style: subcomponent.style, - custom_id: subcomponent.customId, - label: subcomponent.label, - placeholder: subcomponent.placeholder, - min_length: subcomponent.minLength ?? subcomponent.required === false ? 0 : subcomponent.minLength, - max_length: subcomponent.maxLength, + type: subComponent.type, + style: subComponent.style, + custom_id: subComponent.customId, + label: subComponent.label, + placeholder: subComponent.placeholder, + min_length: subComponent.minLength ?? subComponent.required === false ? 0 : subComponent.minLength, + max_length: subComponent.maxLength, }; } - if (subcomponent.type === MessageComponentTypes.SelectMenu) { + if (subComponent.type === MessageComponentTypes.SelectMenu) { return { - type: subcomponent.type, - custom_id: subcomponent.customId, - placeholder: subcomponent.placeholder, - min_values: subcomponent.minValues, - max_values: subcomponent.maxValues, - options: subcomponent.options.map((option) => ({ + type: subComponent.type, + custom_id: subComponent.customId, + placeholder: subComponent.placeholder, + min_values: subComponent.minValues, + max_values: subComponent.maxValues, + options: subComponent.options.map((option) => ({ label: option.label, value: option.value, description: option.description, @@ -74,19 +74,19 @@ export async function sendInteractionResponse( } return { - type: subcomponent.type, - custom_id: subcomponent.customId, - label: subcomponent.label, - style: subcomponent.style, - emoji: "emoji" in subcomponent && subcomponent.emoji + type: subComponent.type, + custom_id: subComponent.customId, + label: subComponent.label, + style: subComponent.style, + emoji: "emoji" in subComponent && subComponent.emoji ? { - id: subcomponent.emoji.id?.toString(), - name: subcomponent.emoji.name, - animated: subcomponent.emoji.animated, + id: subComponent.emoji.id?.toString(), + name: subComponent.emoji.name, + animated: subComponent.emoji.animated, } : undefined, - url: "url" in subcomponent ? subcomponent.url : undefined, - disabled: "disabled" in subcomponent ? subcomponent.disabled : undefined, + url: "url" in subComponent ? subComponent.url : undefined, + disabled: "disabled" in subComponent ? subComponent.disabled : undefined, }; }), })), @@ -130,7 +130,7 @@ export interface InteractionResponse { export interface InteractionApplicationCommandCallbackData { /** The message contents (up to 2000 characters) */ content?: string; - /** true if this is a TTS message */ + /** True if this is a TTS message */ tts?: boolean; /** Embedded `rich` content (up to 6000 characters) */ embeds?: Embed[]; @@ -144,9 +144,9 @@ export interface InteractionApplicationCommandCallbackData { title?: string; /** The components you would like to have sent in this message */ components?: MessageComponents; - /** message flags combined as a bitfield (only SUPPRESS_EMBEDS and EPHEMERAL can be set) */ + /** Message flags combined as a bit field (only SUPPRESS_EMBEDS and EPHEMERAL can be set) */ flags?: number; - /** autocomplete choices (max of 25 choices) */ + /** Autocomplete choices (max of 25 choices) */ choices?: ApplicationCommandOptionChoice[]; } diff --git a/helpers/invites/createInvite.ts b/helpers/invites/createInvite.ts index fa85aff66..03dabb428 100644 --- a/helpers/invites/createInvite.ts +++ b/helpers/invites/createInvite.ts @@ -42,7 +42,7 @@ export interface CreateChannelInvite { maxUses?: number; /** Whether this invite only grants temporary membership. Default: false */ temporary?: boolean; - /** If true, don't try to reuse simmilar invite (useful for creating many unique one time use invites). Default: false */ + /** If true, don't try to reuse similar invite (useful for creating many unique one time use invites). Default: false */ unique?: boolean; /** The type of target for this voice channel invite */ targetType?: InviteTargetTypes; diff --git a/helpers/messages/editMessage.ts b/helpers/messages/editMessage.ts index 442d60947..c93d87110 100644 --- a/helpers/messages/editMessage.ts +++ b/helpers/messages/editMessage.ts @@ -33,27 +33,27 @@ export async function editMessage(bot: Bot, channelId: bigint, messageId: bigint file: content.file, components: content.components?.map((component) => ({ type: component.type, - components: component.components.map((subcomponent) => { - if (subcomponent.type === MessageComponentTypes.InputText) { + components: component.components.map((subComponent) => { + if (subComponent.type === MessageComponentTypes.InputText) { return { - type: subcomponent.type, - style: subcomponent.style, - custom_id: subcomponent.customId, - label: subcomponent.label, - placeholder: subcomponent.placeholder, - min_length: subcomponent.minLength ?? subcomponent.required === false ? 0 : subcomponent.minLength, - max_length: subcomponent.maxLength, + type: subComponent.type, + style: subComponent.style, + custom_id: subComponent.customId, + label: subComponent.label, + placeholder: subComponent.placeholder, + min_length: subComponent.minLength ?? subComponent.required === false ? 0 : subComponent.minLength, + max_length: subComponent.maxLength, }; } - if (subcomponent.type === MessageComponentTypes.SelectMenu) { + if (subComponent.type === MessageComponentTypes.SelectMenu) { return { - type: subcomponent.type, - custom_id: subcomponent.customId, - placeholder: subcomponent.placeholder, - min_values: subcomponent.minValues, - max_values: subcomponent.maxValues, - options: subcomponent.options.map((option) => ({ + type: subComponent.type, + custom_id: subComponent.customId, + placeholder: subComponent.placeholder, + min_values: subComponent.minValues, + max_values: subComponent.maxValues, + options: subComponent.options.map((option) => ({ label: option.label, value: option.value, description: option.description, @@ -70,19 +70,19 @@ export async function editMessage(bot: Bot, channelId: bigint, messageId: bigint } return { - type: subcomponent.type, - custom_id: subcomponent.customId, - label: subcomponent.label, - style: subcomponent.style, - emoji: "emoji" in subcomponent && subcomponent.emoji + type: subComponent.type, + custom_id: subComponent.customId, + label: subComponent.label, + style: subComponent.style, + emoji: "emoji" in subComponent && subComponent.emoji ? { - id: subcomponent.emoji.id?.toString(), - name: subcomponent.emoji.name, - animated: subcomponent.emoji.animated, + id: subComponent.emoji.id?.toString(), + name: subComponent.emoji.name, + animated: subComponent.emoji.animated, } : undefined, - url: "url" in subcomponent ? subcomponent.url : undefined, - disabled: "disabled" in subcomponent ? subcomponent.disabled : undefined, + url: "url" in subComponent ? subComponent.url : undefined, + disabled: "disabled" in subComponent ? subComponent.disabled : undefined, }; }), })), @@ -98,7 +98,7 @@ export interface EditMessage { content?: string | null; /** Embedded `rich` content (up to 6000 characters) */ embeds?: Embed[] | null; - /** Edit the flags of the message (only `SUPRESS_EMBEDS` can currently be set/unset) */ + /** Edit the flags of the message (only `SUPPRESS_EMBEDS` can currently be set/unset) */ flags?: 4 | null; /** The contents of the file being sent/edited */ file?: FileContent | FileContent[] | null; diff --git a/helpers/messages/sendMessage.ts b/helpers/messages/sendMessage.ts index 9e99d471a..040cfe5c8 100644 --- a/helpers/messages/sendMessage.ts +++ b/helpers/messages/sendMessage.ts @@ -25,27 +25,27 @@ export async function sendMessage(bot: Bot, channelId: bigint, content: CreateMe file: content.file, components: content.components?.map((component) => ({ type: component.type, - components: component.components.map((subcomponent) => { - if (subcomponent.type === MessageComponentTypes.InputText) { + components: component.components.map((subComponent) => { + if (subComponent.type === MessageComponentTypes.InputText) { return { - type: subcomponent.type, - style: subcomponent.style, - custom_id: subcomponent.customId, - label: subcomponent.label, - placeholder: subcomponent.placeholder, - min_length: subcomponent.minLength ?? subcomponent.required === false ? 0 : subcomponent.minLength, - max_length: subcomponent.maxLength, + type: subComponent.type, + style: subComponent.style, + custom_id: subComponent.customId, + label: subComponent.label, + placeholder: subComponent.placeholder, + min_length: subComponent.minLength ?? subComponent.required === false ? 0 : subComponent.minLength, + max_length: subComponent.maxLength, }; } - if (subcomponent.type === MessageComponentTypes.SelectMenu) { + if (subComponent.type === MessageComponentTypes.SelectMenu) { return { - type: subcomponent.type, - custom_id: subcomponent.customId, - placeholder: subcomponent.placeholder, - min_values: subcomponent.minValues, - max_values: subcomponent.maxValues, - options: subcomponent.options.map((option) => ({ + type: subComponent.type, + custom_id: subComponent.customId, + placeholder: subComponent.placeholder, + min_values: subComponent.minValues, + max_values: subComponent.maxValues, + options: subComponent.options.map((option) => ({ label: option.label, value: option.value, description: option.description, @@ -62,19 +62,19 @@ export async function sendMessage(bot: Bot, channelId: bigint, content: CreateMe } return { - type: subcomponent.type, - custom_id: subcomponent.customId, - label: subcomponent.label, - style: subcomponent.style, - emoji: "emoji" in subcomponent && subcomponent.emoji + type: subComponent.type, + custom_id: subComponent.customId, + label: subComponent.label, + style: subComponent.style, + emoji: "emoji" in subComponent && subComponent.emoji ? { - id: subcomponent.emoji.id?.toString(), - name: subcomponent.emoji.name, - animated: subcomponent.emoji.animated, + id: subComponent.emoji.id?.toString(), + name: subComponent.emoji.name, + animated: subComponent.emoji.animated, } : undefined, - url: "url" in subcomponent ? subcomponent.url : undefined, - disabled: "disabled" in subcomponent ? subcomponent.disabled : undefined, + url: "url" in subComponent ? subComponent.url : undefined, + disabled: "disabled" in subComponent ? subComponent.disabled : undefined, }; }), })), diff --git a/helpers/webhooks/editWebhookMessage.ts b/helpers/webhooks/editWebhookMessage.ts index e0b0b1ff8..98d5a15e4 100644 --- a/helpers/webhooks/editWebhookMessage.ts +++ b/helpers/webhooks/editWebhookMessage.ts @@ -45,27 +45,27 @@ export async function editWebhookMessage( })), components: options.components?.map((component) => ({ type: component.type, - components: component.components.map((subcomponent) => { - if (subcomponent.type === MessageComponentTypes.InputText) { + components: component.components.map((subComponent) => { + if (subComponent.type === MessageComponentTypes.InputText) { return { - type: subcomponent.type, - style: subcomponent.style, - custom_id: subcomponent.customId, - label: subcomponent.label, - placeholder: subcomponent.placeholder, - min_length: subcomponent.minLength ?? subcomponent.required === false ? 0 : subcomponent.minLength, - max_length: subcomponent.maxLength, + type: subComponent.type, + style: subComponent.style, + custom_id: subComponent.customId, + label: subComponent.label, + placeholder: subComponent.placeholder, + min_length: subComponent.minLength ?? subComponent.required === false ? 0 : subComponent.minLength, + max_length: subComponent.maxLength, }; } - if (subcomponent.type === MessageComponentTypes.SelectMenu) { + if (subComponent.type === MessageComponentTypes.SelectMenu) { return { - type: subcomponent.type, - custom_id: subcomponent.customId, - placeholder: subcomponent.placeholder, - min_values: subcomponent.minValues, - max_values: subcomponent.maxValues, - options: subcomponent.options.map((option) => ({ + type: subComponent.type, + custom_id: subComponent.customId, + placeholder: subComponent.placeholder, + min_values: subComponent.minValues, + max_values: subComponent.maxValues, + options: subComponent.options.map((option) => ({ label: option.label, value: option.value, description: option.description, @@ -82,19 +82,19 @@ export async function editWebhookMessage( } return { - type: subcomponent.type, - custom_id: subcomponent.customId, - label: subcomponent.label, - style: subcomponent.style, - emoji: "emoji" in subcomponent && subcomponent.emoji + type: subComponent.type, + custom_id: subComponent.customId, + label: subComponent.label, + style: subComponent.style, + emoji: "emoji" in subComponent && subComponent.emoji ? { - id: subcomponent.emoji.id?.toString(), - name: subcomponent.emoji.name, - animated: subcomponent.emoji.animated, + id: subComponent.emoji.id?.toString(), + name: subComponent.emoji.name, + animated: subComponent.emoji.animated, } : undefined, - url: "url" in subcomponent ? subcomponent.url : undefined, - disabled: "disabled" in subcomponent ? subcomponent.disabled : undefined, + url: "url" in subComponent ? subComponent.url : undefined, + disabled: "disabled" in subComponent ? subComponent.disabled : undefined, }; }), })), diff --git a/plugins/cache/src/setupCacheRemovals.ts b/plugins/cache/src/setupCacheRemovals.ts index 8410f511f..9ce971749 100644 --- a/plugins/cache/src/setupCacheRemovals.ts +++ b/plugins/cache/src/setupCacheRemovals.ts @@ -43,7 +43,7 @@ export function setupCacheRemovals(bot: BotWithCache) { bot.handlers.CHANNEL_DELETE = function (_, data, shardId) { const payload = data.d as DiscordChannel; - // HANDLER BEFORE DELETING, BECAUSE HANDLER RUNS TRANSFORMER WHICH RECACHES + // HANDLER BEFORE DELETING, BECAUSE HANDLER RUNS TRANSFORMER WHICH REACHES CHANNEL_DELETE(bot, data, shardId); const id = bot.transformers.snowflake(payload.id); diff --git a/plugins/cache/src/sweepers.ts b/plugins/cache/src/sweepers.ts index 908446976..064e17e7b 100644 --- a/plugins/cache/src/sweepers.ts +++ b/plugins/cache/src/sweepers.ts @@ -9,7 +9,7 @@ export function enableCacheSweepers(bot: BotWithCache) { // Reset activity for next interval if (bot.activeGuildIds.delete(guild.id)) return false; - // This is inactive guild. Not a single thing has happened for atleast 30 minutes. + // This is inactive guild. Not a single thing has happened for at least 30 minutes. // Not a reaction, not a message, not any event! bot.dispatchedGuildIds.add(guild.id); diff --git a/plugins/fileloader/README.md b/plugins/fileloader/README.md index 46d037d59..b82f8ea26 100644 --- a/plugins/fileloader/README.md +++ b/plugins/fileloader/README.md @@ -29,4 +29,4 @@ bot.fastFileLoader([ startBot(bot); ``` -Make sure to ignore `fileloader.ts` in git as it is (re)generated whever you (re)start the bot. +Make sure to ignore `fileloader.ts` in git as it is (re)generated where you (re)start the bot. diff --git a/plugins/helpers/src/sendDirectMessage.ts b/plugins/helpers/src/sendDirectMessage.ts index 529d3ee5a..f4e5c9b2f 100644 --- a/plugins/helpers/src/sendDirectMessage.ts +++ b/plugins/helpers/src/sendDirectMessage.ts @@ -16,7 +16,7 @@ export async function sendDirectMessage( // IF ID IS CACHED SEND MESSAGE DIRECTLY if (cachedChannelId) return bot.helpers.sendMessage(cachedChannelId, content); - // CREATE A NEW DM CHANNEL AND PULCK ITS ID + // CREATE A NEW DM CHANNEL AND PLUCK ITS ID const channel = (await bot.helpers.getDmChannel(userId)); // CACHE IT FOR FUTURE REQUESTS diff --git a/plugins/permissions/src/components.ts b/plugins/permissions/src/components.ts index 072c196ab..8734173b7 100644 --- a/plugins/permissions/src/components.ts +++ b/plugins/permissions/src/components.ts @@ -15,92 +15,92 @@ export function validateComponents(bot: Bot, components: MessageComponents) { throw new Error("Too many components."); } else if ( component.components?.length > 1 && - component.components.some((subcomponent) => subcomponent.type === MessageComponentTypes.SelectMenu) + component.components.some((subComponent) => subComponent.type === MessageComponentTypes.SelectMenu) ) { throw new Error("Select component must be alone."); } - for (const subcomponent of component.components) { + for (const subComponent of component.components) { if ( - subcomponent.customId && - !bot.utils.validateLength(subcomponent.customId, { max: 100 }) + subComponent.customId && + !bot.utils.validateLength(subComponent.customId, { max: 100 }) ) { throw new Error("The custom id in the component is too big."); } // 5 Link buttons can not have a customId - if (subcomponent.type === MessageComponentTypes.Button) { - if (subcomponent.style === ButtonStyles.Link && subcomponent.customId) { + if (subComponent.type === MessageComponentTypes.Button) { + if (subComponent.style === ButtonStyles.Link && subComponent.customId) { throw new Error("Link buttons can not have custom ids."); } // Other buttons must have a customId if ( - !subcomponent.customId && subcomponent.style !== ButtonStyles.Link + !subComponent.customId && subComponent.style !== ButtonStyles.Link ) { throw new Error( "The button requires a custom id if it is not a link button.", ); } - if (!bot.utils.validateLength(subcomponent.label, { max: 80 })) { + if (!bot.utils.validateLength(subComponent.label, { max: 80 })) { throw new Error("The label can not be longer than 80 characters."); } - subcomponent.emoji = makeEmojiFromString(subcomponent.emoji); + subComponent.emoji = makeEmojiFromString(subComponent.emoji); } - if (subcomponent.type === MessageComponentTypes.SelectMenu) { + if (subComponent.type === MessageComponentTypes.SelectMenu) { if ( - subcomponent.placeholder && - !bot.utils.validateLength(subcomponent.placeholder, { max: 150 }) + subComponent.placeholder && + !bot.utils.validateLength(subComponent.placeholder, { max: 150 }) ) { throw new Error( "The component placeholder can not be longer than 150 characters.", ); } - if (subcomponent.minValues) { - if (subcomponent.minValues < 1) { + if (subComponent.minValues) { + if (subComponent.minValues < 1) { throw new Error( "The min values must be more than 1 in a select component.", ); } - if (subcomponent.minValues > 25) { + if (subComponent.minValues > 25) { throw new Error( "The min values must be less than 25 in a select component.", ); } - if (!subcomponent.maxValues) { - subcomponent.maxValues = subcomponent.minValues; + if (!subComponent.maxValues) { + subComponent.maxValues = subComponent.minValues; } - if (subcomponent.minValues > subcomponent.maxValues) { + if (subComponent.minValues > subComponent.maxValues) { throw new Error( "The select component can not have a min values higher than a max values.", ); } } - if (subcomponent.maxValues) { - if (subcomponent.maxValues < 1) { + if (subComponent.maxValues) { + if (subComponent.maxValues < 1) { throw new Error( "The max values must be more than 1 in a select component.", ); } - if (subcomponent.maxValues > 25) { + if (subComponent.maxValues > 25) { throw new Error( "The max values must be less than 25 in a select component.", ); } } - if (subcomponent.options.length < 1) { - throw new Error("You need atleast 1 option in the select component."); + if (subComponent.options.length < 1) { + throw new Error("You need at least 1 option in the select component."); } - if (subcomponent.options.length > 25) { + if (subComponent.options.length > 25) { throw new Error( "You can not have more than 25 options in the select component.", ); @@ -108,10 +108,10 @@ export function validateComponents(bot: Bot, components: MessageComponents) { let defaults = 0; - for (const option of subcomponent.options) { + for (const option of subComponent.options) { if (option.default) { defaults++; - if (defaults > (subcomponent.maxValues || 25)) { + if (defaults > (subComponent.maxValues || 25)) { throw new Error("You chose too many default options."); } } diff --git a/plugins/permissions/src/permissions.ts b/plugins/permissions/src/permissions.ts index c7daedb12..36fde90d6 100644 --- a/plugins/permissions/src/permissions.ts +++ b/plugins/permissions/src/permissions.ts @@ -23,7 +23,7 @@ export function calculateBasePermissions( if (!guild || !member) return 8n; let permissions = 0n; - // Calculate the role permissions bits, @everyone role is not in memberRoleIds so we need to pass guildId manualy + // Calculate the role permissions bits, @everyone role is not in memberRoleIds so we need to pass guildId manually permissions |= [...member.roles, guild.id] .map((id) => guild.roles.get(id)?.permissions) // Removes any edge case undefined @@ -211,13 +211,13 @@ export function getMissingChannelPermissions( member: bigint | Member, permissions: PermissionStrings[], ) { - // First we need the role permissino bits this member has + // First we need the role permission bits this member has const permissionBits = calculateChannelOverwrites( bot, channel, member, ); - // Second returnn the members missing permissions + // Second return the members missing permissions return missingPermissions(permissionBits, permissions); } diff --git a/rest/checkRateLimits.ts b/rest/checkRateLimits.ts index 2cf75d568..00ea29fad 100644 --- a/rest/checkRateLimits.ts +++ b/rest/checkRateLimits.ts @@ -2,8 +2,8 @@ import { RestManager } from "../bot.ts"; /** Check the rate limits for a url or a bucket. */ export function checkRateLimits(rest: RestManager, url: string) { - const ratelimited = rest.ratelimitedPaths.get(url); - const global = rest.ratelimitedPaths.get("global"); + const ratelimited = rest.rateLimitedPaths.get(url); + const global = rest.rateLimitedPaths.get("global"); const now = Date.now(); if (ratelimited && now < ratelimited.resetTimestamp) { diff --git a/rest/processGlobalQueue.ts b/rest/processGlobalQueue.ts index 23bb5c4ec..72f071aed 100644 --- a/rest/processGlobalQueue.ts +++ b/rest/processGlobalQueue.ts @@ -11,7 +11,7 @@ export async function processGlobalQueue(rest: RestManager) { rest.globalQueueProcessing = true; while (rest.globalQueue.length) { - // IF THE BOT IS GLOBALLY RATELIMITED TRY AGAIN + // IF THE BOT IS GLOBALLY RATE LIMITED TRY AGAIN if (rest.globallyRateLimited) { setTimeout(() => { rest.debug(`[REST - processGlobalQueue] Globally rate limited, running setTimeout.`); @@ -41,7 +41,7 @@ export async function processGlobalQueue(rest: RestManager) { // REMOVES ANY POTENTIAL INVALID CONFLICTS if (!request) continue; - // CHECK RATELIMITS FOR 429 REPEATS + // CHECK RATE LIMITS FOR 429 REPEATS // IF THIS URL IS STILL RATE LIMITED, TRY AGAIN const urlResetIn = rest.checkRateLimits(rest, request.basicURL); // IF A BUCKET EXISTS, CHECK THE BUCKET'S RATE LIMITS diff --git a/rest/processQueue.ts b/rest/processQueue.ts index 052d62111..18d7ebafe 100644 --- a/rest/processQueue.ts +++ b/rest/processQueue.ts @@ -9,7 +9,7 @@ export function processQueue(rest: RestManager, id: string) { rest.debug(`[REST - processQueue] Running while loop.`); // SELECT THE FIRST ITEM FROM THIS QUEUE const queuedRequest = queue.requests[0]; - // IF THIS DOESNT HAVE ANY ITEMS JUST CANCEL, THE CLEANER WILL REMOVE IT. + // IF THIS DOESN'T HAVE ANY ITEMS JUST CANCEL, THE CLEANER WILL REMOVE IT. if (!queuedRequest) break; const basicURL = rest.simplifyUrl(queuedRequest.request.url, queuedRequest.request.method.toUpperCase()); @@ -37,7 +37,7 @@ export function processQueue(rest: RestManager, id: string) { const bucketResetIn = queuedRequest.payload.bucketId ? rest.checkRateLimits(rest, queuedRequest.payload.bucketId) : false; - // THIS BUCKET IS STILL RATELIMITED, RE-ADD TO QUEUE + // THIS BUCKET IS STILL RATE LIMITED, RE-ADD TO QUEUE if (bucketResetIn) continue; // EXECUTE THE REQUEST diff --git a/rest/processRateLimitedPaths.ts b/rest/processRateLimitedPaths.ts index 59ea29729..a9aa77de4 100644 --- a/rest/processRateLimitedPaths.ts +++ b/rest/processRateLimitedPaths.ts @@ -4,19 +4,19 @@ import { RestManager } from "../bot.ts"; export function processRateLimitedPaths(rest: RestManager) { const now = Date.now(); - for (const [key, value] of rest.ratelimitedPaths.entries()) { + for (const [key, value] of rest.rateLimitedPaths.entries()) { rest.debug(`[REST - processRateLimitedPaths] Running for of loop. ${value.resetTimestamp - now}`); // IF THE TIME HAS NOT REACHED CANCEL if (value.resetTimestamp > now) continue; // RATE LIMIT IS OVER, DELETE THE RATE LIMITER - rest.ratelimitedPaths.delete(key); + rest.rateLimitedPaths.delete(key); // IF IT WAS GLOBAL ALSO MARK THE GLOBAL VALUE AS FALSE if (key === "global") rest.globallyRateLimited = false; } // ALL PATHS ARE CLEARED CAN CANCEL OUT! - if (!rest.ratelimitedPaths.size) { + if (!rest.rateLimitedPaths.size) { rest.processingRateLimitedPaths = false; } else { rest.processingRateLimitedPaths = true; diff --git a/rest/processRequestHeaders.ts b/rest/processRequestHeaders.ts index a69302f6c..7184afca1 100644 --- a/rest/processRequestHeaders.ts +++ b/rest/processRequestHeaders.ts @@ -1,8 +1,8 @@ import { RestManager } from "../bot.ts"; -/** Processes the rate limit headers and determines if it needs to be ratelimited and returns the bucket id if available */ +/** Processes the rate limit headers and determines if it needs to be rate limited and returns the bucket id if available */ export function processRequestHeaders(rest: RestManager, url: string, headers: Headers) { - let ratelimited = false; + let rateLimited = false; // GET ALL NECESSARY HEADERS const remaining = headers.get("x-ratelimit-remaining"); @@ -14,10 +14,10 @@ export function processRequestHeaders(rest: RestManager, url: string, headers: H // IF THERE IS NO REMAINING RATE LIMIT, MARK IT AS RATE LIMITED if (remaining === "0") { - ratelimited = true; + rateLimited = true; // SAVE THE URL AS LIMITED, IMPORTANT FOR NEW REQUESTS BY USER WITHOUT BUCKET - rest.ratelimitedPaths.set(url, { + rest.rateLimitedPaths.set(url, { url, resetTimestamp: reset, bucketId, @@ -25,7 +25,7 @@ export function processRequestHeaders(rest: RestManager, url: string, headers: H // SAVE THE BUCKET AS LIMITED SINCE DIFFERENT URLS MAY SHARE A BUCKET if (bucketId) { - rest.ratelimitedPaths.set(bucketId, { + rest.rateLimitedPaths.set(bucketId, { url, resetTimestamp: reset, bucketId, @@ -39,16 +39,16 @@ export function processRequestHeaders(rest: RestManager, url: string, headers: H const globalReset = Date.now() + Number(retryAfter) * 1000; rest.debug(`[REST = Globally Rate Limited] URL: ${url} | Global Rest: ${globalReset}`); rest.globallyRateLimited = true; - ratelimited = true; + rateLimited = true; - rest.ratelimitedPaths.set("global", { + rest.rateLimitedPaths.set("global", { url: "global", resetTimestamp: globalReset, bucketId, }); if (bucketId) { - rest.ratelimitedPaths.set(bucketId, { + rest.rateLimitedPaths.set(bucketId, { url: "global", resetTimestamp: globalReset, bucketId, @@ -56,8 +56,8 @@ export function processRequestHeaders(rest: RestManager, url: string, headers: H } } - if (ratelimited && !rest.processingRateLimitedPaths) { + if (rateLimited && !rest.processingRateLimitedPaths) { rest.processRateLimitedPaths(rest); } - return ratelimited ? bucketId : undefined; + return rateLimited ? bucketId : undefined; } diff --git a/rest/rest.ts b/rest/rest.ts index 94d47abaf..78ecd8f7f 100644 --- a/rest/rest.ts +++ b/rest/rest.ts @@ -27,7 +27,7 @@ export const rest = { processingQueue: false, processingRateLimitedPaths: false, globallyRateLimited: false, - ratelimitedPaths: new Map(), + rateLimitedPaths: new Map(), eventHandlers: { // BY DEFAULT WE WILL LOG ALL ERRORS TO CONSOLE. USER CAN CHOOSE TO OVERRIDE error: function (...args: unknown[]) {}, diff --git a/rest/restManager.ts b/rest/restManager.ts index 05cfc151c..77b932d53 100644 --- a/rest/restManager.ts +++ b/rest/restManager.ts @@ -58,7 +58,7 @@ export function createRestManager(options: CreateRestManagerOptions) { urlToUse: string; }[], globalQueueProcessing: false, - ratelimitedPaths: new Map(), + rateLimitedPaths: new Map(), debug: options.debug || function (_text: string) {}, checkRateLimits: options.checkRateLimits || checkRateLimits, cleanupQueues: options.cleanupQueues || cleanupQueues, diff --git a/rest/runMethod.ts b/rest/runMethod.ts index 5df9da574..559448be8 100644 --- a/rest/runMethod.ts +++ b/rest/runMethod.ts @@ -29,7 +29,7 @@ export async function runMethod( ); const errorStack = new Error("Location:"); - // @ts-ignore Breaks deno deploy. Luca said add tsignore until it's fixed + // @ts-ignore Breaks deno deploy. Luca said add ts-ignore until it's fixed Error.captureStackTrace(errorStack); // For proxies we don't need to do any of the legwork so we just forward the request diff --git a/rest/simplifyUrl.ts b/rest/simplifyUrl.ts index aee44d102..899a40a64 100644 --- a/rest/simplifyUrl.ts +++ b/rest/simplifyUrl.ts @@ -1,6 +1,6 @@ /** * Credits: github.com/abalabahaha/eris lib/rest/RequestHandler.js#L397 - * Modified for our usecase + * Modified for our use-case */ /** Split a url to separate rate limit buckets based on major/minor parameters. */ @@ -16,7 +16,7 @@ export function simplifyUrl(url: string, method: string) { route = route.substring(0, route.indexOf("/reactions") + "/reactions".length); } - // Delete Messsage endpoint has its own ratelimit + // Delete Message endpoint has its own rate limit if (method === "DELETE" && route.endsWith("/messages/skillzPrefersID")) { route = method + route; } diff --git a/template/beginner/src/utils/logger.ts b/template/beginner/src/utils/logger.ts index 01ce69034..d22b36a5b 100644 --- a/template/beginner/src/utils/logger.ts +++ b/template/beginner/src/utils/logger.ts @@ -1,7 +1,7 @@ // deno-lint-ignore-file no-explicit-any import { bold, cyan, gray, italic, red, yellow } from "../../deps.ts"; -export enum Loglevels { +export enum LogLevels { Debug, Info, Warn, @@ -9,31 +9,31 @@ export enum Loglevels { Fatal, } -const prefixes = new Map([ - [Loglevels.Debug, "DEBUG"], - [Loglevels.Info, "INFO"], - [Loglevels.Warn, "WARN"], - [Loglevels.Error, "ERROR"], - [Loglevels.Fatal, "FATAL"], +const prefixes = new Map([ + [LogLevels.Debug, "DEBUG"], + [LogLevels.Info, "INFO"], + [LogLevels.Warn, "WARN"], + [LogLevels.Error, "ERROR"], + [LogLevels.Fatal, "FATAL"], ]); const noColor: (str: string) => string = (msg) => msg; -const colorFunctions = new Map string>([ - [Loglevels.Debug, gray], - [Loglevels.Info, cyan], - [Loglevels.Warn, yellow], - [Loglevels.Error, (str: string) => red(str)], - [Loglevels.Fatal, (str: string) => red(bold(italic(str)))], +const colorFunctions = new Map string>([ + [LogLevels.Debug, gray], + [LogLevels.Info, cyan], + [LogLevels.Warn, yellow], + [LogLevels.Error, (str: string) => red(str)], + [LogLevels.Fatal, (str: string) => red(bold(italic(str)))], ]); export function logger({ - logLevel = Loglevels.Info, + logLevel = LogLevels.Info, name, }: { - logLevel?: Loglevels; + logLevel?: LogLevels; name?: string; } = {}) { - function log(level: Loglevels, ...args: any[]) { + function log(level: LogLevels, ...args: any[]) { if (level < logLevel) return; let color = colorFunctions.get(level); @@ -48,43 +48,43 @@ export function logger({ ]; switch (level) { - case Loglevels.Debug: + case LogLevels.Debug: return console.debug(...log); - case Loglevels.Info: + case LogLevels.Info: return console.info(...log); - case Loglevels.Warn: + case LogLevels.Warn: return console.warn(...log); - case Loglevels.Error: + case LogLevels.Error: return console.error(...log); - case Loglevels.Fatal: + case LogLevels.Fatal: return console.error(...log); default: return console.log(...log); } } - function setLevel(level: Loglevels) { + function setLevel(level: LogLevels) { logLevel = level; } function debug(...args: any[]) { - log(Loglevels.Debug, ...args); + log(LogLevels.Debug, ...args); } function info(...args: any[]) { - log(Loglevels.Info, ...args); + log(LogLevels.Info, ...args); } function warn(...args: any[]) { - log(Loglevels.Warn, ...args); + log(LogLevels.Warn, ...args); } function error(...args: any[]) { - log(Loglevels.Error, ...args); + log(LogLevels.Error, ...args); } function fatal(...args: any[]) { - log(Loglevels.Fatal, ...args); + log(LogLevels.Fatal, ...args); } return { diff --git a/template/bigbot/src/bot/events/interactions/executeSlashCommand.ts b/template/bigbot/src/bot/events/interactions/executeSlashCommand.ts index 4ab2e5efc..fce6ad042 100644 --- a/template/bigbot/src/bot/events/interactions/executeSlashCommand.ts +++ b/template/bigbot/src/bot/events/interactions/executeSlashCommand.ts @@ -74,7 +74,7 @@ export async function executeSlashCommand( // Load the language for this guild if (interaction.guildId && !serverLanguages.has(interaction.guildId)) { - // TODO: Check if this is deferable + // TODO: Check if this is deferrable await replyToInteraction(bot, interaction, { type: InteractionResponseTypes.DeferredChannelMessageWithSource, }); diff --git a/template/bigbot/src/bot/mod.ts b/template/bigbot/src/bot/mod.ts index 7090d2b0c..373a768ab 100644 --- a/template/bigbot/src/bot/mod.ts +++ b/template/bigbot/src/bot/mod.ts @@ -36,7 +36,7 @@ if (DEVELOPMENT) { logger.info(`[DEV MODE] Updating slash commands for dev server.`); await updateDevCommands(bot); } else { - // THIS WILL UPDATE ALL YOUR GLOBAL COMMANDS ON BOOTUP + // THIS WILL UPDATE ALL YOUR GLOBAL COMMANDS ON STARTUP // await updateGlobalCommands(bot); } @@ -87,7 +87,7 @@ async function handleRequest(conn: Deno.Conn) { bot.events.raw(bot, json.data, json.shardId); if (json.data.t && json.data.t !== "RESUMED") { - // When a guild or something isnt in cache this will fetch it before doing anything else + // When a guild or something isn't in cache this will fetch it before doing anything else if (!["READY", "GUILD_LOADED_DD"].includes(json.data.t)) { await bot.events.dispatchRequirements(bot, json.data, json.shardId); // WE ALSO WANT TO UPDATE GUILD SLASH IF NECESSARY AT THIS POINT diff --git a/template/bigbot/src/bot/types/command.ts b/template/bigbot/src/bot/types/command.ts index 2a7557940..d04cf1dba 100644 --- a/template/bigbot/src/bot/types/command.ts +++ b/template/bigbot/src/bot/types/command.ts @@ -251,7 +251,7 @@ export type ConvertArgumentDefinitionsToArgs< : // deno-lint-ignore ban-types {}; } - : // SUBCOMMANDGROUP + : // SUBCOMMAND GROUP T[P] extends SubcommandGroupArgumentDefinition ? { [_ in getName]?: ConvertArgumentDefinitionsToArgs< T[P]["options"] diff --git a/template/bigbot/src/utils/Components.ts b/template/bigbot/src/utils/Components.ts index 85f3100a8..4c0a3d9fc 100644 --- a/template/bigbot/src/utils/Components.ts +++ b/template/bigbot/src/utils/Components.ts @@ -36,7 +36,7 @@ export class Components extends Array { this.addActionRow(); row = this[this.length - 1]; - // Apperandly there are already 5 Full Action Rows so don't add the button + // Apparently there are already 5 Full Action Rows so don't add the button if (row.components.length === 5) return this; } diff --git a/template/bigbot/src/utils/helpers.ts b/template/bigbot/src/utils/helpers.ts index 4c36a8569..84570afde 100644 --- a/template/bigbot/src/utils/helpers.ts +++ b/template/bigbot/src/utils/helpers.ts @@ -117,12 +117,12 @@ export function stringToMilliseconds(text: string) { export function chunkStrings( array: string[], size = 2000, - lineSeperator = "\n", + lineSeparator = "\n", ) { const responses: string[] = []; let response = ""; for (const text of array) { - const nextText = response.length && lineSeperator ? `${lineSeperator}${text}` : text; + const nextText = response.length && lineSeparator ? `${lineSeparator}${text}` : text; if (response.length + nextText.length >= size) { responses.push(response); response = ""; diff --git a/template/bigbot/src/utils/logger.ts b/template/bigbot/src/utils/logger.ts index cada3af58..07c285672 100644 --- a/template/bigbot/src/utils/logger.ts +++ b/template/bigbot/src/utils/logger.ts @@ -1,7 +1,7 @@ // deno-lint-ignore-file no-explicit-any import { bold, cyan, gray, italic, red, yellow } from "../../deps.ts"; -export enum Loglevels { +export enum LogLevels { Debug, Info, Warn, @@ -9,31 +9,31 @@ export enum Loglevels { Fatal, } -const prefixes = new Map([ - [Loglevels.Debug, "DEBUG"], - [Loglevels.Info, "INFO"], - [Loglevels.Warn, "WARN"], - [Loglevels.Error, "ERROR"], - [Loglevels.Fatal, "FATAL"], +const prefixes = new Map([ + [LogLevels.Debug, "DEBUG"], + [LogLevels.Info, "INFO"], + [LogLevels.Warn, "WARN"], + [LogLevels.Error, "ERROR"], + [LogLevels.Fatal, "FATAL"], ]); const noColor: (str: string) => string = (msg) => msg; -const colorFunctions = new Map string>([ - [Loglevels.Debug, gray], - [Loglevels.Info, cyan], - [Loglevels.Warn, yellow], - [Loglevels.Error, (str: string) => red(str)], - [Loglevels.Fatal, (str: string) => red(bold(italic(str)))], +const colorFunctions = new Map string>([ + [LogLevels.Debug, gray], + [LogLevels.Info, cyan], + [LogLevels.Warn, yellow], + [LogLevels.Error, (str: string) => red(str)], + [LogLevels.Fatal, (str: string) => red(bold(italic(str)))], ]); export function logger({ - logLevel = Loglevels.Info, + logLevel = LogLevels.Info, name, }: { - logLevel?: Loglevels; + logLevel?: LogLevels; name?: string; } = {}) { - function log(level: Loglevels, ...args: any[]) { + function log(level: LogLevels, ...args: any[]) { if (level < logLevel) return; let color = colorFunctions.get(level); @@ -48,43 +48,43 @@ export function logger({ ]; switch (level) { - case Loglevels.Debug: + case LogLevels.Debug: return console.debug(...log); - case Loglevels.Info: + case LogLevels.Info: return console.info(...log); - case Loglevels.Warn: + case LogLevels.Warn: return console.warn(...log); - case Loglevels.Error: + case LogLevels.Error: return console.error(...log); - case Loglevels.Fatal: + case LogLevels.Fatal: return console.error(...log); default: return console.log(...log); } } - function setLevel(level: Loglevels) { + function setLevel(level: LogLevels) { logLevel = level; } function debug(...args: any[]) { - log(Loglevels.Debug, ...args); + log(LogLevels.Debug, ...args); } function info(...args: any[]) { - log(Loglevels.Info, ...args); + log(LogLevels.Info, ...args); } function warn(...args: any[]) { - log(Loglevels.Warn, ...args); + log(LogLevels.Warn, ...args); } function error(...args: any[]) { - log(Loglevels.Error, ...args); + log(LogLevels.Error, ...args); } function fatal(...args: any[]) { - log(Loglevels.Fatal, ...args); + log(LogLevels.Fatal, ...args); } return { diff --git a/template/bigbot/src/utils/options.ts b/template/bigbot/src/utils/options.ts index 8d43acfa7..a62d3aa6c 100644 --- a/template/bigbot/src/utils/options.ts +++ b/template/bigbot/src/utils/options.ts @@ -141,7 +141,7 @@ function convertOptionValue( return [translateOptions?.[option.name] ?? option.name, final]; } - // THE REST OF OPTIONS DON'T NEED ANY CONVERTION + // THE REST OF OPTIONS DON'T NEED ANY CONVERSION // SAVE THE ARGUMENT WITH THE CORRECT NAME // @ts-ignore ts leave me alone return [translateOptions?.[option.name] ?? option.name, option.value]; diff --git a/template/bigbot/src/utils/permLevels.ts b/template/bigbot/src/utils/permLevels.ts index 9e19e4d02..303833f93 100644 --- a/template/bigbot/src/utils/permLevels.ts +++ b/template/bigbot/src/utils/permLevels.ts @@ -6,7 +6,7 @@ export default async function hasPermissionLevel( command: Command, payload: Interaction, ) { - // This command doesnt require a perm level so allow the command. + // This command doesn't require a perm level so allow the command. if (!command.permissionLevels) return true; // If a custom function was provided @@ -15,9 +15,9 @@ export default async function hasPermissionLevel( } // If an array of perm levels was provided - for (const permlevel of command.permissionLevels) { + for (const permLevel of command.permissionLevels) { // If this user has one of the allowed perm level, the loop is canceled and command is allowed. - if (await PermissionLevelHandlers[permlevel](payload, command)) return true; + if (await PermissionLevelHandlers[permLevel](payload, command)) return true; } // None of the perm levels were met. So cancel the command diff --git a/template/minimal/src/events/interactionCreate.ts b/template/minimal/src/events/interactionCreate.ts index 6f8c26178..67faa9ac0 100644 --- a/template/minimal/src/events/interactionCreate.ts +++ b/template/minimal/src/events/interactionCreate.ts @@ -200,7 +200,7 @@ events.interactionCreate = async (rawBot, interaction) => { // Check if command has execute if (!cmd.execute) { logger.error(`Command ${cmdName} is missing execute.`); - sendBasicReponse(data.id, data.token, "This command is not configured to be executed."); + sendBasicResponse(data.id, data.token, "This command is not configured to be executed."); return; } diff --git a/template/minimal/src/utils/logger.ts b/template/minimal/src/utils/logger.ts index a6702b472..3770ae4b6 100644 --- a/template/minimal/src/utils/logger.ts +++ b/template/minimal/src/utils/logger.ts @@ -1,7 +1,7 @@ // deno-lint-ignore-file no-explicit-any import { bold, cyan, gray, italic, red, yellow } from "../../deps.ts"; -export enum Loglevels { +export enum LogLevels { Debug, Info, Warn, @@ -9,31 +9,31 @@ export enum Loglevels { Fatal, } -const prefixes = new Map([ - [Loglevels.Debug, "DEBUG"], - [Loglevels.Info, "INFO"], - [Loglevels.Warn, "WARN"], - [Loglevels.Error, "ERROR"], - [Loglevels.Fatal, "FATAL"], +const prefixes = new Map([ + [LogLevels.Debug, "DEBUG"], + [LogLevels.Info, "INFO"], + [LogLevels.Warn, "WARN"], + [LogLevels.Error, "ERROR"], + [LogLevels.Fatal, "FATAL"], ]); const noColor: (str: string) => string = (msg) => msg; -const colorFunctions = new Map string>([ - [Loglevels.Debug, gray], - [Loglevels.Info, cyan], - [Loglevels.Warn, yellow], - [Loglevels.Error, (str: string) => red(str)], - [Loglevels.Fatal, (str: string) => red(bold(italic(str)))], +const colorFunctions = new Map string>([ + [LogLevels.Debug, gray], + [LogLevels.Info, cyan], + [LogLevels.Warn, yellow], + [LogLevels.Error, (str: string) => red(str)], + [LogLevels.Fatal, (str: string) => red(bold(italic(str)))], ]); export function logger({ - logLevel = Loglevels.Info, + logLevel = LogLevels.Info, name, }: { - logLevel?: Loglevels; + logLevel?: LogLevels; name?: string; } = {}) { - function log(level: Loglevels, ...args: any[]) { + function log(level: LogLevels, ...args: any[]) { if (level < logLevel) return; let color = colorFunctions.get(level); @@ -48,43 +48,43 @@ export function logger({ ]; switch (level) { - case Loglevels.Debug: + case LogLevels.Debug: return console.debug(...log); - case Loglevels.Info: + case LogLevels.Info: return console.info(...log); - case Loglevels.Warn: + case LogLevels.Warn: return console.warn(...log); - case Loglevels.Error: + case LogLevels.Error: return console.error(...log); - case Loglevels.Fatal: + case LogLevels.Fatal: return console.error(...log); default: return console.log(...log); } } - function setLevel(level: Loglevels) { + function setLevel(level: LogLevels) { logLevel = level; } function debug(...args: any[]) { - log(Loglevels.Debug, ...args); + log(LogLevels.Debug, ...args); } function info(...args: any[]) { - log(Loglevels.Info, ...args); + log(LogLevels.Info, ...args); } function warn(...args: any[]) { - log(Loglevels.Warn, ...args); + log(LogLevels.Warn, ...args); } function error(...args: any[]) { - log(Loglevels.Error, ...args); + log(LogLevels.Error, ...args); } function fatal(...args: any[]) { - log(Loglevels.Fatal, ...args); + log(LogLevels.Fatal, ...args); } return { diff --git a/transformers/auditLogEntry.ts b/transformers/auditLogEntry.ts new file mode 100644 index 000000000..398d1518b --- /dev/null +++ b/transformers/auditLogEntry.ts @@ -0,0 +1,133 @@ +import { Bot } from "../bot.ts"; +import { DiscordAuditLogEntry } from "../types/discord.ts"; +import { Optionalize } from "../types/shared.ts"; + +export function transformAuditLogEntry(bot: Bot, payload: DiscordAuditLogEntry) { + const auditLogEntry = { + id: bot.transformers.snowflake(payload.id), + changes: payload.changes?.map((change) => { + switch (change.key) { + case "$add": + case "$remove": + return { + key: change.key, + new: change.new_value?.map((val) => ({ + id: val.id ? bot.transformers.snowflake(val.id) : undefined, + name: val.name, + })), + old: change.old_value?.map((val) => ({ + id: val?.id ? bot.transformers.snowflake(val.id) : undefined, + name: val?.name, + })), + }; + case "discovery_splash_hash": + case "banner_hash": + case "rules_channel_id": + case "public_updates_channel_id": + case "icon_hash": + case "image_hash": + case "splash_hash": + case "owner_id": + case "widget_channel_id": + case "system_channel_id": + case "application_id": + case "permissions": + case "allow": + case "deny": + case "channel_id": + case "inviter_id": + case "avatar_hash": + case "id": + return { + key: change.key, + old: change.old_value ? bot.transformers.snowflake(change.old_value) : undefined, + new: change.new_value ? bot.transformers.snowflake(change.new_value) : undefined, + }; + case "name": + case "description": + case "preferred_locale": + case "region": + case "afk_channel_id": + case "vanity_url_code": + case "topic": + case "code": + case "nick": + case "location": + return { + key: change.key, + old: change.old_value, + new: change.new_value, + }; + case "afk_timeout": + case "mfa_level": + case "verification_level": + case "explicit_content_filter": + case "default_message_notifications": + case "prune_delete_days": + case "position": + case "bitrate": + case "rate_limit_per_user": + case "color": + case "max_uses": + case "uses": + case "max_age": + case "expire_behavior": + case "expire_grace_period": + case "user_limit": + case "privacy_level": + case "entity_type": + case "status": + return { + key: change.key, + old: change.old_value ? Number(change.old_value) : undefined, + new: change.new_value ? Number(change.new_value) : undefined, + }; + case "widget_enabled": + case "nsfw": + case "hoist": + case "mentionable": + case "temporary": + case "deaf": + case "mute": + case "enable_emoticons": + return { + key: change.key, + old: change.old_value ?? false, + new: change.new_value ?? false, + }; + case "permission_overwrites": + return { + key: change.key, + old: change.old_value, + new: change.new_value, + }; + default: + return { + key: change.key, + old: change.old_value, + new: change.new_value, + }; + } + }), + userId: payload.user_id ? bot.transformers.snowflake(payload.user_id) : undefined, + targetId: payload.target_id ? bot.transformers.snowflake(payload.target_id) : undefined, + actionType: payload.action_type, + options: payload.options + ? { + deleteMemberDays: payload.options.delete_member_days ? Number(payload.options.delete_member_days) : 0, + membersRemoved: payload.options.members_removed ? Number(payload.options.members_removed) : 0, + channelId: payload.options.channel_id ? bot.transformers.snowflake(payload.options.channel_id) : undefined, + messageId: payload.options.message_id ? bot.transformers.snowflake(payload.options.message_id) : undefined, + count: payload.options.count ? Number(payload.options.count) : 0, + id: payload.options.id ? bot.transformers.snowflake(payload.options.id) : undefined, + type: Number(payload.options.type), + roleName: payload.options.role_name, + } + : undefined, + reason: payload.reason, + }; + + return auditLogEntry as Optionalize; +} + +export interface AuditLogEntry extends ReturnType {} diff --git a/transformers/mod.ts b/transformers/mod.ts index fd52050d9..fdc1a649c 100644 --- a/transformers/mod.ts +++ b/transformers/mod.ts @@ -6,7 +6,7 @@ export * from "./applicationCommand.ts"; export * from "./applicationCommandOption.ts"; export * from "./applicationCommandPermission.ts"; export * from "./attachment.ts"; -export * from "./auditlogEntry.ts"; +export * from "./auditLogEntry.ts"; export * from "./channel.ts"; export * from "./component.ts"; export * from "./embed.ts"; diff --git a/transformers/toggles/guild.ts b/transformers/toggles/guild.ts index 070433837..a6ff853e5 100644 --- a/transformers/toggles/guild.ts +++ b/transformers/toggles/guild.ts @@ -18,7 +18,7 @@ export const GuildToggle = { /** Whether the guild has access to set an invite splash background */ inviteSplash: 1n << 5n, - /** Whether the guild has access to set 384kbps bitrate in voice (previously VIP voice servers) */ + /** Whether the guild has access to set 384 kbps bitrate in voice (previously VIP voice servers) */ vipRegions: 1n << 6n, /** Whether the guild has access to set a vanity URL */ vanityUrl: 1n << 7n, @@ -26,7 +26,7 @@ export const GuildToggle = { verified: 1n << 8n, /** Whether the guild is partnered */ partnered: 1n << 9n, - /** Whether the guild can enable welcome screen, Membership Screening, stage channels and discovery, and recives community updates */ + /** Whether the guild can enable welcome screen, Membership Screening, stage channels and discovery, and receives community updates */ community: 1n << 10n, /** Whether the guild has access to use commerce features (i.e. create store channels) */ commerce: 1n << 11n, @@ -130,7 +130,7 @@ export class GuildToggles extends ToggleBitfieldBigint { get inviteSplash() { return this.has("inviteSplash"); } - /** Whether the guild has access to set 384kbps bitrate in voice (previously VIP voice servers) */ + /** Whether the guild has access to set 384 kbps bitrate in voice (previously VIP voice servers) */ get vipRegions() { return this.has("vipRegions"); } @@ -146,7 +146,7 @@ export class GuildToggles extends ToggleBitfieldBigint { get partnered() { return this.has("partnered"); } - /** Whether the guild can enable welcome screen, Membership Screening, stage channels and discovery, and recives community updates */ + /** Whether the guild can enable welcome screen, Membership Screening, stage channels and discovery, and receives community updates */ get community() { return this.has("community"); } diff --git a/transformers/toggles/role.ts b/transformers/toggles/role.ts index 5f0b414fa..1325f74e6 100644 --- a/transformers/toggles/role.ts +++ b/transformers/toggles/role.ts @@ -2,7 +2,7 @@ import { DiscordRole } from "../../types/discord.ts"; import { ToggleBitfield } from "./ToggleBitfield.ts"; export const RoleToggle = { - /** If this role is showed seperately in the user listing */ + /** If this role is showed separately in the user listing */ hoist: 1 << 0, /** Whether this role is managed by an integration */ managed: 1 << 1, @@ -22,7 +22,7 @@ export class RoleToggles extends ToggleBitfield { if (role.tags?.premium_subscriber === null) this.add(RoleToggle.premiumSubscriber); } - /** If this role is showed seperately in the user listing */ + /** If this role is showed separately in the user listing */ get hoist() { return this.has("hoist"); } diff --git a/types/discord.ts b/types/discord.ts index 730b7d4e7..67c40ee1d 100644 --- a/types/discord.ts +++ b/types/discord.ts @@ -214,7 +214,7 @@ export interface DiscordMember { roles: string[]; /** When the user joined the guild */ joined_at: string; - /** When the user started boosing the guild */ + /** When the user started boosting the guild */ premium_since?: string | null; /** The permissions this member has in the guild. Only present on interaction events. */ permissions?: string; @@ -444,7 +444,7 @@ export type DiscordWebhook = DiscordIncomingWebhook | DiscordApplicationWebhook; export interface DiscordIncomingWebhook { /** The type of the webhook */ type: WebhookTypes; - /** The secure token of the webhook (returned for Incomming Webhooks) */ + /** The secure token of the webhook (returned for Incoming Webhooks) */ token?: string; /** The url used for executing the webhook (returned by the webhooks OAuth2 flow) */ url?: string; @@ -472,7 +472,7 @@ export interface DiscordIncomingWebhook { export interface DiscordApplicationWebhook { /** The type of the webhook */ type: WebhookTypes.Application; - /** The secure token of the webhook (returned for Incomming Webhooks) */ + /** The secure token of the webhook (returned for Incoming Webhooks) */ token?: string; /** The url used for executing the webhook (returned by the webhooks OAuth2 flow) */ url?: string; @@ -499,7 +499,7 @@ export interface DiscordApplicationWebhook { /** https://discord.com/developers/docs/resources/guild#guild-object */ export interface DiscordGuild { - /** Guild name (2-100 characaters, excluding trailing and leading whitespace) */ + /** Guild name (2-100 characters, excluding trailing and leading whitespace) */ name: string; /** True if the user is the owner of the guild */ owner?: boolean; @@ -529,7 +529,7 @@ export interface DiscordGuild { max_presences?: number | null; /** The maximum number of members for the guild */ max_members?: number; - /** The vaniy url code for the guild */ + /** The vanity url code for the guild */ vanity_url_code: string | null; /** The description of a Community guild */ description: string | null; @@ -606,7 +606,7 @@ export interface DiscordGuild { export interface DiscordRole { /** Role id */ id: string; - /** If this role is showed seperately in the user listing */ + /** If this role is showed separately in the user listing */ hoist: boolean; /** Permission bit set */ permissions: string; @@ -735,7 +735,7 @@ export interface DiscordChannel { parent_id?: string | null; /** When the last pinned message was pinned. This may be null in events such as GUILD_CREATE when a message is not pinned. */ last_pin_timestamp?: string | null; - /** Thread-specifig fields not needed by other channels */ + /** Thread-specific fields not needed by other channels */ thread_metadata?: DiscordThreadMetadata; /** Thread member object for the current user, if they have joined the thread, only included on certain API endpoints */ member?: DiscordThreadMember; @@ -803,7 +803,6 @@ export interface DiscordThreadMetadata { locked: boolean; /** whether non-moderators can add other non-moderators to a thread; only available on private threads */ invitable?: boolean; - /** Timestamp when the thread's archive status was last changed, used for calculating recent activity */ archive_timestamp: string; /** Timestamp when the thread was created; only populated for threads created after 2022-01-09 */ @@ -818,7 +817,6 @@ export interface DiscordThreadMemberBase { export interface DiscordThreadMember { /** Any user-thread settings, currently only used for notifications */ flags: number; - /** The id of the thread */ id: string; /** The id of the user */ @@ -830,7 +828,6 @@ export interface DiscordThreadMember { export interface DiscordThreadMemberGuildCreate { /** Any user-thread settings, currently only used for notifications */ flags: number; - /** The time the current user last joined the thread */ join_timestamp: string; } @@ -853,7 +850,6 @@ export interface DiscordActivity { instance?: boolean; /** Activity flags `OR`d together, describes what the payload includes */ flags?: number; - /** Unix timestamps for start and/or end of the game */ timestamps?: DiscordActivityTimestamps; /** Application id for the game */ @@ -894,7 +890,6 @@ export interface DiscordActivityEmoji { name: string; /** Whether this emoji is animated */ animated?: boolean; - /** The id of the emoji */ id?: string; } @@ -903,7 +898,6 @@ export interface DiscordActivityEmoji { export interface DiscordActivityParty { /** Used to show the party's current and maximum size */ size?: [currentSize: number, maxSize: number]; - /** The id of the party */ id?: string; } @@ -914,7 +908,6 @@ export interface DiscordActivityAssets { large_text?: string; /** Text displayed when hovering over the small image of the activity */ small_text?: string; - /** The id for a large asset of the activity, usually a snowflake */ large_image?: string; /** The id for a small asset of the activity, usually a snowflake */ @@ -943,7 +936,6 @@ export interface DiscordActivityButton { export interface DiscordOverwrite { /** Either 0 (role) or 1 (member) */ type: OverwriteTypes; - /** Role or user id */ id: string; /** Permission bit set */ @@ -1277,9 +1269,7 @@ export interface DiscordInteraction { version: 1; /** For the message the button was attached to */ message?: DiscordMessage; - data?: DiscordInteractionData; - /** The selected language of the invoking user */ locale?: string; /** The guild's preferred locale, if invoked in a guild */ @@ -1398,7 +1388,7 @@ export interface DiscordAuditLogEntry { user_id: string | null; /** id of the entry */ id: string; - /** Type of action that occured */ + /** Type of action that occurred */ action_type: AuditLogEvents; /** Additional info for certain action types */ options?: DiscordOptionalAuditEntryInfo; @@ -1449,7 +1439,7 @@ export type DiscordAuditLogChange = | "mfa_level" | "verification_level" | "explicit_content_filter" - | "default_messagae_notifications" + | "default_message_notifications" | "prune_delete_days" | "position" | "bitrate" @@ -1653,11 +1643,11 @@ export interface DiscordApplicationCommand { description_localizations?: Localization; /** The parameters for the command */ options?: DiscordApplicationCommandOption[]; - /** Whether the command is enbaled by default when the app is added to a guild */ + /** Whether the command is enabled by default when the app is added to a guild */ default_permission?: boolean; /** The type of command. By default this is a application command(ChatInput). */ type?: ApplicationCommandTypes; - /** Autoincrementing version identifier updated during substantial record changes */ + /** Auto incrementing version identifier updated during substantial record changes */ version: string; } @@ -1771,7 +1761,7 @@ export interface DiscordGuildPreview { export interface DiscordDiscoveryCategory { /** Numeric id of the category */ id: number; - /** The name of this category, in mutliple languages */ + /** The name of this category, in multiple languages */ name: DiscordDiscoveryName; /** Whether this category can be set as a guild's primary category */ is_primary: boolean; @@ -1793,7 +1783,7 @@ export interface DiscordDiscoveryMetadata { keywords: string[] | null; /** Whether guild info is shown when custom emojis from this guild are clicked */ emoji_discoverability_enabled: boolean; - /** When the server's partner applicationo was accepted or denied, for applications via Server Settings */ + /** When the server's partner application was accepted or denied, for applications via Server Settings */ partner_actioned_timestamp: string | null; /** When the server applied for partnership, if it has a pending application */ partner_application_timestamp: string | null; @@ -2044,7 +2034,7 @@ export interface DiscordTemplate { & { id: number } )[]; }; - /** Whether the template has unsynced changes */ + /** Whether the template has un-synced changes */ is_dirty: boolean | null; } @@ -2223,7 +2213,7 @@ export interface DiscordVoiceRegion { name: string; /** true for a single server that is closest to the current user's client */ optimal: boolean; - /** Whether this is a deprecated voice region (avoid swithing to these) */ + /** Whether this is a deprecated voice region (avoid switching to these) */ deprecated: boolean; /** Whether this is a custom voice region (used for events/etc) */ custom: boolean; diff --git a/types/shared.ts b/types/shared.ts index 74df96117..79b5ea17b 100644 --- a/types/shared.ts +++ b/types/shared.ts @@ -11,7 +11,7 @@ export enum PremiumTypes { export enum UserFlags { None, DiscordEmployee = 1 << 0, - ParteneredServerOwner = 1 << 1, + PartneredServerOwner = 1 << 1, HypeSquadEvents = 1 << 2, BugHunterLevel1 = 1 << 3, HouseBravery = 1 << 6, @@ -170,7 +170,7 @@ export interface BaseRole { export enum GuildFeatures { /** Guild has access to set an invite splash background */ InviteSplash = "INVITE_SPLASH", - /** Guild has access to set 384kbps bitrate in voice (previously VIP voice servers) */ + /** Guild has access to set 384 kbps bitrate in voice (previously VIP voice servers) */ VipRegions = "VIP_REGIONS", /** Guild has access to set a vanity URL */ VanityUrl = "VANITY_URL", @@ -178,7 +178,7 @@ export enum GuildFeatures { Verified = "VERIFIED", /** Guild is partnered */ Partnered = "PARTNERED", - /** Guild can enable welcome screen, Membership Screening, stage channels and discovery, and recives community updates */ + /** Guild can enable welcome screen, Membership Screening, stage channels and discovery, and receives community updates */ Community = "COMMUNITY", /** Guild has access to use commerce features (i.e. create store channels) */ Commerce = "COMMERCE", @@ -350,7 +350,7 @@ export enum StickerTypes { /** https://discord.com/developers/docs/resources/sticker#sticker-object-sticker-format-types */ export enum StickerFormatTypes { Png = 1, - Apng, + APng, Lottie, } @@ -1224,10 +1224,10 @@ export enum Errors { BUTTON_REQUIRES_CUSTOM_ID = "BUTTON_REQUIRES_CUSTOM_ID", COMPONENT_SELECT_MUST_BE_ALONE = "COMPONENT_SELECT_MUST_BE_ALONE", COMPONENT_PLACEHOLDER_TOO_BIG = "COMPONENT_PLACEHOLDER_TOO_BIG", - COMPONENT_SELECT_MINVALUE_TOO_LOW = "COMPONENT_SELECT_MINVALUE_TOO_LOW", - COMPONENT_SELECT_MINVALUE_TOO_MANY = "COMPONENT_SELECT_MINVALUE_TOO_MANY", - COMPONENT_SELECT_MAXVALUE_TOO_LOW = "COMPONENT_SELECT_MAXVALUE_TOO_LOW", - COMPONENT_SELECT_MAXVALUE_TOO_MANY = "COMPONENT_SELECT_MAXVALUE_TOO_MANY", + COMPONENT_SELECT_MIN_VALUE_TOO_LOW = "COMPONENT_SELECT_MIN_VALUE_TOO_LOW", + COMPONENT_SELECT_MIN_VALUE_TOO_MANY = "COMPONENT_SELECT_MIN_VALUE_TOO_MANY", + COMPONENT_SELECT_MAX_VALUE_TOO_LOW = "COMPONENT_SELECT_MAX_VALUE_TOO_LOW", + COMPONENT_SELECT_MAX_VALUE_TOO_MANY = "COMPONENT_SELECT_MAX_VALUE_TOO_MANY", COMPONENT_SELECT_OPTIONS_TOO_LOW = "COMPONENT_SELECT_OPTIONS_TOO_LOW", COMPONENT_SELECT_OPTIONS_TOO_MANY = "COMPONENT_SELECT_OPTIONS_TOO_MANY", SELECT_OPTION_LABEL_TOO_BIG = "SELECT_OPTION_LABEL_TOO_BIG", diff --git a/util/collection.ts b/util/collection.ts index 26d28192b..8e2ef5f32 100644 --- a/util/collection.ts +++ b/util/collection.ts @@ -46,7 +46,7 @@ export class Collection extends Map { } set(key: K, value: V) { - // When this collection is maxSizeed make sure we can add first + // When this collection is maxSized make sure we can add first if ((this.maxSize || this.maxSize === 0) && this.size >= this.maxSize) { return this; }