diff --git a/src/bot.ts b/src/bot.ts index c911ceebe..63f41b5c3 100644 --- a/src/bot.ts +++ b/src/bot.ts @@ -9,14 +9,14 @@ import { spawnShards } from "./ws/shard_manager.ts"; export let authorization = ""; export let restAuthorization = ""; -export let botID = ""; -export let applicationID = ""; +export let botId = ""; +export let applicationId = ""; export let eventHandlers: EventHandlers = {}; export let botGatewayData: DiscordGetGatewayBot; export let proxyWSURL = `wss://gateway.discord.gg`; -export let lastShardID = 0; +export let lastShardId = 0; export const identifyPayload: DiscordIdentify = { token: "", @@ -51,10 +51,10 @@ export async function startBot(config: BotConfig) { : next), 0, ); - lastShardID = botGatewayData.shards; - identifyPayload.shard = [0, lastShardID]; + lastShardId = botGatewayData.shards; + identifyPayload.shard = [0, lastShardId]; - await spawnShards(botGatewayData, identifyPayload, 0, lastShardID); + await spawnShards(botGatewayData, identifyPayload, 0, lastShardId); } /** Allows you to dynamically update the event handlers by passing in new eventHandlers */ @@ -65,14 +65,14 @@ export function updateEventHandlers(newEventHandlers: EventHandlers) { }; } -/** INTERNAL LIB function used to set the bot ID once the READY event is sent by Discord. */ -export function setBotID(id: string) { - if (botID !== id) botID = id; +/** INTERNAL LIB function used to set the bot Id once the READY event is sent by Discord. */ +export function setBotId(id: string) { + if (botId !== id) botId = id; } -/** INTERNAL LIB function used to set the application ID once the READY event is sent by Discord. */ -export function setApplicationID(id: string) { - if (applicationID !== id) applicationID = id; +/** INTERNAL LIB function used to set the application Id once the READY event is sent by Discord. */ +export function setApplicationId(id: string) { + if (applicationId !== id) applicationId = id; } // BIG BRAIN BOT STUFF ONLY BELOW THIS @@ -113,10 +113,10 @@ export async function startBigBrainBot(data: BigBrainBotConfig) { await spawnShards( botGatewayData, identifyPayload, - data.firstShardID, - data.lastShardID || + data.firstShardId, + data.lastShardId || (botGatewayData.shards >= 25 - ? (data.firstShardID + 25) + ? (data.firstShardId + 25) : botGatewayData.shards), ); } @@ -130,9 +130,9 @@ export interface BotConfig { export interface BigBrainBotConfig extends BotConfig { /** The first shard to start at for this worker. Use this to control which shards to run in each worker. */ - firstShardID: number; - /** The last shard to start for this worker. By default it will be 25 + the firstShardID. */ - lastShardID?: number; + firstShardId: number; + /** The last shard to start for this worker. By default it will be 25 + the firstShardId. */ + lastShardId?: number; /** This can be used to forward the ws handling to a proxy. */ wsURL?: string; /** This can be used to forward the REST handling to a proxy. */ diff --git a/src/cache.ts b/src/cache.ts index ba7d46992..e8678402c 100644 --- a/src/cache.ts +++ b/src/cache.ts @@ -5,17 +5,17 @@ import { Collection } from "./util/collection.ts"; export const cache: CacheData = { isReady: false, - /** All of the guild objects the bot has access to, mapped by their IDs */ + /** All of the guild objects the bot has access to, mapped by their Ids */ guilds: new Collection(), - /** All of the channel objects the bot has access to, mapped by their IDs */ + /** All of the channel objects the bot has access to, mapped by their Ids */ channels: new Collection(), - /** All of the message objects the bot has cached since the bot acquired `READY` state, mapped by their IDs */ + /** All of the message objects the bot has cached since the bot acquired `READY` state, mapped by their Ids */ messages: new Collection(), - /** All of the member objects that have been cached since the bot acquired `READY` state, mapped by their IDs */ + /** All of the member objects that have been cached since the bot acquired `READY` state, mapped by their Ids */ members: new Collection(), - /** All of the unavailable guilds, mapped by their IDs (id, shardID) */ + /** All of the unavailable guilds, mapped by their Ids (id, shardId) */ unavailableGuilds: new Collection(), - /** All of the presence update objects received in PRESENCE_UPDATE gateway event, mapped by their user ID */ + /** All of the presence update objects received in PRESENCE_UPDATE gateway event, mapped by their user Id */ presences: new Collection(), fetchAllMembersProcessingRequests: new Collection(), executedSlashCommands: new Collection(), diff --git a/src/handlers/channels/CHANNEL_DELETE.ts b/src/handlers/channels/CHANNEL_DELETE.ts index 2e839f647..a9ba2744d 100644 --- a/src/handlers/channels/CHANNEL_DELETE.ts +++ b/src/handlers/channels/CHANNEL_DELETE.ts @@ -13,22 +13,22 @@ export async function handleChannelDelete(data: DiscordGatewayPayload) { if (guild) { return Promise.all(guild.voiceStates.map(async (vs, key) => { - if (vs.channelID !== payload.id) return; + if (vs.channelId !== payload.id) return; // Since this channel was deleted all voice states for this channel should be deleted guild.voiceStates.delete(key); - const member = await cacheHandlers.get("members", vs.userID); + const member = await cacheHandlers.get("members", vs.userId); if (!member) return; - eventHandlers.voiceChannelLeave?.(member, vs.channelID); + eventHandlers.voiceChannelLeave?.(member, vs.channelId); })); } } await cacheHandlers.delete("channels", payload.id); cacheHandlers.forEach("messages", (message) => { - if (message.channelID === payload.id) { + if (message.channelId === payload.id) { cacheHandlers.delete("messages", message.id); } }); diff --git a/src/handlers/guilds/GUILD_CREATE.ts b/src/handlers/guilds/GUILD_CREATE.ts index 3053b4a4e..00f42073e 100644 --- a/src/handlers/guilds/GUILD_CREATE.ts +++ b/src/handlers/guilds/GUILD_CREATE.ts @@ -6,7 +6,7 @@ import { basicShards } from "../../ws/shard.ts"; export async function handleGuildCreate( data: DiscordGatewayPayload, - shardID: number, + shardId: number, ) { const payload = data.d as DiscordGuild; // When shards resume they emit GUILD_CREATE again. @@ -14,16 +14,16 @@ export async function handleGuildCreate( const guildStruct = await structures.createGuildStruct( data.d, - shardID, + shardId, ); await cacheHandlers.set("guilds", guildStruct.id, guildStruct); - const shard = basicShards.get(shardID); + const shard = basicShards.get(shardId); - if (shard?.unavailableGuildIDs.has(payload.id)) { + if (shard?.unavailableGuildIds.has(payload.id)) { await cacheHandlers.delete("unavailableGuilds", payload.id); - shard.unavailableGuildIDs.delete(payload.id); + shard.unavailableGuildIds.delete(payload.id); } if (!cache.isReady) return eventHandlers.guildLoaded?.(guildStruct); diff --git a/src/handlers/guilds/GUILD_DELETE.ts b/src/handlers/guilds/GUILD_DELETE.ts index 0d3c8a0c9..8c582bb59 100644 --- a/src/handlers/guilds/GUILD_DELETE.ts +++ b/src/handlers/guilds/GUILD_DELETE.ts @@ -5,7 +5,7 @@ import { basicShards } from "../../ws/shard.ts"; export async function handleGuildDelete( data: DiscordGatewayPayload, - shardID: number, + shardId: number, ) { const payload = data.d as DiscordUnavailableGuild; @@ -15,8 +15,8 @@ export async function handleGuildDelete( await cacheHandlers.delete("guilds", payload.id); if (payload.unavailable) { - const shard = basicShards.get(shardID); - if (shard) shard.unavailableGuildIDs.add(payload.id); + const shard = basicShards.get(shardId); + if (shard) shard.unavailableGuildIds.add(payload.id); await cacheHandlers.set("unavailableGuilds", payload.id, Date.now()); } @@ -24,13 +24,13 @@ export async function handleGuildDelete( eventHandlers.guildDelete?.(guild); cacheHandlers.forEach("messages", (message) => { - if (message.guildID === payload.id) { + if (message.guildId === payload.id) { cacheHandlers.delete("messages", message.id); } }); cacheHandlers.forEach("channels", (channel) => { - if (channel.guildID === payload.id) { + if (channel.guildId === payload.id) { cacheHandlers.delete("channels", channel.id); } }); diff --git a/src/handlers/invites/INVITE_DELETE.ts b/src/handlers/invites/INVITE_DELETE.ts index 9d42920a0..12fd390a1 100644 --- a/src/handlers/invites/INVITE_DELETE.ts +++ b/src/handlers/invites/INVITE_DELETE.ts @@ -6,14 +6,14 @@ import { export function handleInviteDelete(payload: DiscordGatewayPayload) { const { - channel_id: channelID, - guild_id: guildID, + channel_id: channelId, + guild_id: guildId, ...rest } = payload.d as DiscordInviteDelete; eventHandlers.inviteDelete?.({ ...rest, - channelID, - guildID, + channelId, + guildId, }); } diff --git a/src/handlers/members/GUILD_MEMBER_UPDATE.ts b/src/handlers/members/GUILD_MEMBER_UPDATE.ts index 9655dce09..ae8155f44 100644 --- a/src/handlers/members/GUILD_MEMBER_UPDATE.ts +++ b/src/handlers/members/GUILD_MEMBER_UPDATE.ts @@ -44,16 +44,16 @@ export async function handleGuildMemberUpdate(data: DiscordGatewayPayload) { eventHandlers.membershipScreeningPassed?.(guild, memberStruct); } - const roleIDs = guildMember?.roles || []; + const roleIds = guildMember?.roles || []; - roleIDs.forEach((id) => { + roleIds.forEach((id) => { if (!payload.roles.includes(id)) { eventHandlers.roleLost?.(guild, memberStruct, id); } }); payload.roles.forEach((id) => { - if (!roleIDs.includes(id)) { + if (!roleIds.includes(id)) { eventHandlers.roleGained?.(guild, memberStruct, id); } }); diff --git a/src/handlers/messages/MESSAGE_CREATE.ts b/src/handlers/messages/MESSAGE_CREATE.ts index 634c2cd3f..b1a7e7e9d 100644 --- a/src/handlers/messages/MESSAGE_CREATE.ts +++ b/src/handlers/messages/MESSAGE_CREATE.ts @@ -6,7 +6,7 @@ import { DiscordGatewayPayload } from "../../types/gateway.ts"; export async function handleMessageCreate(data: DiscordGatewayPayload) { const payload = data.d as DiscordMessage; const channel = await cacheHandlers.get("channels", payload.channel_id); - if (channel) channel.lastMessageID = payload.id; + if (channel) channel.lastMessageId = payload.id; const guild = payload.guild_id ? await cacheHandlers.get("guilds", payload.guild_id) diff --git a/src/handlers/messages/MESSAGE_REACTION_ADD.ts b/src/handlers/messages/MESSAGE_REACTION_ADD.ts index af7df860b..2c387e117 100644 --- a/src/handlers/messages/MESSAGE_REACTION_ADD.ts +++ b/src/handlers/messages/MESSAGE_REACTION_ADD.ts @@ -1,4 +1,4 @@ -import { botID, eventHandlers } from "../../bot.ts"; +import { botId, eventHandlers } from "../../bot.ts"; import { cacheHandlers } from "../../cache.ts"; import { structures } from "../../structures/mod.ts"; import { @@ -21,7 +21,7 @@ export async function handleMessageReactionAdd(data: DiscordGatewayPayload) { else { const newReaction = { count: 1, - me: payload.user_id === botID, + me: payload.user_id === botId, emoji: { ...payload.emoji, id: payload.emoji.id || undefined }, }; message.reactions = message.reactions @@ -46,8 +46,8 @@ export async function handleMessageReactionAdd(data: DiscordGatewayPayload) { const uncachedOptions = { ...payload, id: payload.message_id, - channelID: payload.channel_id, - guildID: payload.guild_id || "", + channelId: payload.channel_id, + guildId: payload.guild_id || "", }; eventHandlers.reactionAdd?.( diff --git a/src/handlers/messages/MESSAGE_REACTION_REMOVE.ts b/src/handlers/messages/MESSAGE_REACTION_REMOVE.ts index c637d6575..b55c1270f 100644 --- a/src/handlers/messages/MESSAGE_REACTION_REMOVE.ts +++ b/src/handlers/messages/MESSAGE_REACTION_REMOVE.ts @@ -1,4 +1,4 @@ -import { botID, eventHandlers } from "../../bot.ts"; +import { botId, eventHandlers } from "../../bot.ts"; import { cacheHandlers } from "../../cache.ts"; import { structures } from "../../structures/mod.ts"; import { @@ -23,7 +23,7 @@ export async function handleMessageReactionRemove( else { const newReaction = { count: 1, - me: payload.user_id === botID, + me: payload.user_id === botId, emoji: { ...payload.emoji, id: payload.emoji.id || undefined }, }; message.reactions = message.reactions @@ -48,8 +48,8 @@ export async function handleMessageReactionRemove( const uncachedOptions = { ...payload, id: payload.message_id, - channelID: payload.channel_id, - guildID: payload.guild_id, + channelId: payload.channel_id, + guildId: payload.guild_id, }; eventHandlers.reactionRemove?.( diff --git a/src/handlers/misc/READY.ts b/src/handlers/misc/READY.ts index 24564aeff..f8723b7b9 100644 --- a/src/handlers/misc/READY.ts +++ b/src/handlers/misc/READY.ts @@ -1,8 +1,8 @@ import { eventHandlers, - lastShardID, - setApplicationID, - setBotID, + lastShardId, + setApplicationId, + setBotId, } from "../../bot.ts"; import { cache, cacheHandlers } from "../../cache.ts"; import { initialMemberLoadQueue } from "../../structures/guild.ts"; @@ -13,30 +13,30 @@ import { allowNextShard, basicShards } from "../../ws/mod.ts"; export async function handleReady( data: DiscordGatewayPayload, - shardID: number, + shardId: number, ) { // The bot has already started, the last shard is resumed, however. if (cache.isReady) return; const payload = data.d as DiscordReady; - setBotID(payload.user.id); - setApplicationID(payload.application.id); + setBotId(payload.user.id); + setApplicationId(payload.application.id); // Triggered on each shard - eventHandlers.shardReady?.(shardID); + eventHandlers.shardReady?.(shardId); // Save when the READY event was received to prevent infinite load loops const now = Date.now(); - const shard = basicShards.get(shardID); + const shard = basicShards.get(shardId); if (!shard) return; // Set ready to false just to go sure shard.ready = false; // All guilds are unavailable at first - shard.unavailableGuildIDs = new Set(payload.guilds.map((g) => g.id)); + shard.unavailableGuildIds = new Set(payload.guilds.map((g) => g.id)); // Start ready check in 2 seconds - setTimeout(() => checkReady(payload, shardID, now), 2000); + setTimeout(() => checkReady(payload, shardId, now), 2000); // Wait 5 seconds to spawn next shard await delay(5000); @@ -45,48 +45,48 @@ export async function handleReady( // Don't pass the shard itself because unavailableGuilds won't be updated by the GUILD_CREATE event /** This function checks if the shard is fully loaded */ -function checkReady(payload: DiscordReady, shardID: number, now: number) { - const shard = basicShards.get(shardID); +function checkReady(payload: DiscordReady, shardId: number, now: number) { + const shard = basicShards.get(shardId); if (!shard) return; // Check if all guilds were loaded - if (shard.unavailableGuildIDs.size) { + if (shard.unavailableGuildIds.size) { if (Date.now() - now > 10000) { - eventHandlers.shardFailedToLoad?.(shardID, shard.unavailableGuildIDs); + eventHandlers.shardFailedToLoad?.(shardId, shard.unavailableGuildIds); // Force execute the loaded function to prevent infinite loop - loaded(shardID); + loaded(shardId); } else { // Not all guilds were loaded but 10 seconds haven't passed so check again - setTimeout(() => checkReady(payload, shardID, now), 2000); + setTimeout(() => checkReady(payload, shardId, now), 2000); } } else { // All guilds were loaded - loaded(shardID); + loaded(shardId); } } -async function loaded(shardID: number) { - const shard = basicShards.get(shardID); +async function loaded(shardId: number) { + const shard = basicShards.get(shardId); if (!shard) return; shard.ready = true; // If it is the last shard we can go full ready - if (shardID === lastShardID - 1) { + if (shardId === lastShardId - 1) { // Still some shards are loading so wait another 2 seconds for them if (basicShards.some((shard) => !shard.ready)) { - setTimeout(() => loaded(shardID), 2000); + setTimeout(() => loaded(shardId), 2000); } else { cache.isReady = true; eventHandlers.ready?.(); // All the members that came in on guild creates should now be processed 1 by 1 - for (const [guildID, members] of initialMemberLoadQueue.entries()) { + for (const [guildId, members] of initialMemberLoadQueue.entries()) { await Promise.allSettled( members.map(async (member) => { const memberStruct = await structures.createMemberStruct( member, - guildID, + guildId, ); return cacheHandlers.set( diff --git a/src/handlers/voice/VOICE_STATE_UPDATE.ts b/src/handlers/voice/VOICE_STATE_UPDATE.ts index 3bef06689..196afbc20 100644 --- a/src/handlers/voice/VOICE_STATE_UPDATE.ts +++ b/src/handlers/voice/VOICE_STATE_UPDATE.ts @@ -20,10 +20,10 @@ export async function handleVoiceStateUpdate(data: DiscordGatewayPayload) { guild.voiceStates.set(payload.user_id, { ...payload, - guildID: payload.guild_id, - channelID: payload.channel_id || "", - userID: payload.user_id, - sessionID: payload.session_id, + guildId: payload.guild_id, + channelId: payload.channel_id || "", + userId: payload.user_id, + sessionId: payload.session_id, selfDeaf: payload.self_deaf, selfMute: payload.self_mute, selfStream: payload.self_stream || false, @@ -31,22 +31,22 @@ export async function handleVoiceStateUpdate(data: DiscordGatewayPayload) { await cacheHandlers.set("guilds", payload.guild_id, guild); - if (cachedState?.channelID !== payload.channel_id) { + if (cachedState?.channelId !== payload.channel_id) { // Either joined or moved channels if (payload.channel_id) { - if (cachedState?.channelID) { // Was in a channel before + if (cachedState?.channelId) { // Was in a channel before eventHandlers.voiceChannelSwitch?.( member, payload.channel_id, - cachedState.channelID, + cachedState.channelId, ); } else { // Was not in a channel before so user just joined eventHandlers.voiceChannelJoin?.(member, payload.channel_id); } } // Left the channel - else if (cachedState?.channelID) { + else if (cachedState?.channelId) { guild.voiceStates.delete(payload.user_id); - eventHandlers.voiceChannelLeave?.(member, cachedState.channelID); + eventHandlers.voiceChannelLeave?.(member, cachedState.channelId); } } diff --git a/src/helpers/channels/category_children_ids.ts b/src/helpers/channels/category_children_ids.ts index 36344a278..447190ec4 100644 --- a/src/helpers/channels/category_children_ids.ts +++ b/src/helpers/channels/category_children_ids.ts @@ -1,9 +1,9 @@ import { cacheHandlers } from "../../cache.ts"; /** Gets an array of all the channels ids that are the children of this category. */ -export function categoryChildrenIDs(guildID: string, id: string) { +export function categoryChildrenIds(guildId: string, id: string) { return cacheHandlers.filter( "channels", - (channel) => channel.parentID === id && channel.guildID === guildID, + (channel) => channel.parentId === id && channel.guildId === guildId, ); } diff --git a/src/helpers/channels/channel_overwrite_has_permission.ts b/src/helpers/channels/channel_overwrite_has_permission.ts index 938755ebf..500afd6c0 100644 --- a/src/helpers/channels/channel_overwrite_has_permission.ts +++ b/src/helpers/channels/channel_overwrite_has_permission.ts @@ -1,12 +1,12 @@ /** Checks if a channel overwrite for a user id or a role id has permission in this channel */ export function channelOverwriteHasPermission( - guildID: string, + guildId: string, id: string, overwrites: RawOverwrite[], permissions: Permission[], ) { const overwrite = overwrites.find((perm) => perm.id === id) || - overwrites.find((perm) => perm.id === guildID); + overwrites.find((perm) => perm.id === guildId); return permissions.every((perm) => { if (overwrite) { diff --git a/src/helpers/channels/create_channel.ts b/src/helpers/channels/create_channel.ts index bc45faaff..2fcf03dac 100644 --- a/src/helpers/channels/create_channel.ts +++ b/src/helpers/channels/create_channel.ts @@ -9,7 +9,7 @@ import { /** Create a channel in your server. Bot needs MANAGE_CHANNEL permissions in the server. */ export async function createChannel( - guildID: string, + guildId: string, name: string, options?: ChannelCreateOptions, ) { @@ -20,10 +20,10 @@ export async function createChannel( overwrite.deny.forEach(requiredPerms.add, requiredPerms); }); - await requireBotGuildPermissions(guildID, [...requiredPerms]); + await requireBotGuildPermissions(guildId, [...requiredPerms]); const result = (await RequestManager.post( - endpoints.GUILD_CHANNELS(guildID), + endpoints.GUILD_CHANNELS(guildId), { ...options, name, diff --git a/src/helpers/channels/delete_channel.ts b/src/helpers/channels/delete_channel.ts index fd0706cc8..387206f33 100644 --- a/src/helpers/channels/delete_channel.ts +++ b/src/helpers/channels/delete_channel.ts @@ -5,25 +5,25 @@ import { requireBotGuildPermissions } from "../../util/permissions.ts"; /** Delete a channel in your server. Bot needs MANAGE_CHANNEL permissions in the server. */ export async function deleteChannel( - guildID: string, - channelID: string, + guildId: string, + channelId: string, reason?: string, ) { - await requireBotGuildPermissions(guildID, ["MANAGE_CHANNELS"]); + await requireBotGuildPermissions(guildId, ["MANAGE_CHANNELS"]); - const guild = await cacheHandlers.get("guilds", guildID); + const guild = await cacheHandlers.get("guilds", guildId); if (!guild) throw new Error(Errors.GUILD_NOT_FOUND); - if (guild?.rulesChannelID === channelID) { + if (guild?.rulesChannelId === channelId) { throw new Error(Errors.RULES_CHANNEL_CANNOT_BE_DELETED); } - if (guild?.publicUpdatesChannelID === channelID) { + if (guild?.publicUpdatesChannelId === channelId) { throw new Error(Errors.UPDATES_CHANNEL_CANNOT_BE_DELETED); } const result = await RequestManager.delete( - endpoints.CHANNEL_BASE(channelID), + endpoints.CHANNEL_BASE(channelId), { reason }, ); diff --git a/src/helpers/channels/delete_channel_overwrite.ts b/src/helpers/channels/delete_channel_overwrite.ts index 39e7ebee1..e086cf107 100644 --- a/src/helpers/channels/delete_channel_overwrite.ts +++ b/src/helpers/channels/delete_channel_overwrite.ts @@ -4,14 +4,14 @@ import { requireBotGuildPermissions } from "../../util/permissions.ts"; /** Delete the channel permission overwrites for a user or role in this channel. Requires `MANAGE_ROLES` permission. */ export async function deleteChannelOverwrite( - guildID: string, - channelID: string, - overwriteID: string, + guildId: string, + channelId: string, + overwriteId: string, ) { - await requireBotGuildPermissions(guildID, ["MANAGE_ROLES"]); + await requireBotGuildPermissions(guildId, ["MANAGE_ROLES"]); const result = await RequestManager.delete( - endpoints.CHANNEL_OVERWRITE(channelID, overwriteID), + endpoints.CHANNEL_OVERWRITE(channelId, overwriteId), ); return result; diff --git a/src/helpers/channels/edit_channel.ts b/src/helpers/channels/edit_channel.ts index 057180f5f..e466fcf96 100644 --- a/src/helpers/channels/edit_channel.ts +++ b/src/helpers/channels/edit_channel.ts @@ -7,18 +7,18 @@ import { /** Update a channel's settings. Requires the `MANAGE_CHANNELS` permission for the guild. */ export async function editChannel( - channelID: string, + channelId: string, options: ChannelEditOptions, reason?: string, ) { - await requireBotChannelPermissions(channelID, ["MANAGE_CHANNELS"]); + await requireBotChannelPermissions(channelId, ["MANAGE_CHANNELS"]); if (options.name || options.topic) { - const request = editChannelNameTopicQueue.get(channelID); + const request = editChannelNameTopicQueue.get(channelId); if (!request) { // If this hasnt been done before simply add 1 for it - editChannelNameTopicQueue.set(channelID, { - channelID: channelID, + editChannelNameTopicQueue.set(channelId, { + channelId: channelId, amount: 1, // 10 minutes from now timestamp: Date.now() + 600000, @@ -30,7 +30,7 @@ export async function editChannel( request.timestamp = Date.now() + 600000; } else { // 2 have already been used add to queue - request.items.push({ channelID, options }); + request.items.push({ channelId, options }); if (editChannelProcessing) return; editChannelProcessing = true; processEditChannelQueue(); @@ -43,7 +43,7 @@ export async function editChannel( // deno-lint-ignore camelcase rate_limit_per_user: options.rateLimitPerUser, // deno-lint-ignore camelcase - parent_id: options.parentID, + parent_id: options.parentId, // deno-lint-ignore camelcase user_limit: options.userLimit, // deno-lint-ignore camelcase @@ -56,7 +56,7 @@ export async function editChannel( }), }; - const result = await RequestManager.patch(endpoints.CHANNEL_BASE(channelID), { + const result = await RequestManager.patch(endpoints.CHANNEL_BASE(channelId), { ...payload, reason, }); @@ -75,7 +75,7 @@ function processEditChannelQueue() { if (now > request.timestamp) return; // 10 minutes have passed so we can reset this channel again if (!request.items.length) { - return editChannelNameTopicQueue.delete(request.channelID); + return editChannelNameTopicQueue.delete(request.channelId); } request.amount = 0; // There are items to process for this request @@ -83,11 +83,11 @@ function processEditChannelQueue() { if (!details) return; - editChannel(details.channelID, details.options); + editChannel(details.channelId, details.options); const secondDetails = request.items.shift(); if (!secondDetails) return; - return editChannel(secondDetails.channelID, secondDetails.options); + return editChannel(secondDetails.channelId, secondDetails.options); }); if (editChannelNameTopicQueue.size) { diff --git a/src/helpers/channels/edit_channel_overwrite.ts b/src/helpers/channels/edit_channel_overwrite.ts index bd3ee7fa7..0b5918896 100644 --- a/src/helpers/channels/edit_channel_overwrite.ts +++ b/src/helpers/channels/edit_channel_overwrite.ts @@ -7,15 +7,15 @@ import { /** Edit the channel permission overwrites for a user or role in this channel. Requires `MANAGE_ROLES` permission. */ export async function editChannelOverwrite( - guildID: string, - channelID: string, - overwriteID: string, + guildId: string, + channelId: string, + overwriteId: string, options: Omit, ) { - await requireBotGuildPermissions(guildID, ["MANAGE_ROLES"]); + await requireBotGuildPermissions(guildId, ["MANAGE_ROLES"]); const result = await RequestManager.put( - endpoints.CHANNEL_OVERWRITE(channelID, overwriteID), + endpoints.CHANNEL_OVERWRITE(channelId, overwriteId), { allow: calculateBits(options.allow), deny: calculateBits(options.deny), diff --git a/src/helpers/channels/follow_channel.ts b/src/helpers/channels/follow_channel.ts index 5e9c5470c..65c0c010e 100644 --- a/src/helpers/channels/follow_channel.ts +++ b/src/helpers/channels/follow_channel.ts @@ -4,15 +4,15 @@ import { requireBotChannelPermissions } from "../../util/permissions.ts"; /** Follow a News Channel to send messages to a target channel. Requires the `MANAGE_WEBHOOKS` permission in the target channel. Returns the webhook id. */ export async function followChannel( - sourceChannelID: string, - targetChannelID: string, + sourceChannelId: string, + targetChannelId: string, ) { - await requireBotChannelPermissions(targetChannelID, ["MANAGE_WEBHOOKS"]); + await requireBotChannelPermissions(targetChannelId, ["MANAGE_WEBHOOKS"]); const data = (await RequestManager.post( - endpoints.CHANNEL_FOLLOW(sourceChannelID), + endpoints.CHANNEL_FOLLOW(sourceChannelId), { - webhook_channel_id: targetChannelID, + webhook_channel_id: targetChannelId, }, )) as FollowedChannelPayload; diff --git a/src/helpers/channels/get_channel.ts b/src/helpers/channels/get_channel.ts index 840ad91f9..6d471e263 100644 --- a/src/helpers/channels/get_channel.ts +++ b/src/helpers/channels/get_channel.ts @@ -7,9 +7,9 @@ import { endpoints } from "../../util/constants.ts"; * * ⚠️ **If you need this, you are probably doing something wrong. This is not intended for use. Your channels will be cached in your guild.** */ -export async function getChannel(channelID: string, addToCache = true) { +export async function getChannel(channelId: string, addToCache = true) { const result = (await RequestManager.get( - endpoints.CHANNEL_BASE(channelID), + endpoints.CHANNEL_BASE(channelId), )) as ChannelCreatePayload; const channelStruct = await structures.createChannelStruct( diff --git a/src/helpers/channels/get_channel_webhooks.ts b/src/helpers/channels/get_channel_webhooks.ts index eb2fef5a4..972a54f61 100644 --- a/src/helpers/channels/get_channel_webhooks.ts +++ b/src/helpers/channels/get_channel_webhooks.ts @@ -3,11 +3,11 @@ import { endpoints } from "../../util/constants.ts"; import { requireBotChannelPermissions } from "../../util/permissions.ts"; /** Gets the webhooks for this channel. Requires MANAGE_WEBHOOKS */ -export async function getChannelWebhooks(channelID: string) { - await requireBotChannelPermissions(channelID, ["MANAGE_WEBHOOKS"]); +export async function getChannelWebhooks(channelId: string) { + await requireBotChannelPermissions(channelId, ["MANAGE_WEBHOOKS"]); const result = await RequestManager.get( - endpoints.CHANNEL_WEBHOOKS(channelID), + endpoints.CHANNEL_WEBHOOKS(channelId), ); return result as WebhookPayload[]; diff --git a/src/helpers/channels/get_channels.ts b/src/helpers/channels/get_channels.ts index b7ea3f102..f00aa37be 100644 --- a/src/helpers/channels/get_channels.ts +++ b/src/helpers/channels/get_channels.ts @@ -7,13 +7,13 @@ import { endpoints } from "../../util/constants.ts"; * * ⚠️ **If you need this, you are probably doing something wrong. This is not intended for use. Your channels will be cached in your guild.** */ -export async function getChannels(guildID: string, addToCache = true) { +export async function getChannels(guildId: string, addToCache = true) { const result = (await RequestManager.get( - endpoints.GUILD_CHANNELS(guildID), + endpoints.GUILD_CHANNELS(guildId), ) as ChannelCreatePayload[]); return Promise.all(result.map(async (res) => { - const channelStruct = await structures.createChannelStruct(res, guildID); + const channelStruct = await structures.createChannelStruct(res, guildId); if (addToCache) { await cacheHandlers.set("channels", channelStruct.id, channelStruct); } diff --git a/src/helpers/channels/get_pins.ts b/src/helpers/channels/get_pins.ts index 881dea896..9dbde3195 100644 --- a/src/helpers/channels/get_pins.ts +++ b/src/helpers/channels/get_pins.ts @@ -3,9 +3,9 @@ import { structures } from "../../structures/mod.ts"; import { endpoints } from "../../util/constants.ts"; /** Get pinned messages in this channel. */ -export async function getPins(channelID: string) { +export async function getPins(channelId: string) { const result = (await RequestManager.get( - endpoints.CHANNEL_PINS(channelID), + endpoints.CHANNEL_PINS(channelId), )) as MessageCreateOptions[]; return Promise.all( diff --git a/src/helpers/channels/is_channel_synced.ts b/src/helpers/channels/is_channel_synced.ts index abeebe520..4f2dd0e0a 100644 --- a/src/helpers/channels/is_channel_synced.ts +++ b/src/helpers/channels/is_channel_synced.ts @@ -1,11 +1,11 @@ import { cacheHandlers } from "../../cache.ts"; /** Checks whether a channel is synchronized with its parent/category channel or not. */ -export async function isChannelSynced(channelID: string) { - const channel = await cacheHandlers.get("channels", channelID); - if (!channel?.parentID) return false; +export async function isChannelSynced(channelId: string) { + const channel = await cacheHandlers.get("channels", channelId); + if (!channel?.parentId) return false; - const parentChannel = await cacheHandlers.get("channels", channel.parentID); + const parentChannel = await cacheHandlers.get("channels", channel.parentId); if (!parentChannel) return false; return channel.permissionOverwrites?.every((overwrite) => { diff --git a/src/helpers/channels/start_typing.ts b/src/helpers/channels/start_typing.ts index c355ad045..e0e612bdd 100644 --- a/src/helpers/channels/start_typing.ts +++ b/src/helpers/channels/start_typing.ts @@ -8,8 +8,8 @@ import { botHasChannelPermissions } from "../../util/permissions.ts"; * However, if a bot is responding to a command and expects the computation to take a few seconds, * this endpoint may be called to let the user know that the bot is processing their message. */ -export async function startTyping(channelID: string) { - const channel = await cacheHandlers.get("channels", channelID); +export async function startTyping(channelId: string) { + const channel = await cacheHandlers.get("channels", channelId); // If the channel is cached, we can do extra checks/safety if (channel) { if ( @@ -23,7 +23,7 @@ export async function startTyping(channelID: string) { } const hasSendMessagesPerm = await botHasChannelPermissions( - channelID, + channelId, ["SEND_MESSAGES"], ); if ( @@ -33,7 +33,7 @@ export async function startTyping(channelID: string) { } } - const result = await RequestManager.post(endpoints.CHANNEL_TYPING(channelID)); + const result = await RequestManager.post(endpoints.CHANNEL_TYPING(channelId)); return result; } diff --git a/src/helpers/channels/swap_channels.ts b/src/helpers/channels/swap_channels.ts index 2de4a25bb..0239c2ac6 100644 --- a/src/helpers/channels/swap_channels.ts +++ b/src/helpers/channels/swap_channels.ts @@ -3,7 +3,7 @@ import { endpoints } from "../../util/constants.ts"; /** Modify the positions of channels on the guild. Requires MANAGE_CHANNELS permisison. */ export async function swapChannels( - guildID: string, + guildId: string, channelPositions: PositionSwap[], ) { if (channelPositions.length < 2) { @@ -11,7 +11,7 @@ export async function swapChannels( } const result = await RequestManager.patch( - endpoints.GUILD_CHANNELS(guildID), + endpoints.GUILD_CHANNELS(guildId), channelPositions, ); diff --git a/src/helpers/commands/create_slash_command.ts b/src/helpers/commands/create_slash_command.ts index c70f4e0f0..c4c745c85 100644 --- a/src/helpers/commands/create_slash_command.ts +++ b/src/helpers/commands/create_slash_command.ts @@ -1,4 +1,4 @@ -import { applicationID } from "../../bot.ts"; +import { applicationId } from "../../bot.ts"; import { RequestManager } from "../../rest/request_manager.ts"; import { endpoints } from "../../util/constants.ts"; import { validateSlashCommands } from "../../util/utils.ts"; @@ -18,9 +18,9 @@ export async function createSlashCommand(options: CreateSlashCommandOptions) { validateSlashCommands([options], true); const result = await RequestManager.post( - options.guildID - ? endpoints.COMMANDS_GUILD(applicationID, options.guildID) - : endpoints.COMMANDS(applicationID), + options.guildId + ? endpoints.COMMANDS_GUILD(applicationId, options.guildId) + : endpoints.COMMANDS(applicationId), { ...options, }, diff --git a/src/helpers/commands/delete_slash_command.ts b/src/helpers/commands/delete_slash_command.ts index 2dd7fba57..a07d197b6 100644 --- a/src/helpers/commands/delete_slash_command.ts +++ b/src/helpers/commands/delete_slash_command.ts @@ -1,13 +1,13 @@ -import { applicationID } from "../../bot.ts"; +import { applicationId } from "../../bot.ts"; import { RequestManager } from "../../rest/request_manager.ts"; import { endpoints } from "../../util/constants.ts"; /** Deletes a slash command. */ -export function deleteSlashCommand(id: string, guildID?: string) { - if (!guildID) { - return RequestManager.delete(endpoints.COMMANDS_ID(applicationID, id)); +export function deleteSlashCommand(id: string, guildId?: string) { + if (!guildId) { + return RequestManager.delete(endpoints.COMMANDS_ID(applicationId, id)); } return RequestManager.delete( - endpoints.COMMANDS_GUILD_ID(applicationID, guildID, id), + endpoints.COMMANDS_GUILD_ID(applicationId, guildId, id), ); } diff --git a/src/helpers/commands/delete_slash_response.ts b/src/helpers/commands/delete_slash_response.ts index 0118e186f..d18e48bc5 100644 --- a/src/helpers/commands/delete_slash_response.ts +++ b/src/helpers/commands/delete_slash_response.ts @@ -1,17 +1,17 @@ -import { applicationID } from "../../bot.ts"; +import { applicationId } from "../../bot.ts"; import { RequestManager } from "../../rest/request_manager.ts"; import { endpoints } from "../../util/constants.ts"; /** To delete your response to a slash command. If a message id is not provided, it will default to deleting the original response. */ -export async function deleteSlashResponse(token: string, messageID?: string) { +export async function deleteSlashResponse(token: string, messageId?: string) { const result = await RequestManager.delete( - messageID - ? endpoints.INTERACTION_ID_TOKEN_MESSAGEID( - applicationID, + messageId + ? endpoints.INTERACTION_ID_TOKEN_MESSAGE_ID( + applicationId, token, - messageID, + messageId, ) - : endpoints.INTERACTION_ORIGINAL_ID_TOKEN(applicationID, token), + : endpoints.INTERACTION_ORIGINAL_ID_TOKEN(applicationId, token), ); return result; diff --git a/src/helpers/commands/edit_slash_response.ts b/src/helpers/commands/edit_slash_response.ts index b68fc8078..a0e0761e7 100644 --- a/src/helpers/commands/edit_slash_response.ts +++ b/src/helpers/commands/edit_slash_response.ts @@ -1,9 +1,9 @@ -import { applicationID } from "../../bot.ts"; +import { applicationId } from "../../bot.ts"; import { RequestManager } from "../../rest/request_manager.ts"; import { structures } from "../../structures/mod.ts"; import { endpoints } from "../../util/constants.ts"; -/** To edit your response to a slash command. If a messageID is not provided it will default to editing the original response. */ +/** To edit your response to a slash command. If a messageId is not provided it will default to editing the original response. */ export async function editSlashResponse( token: string, options: EditSlashResponseOptions, @@ -49,14 +49,14 @@ export async function editSlashResponse( } const result = await RequestManager.patch( - options.messageID - ? endpoints.WEBHOOK_MESSAGE(applicationID, token, options.messageID) - : endpoints.INTERACTION_ORIGINAL_ID_TOKEN(applicationID, token), + options.messageId + ? endpoints.WEBHOOK_MESSAGE(applicationId, token, options.messageId) + : endpoints.INTERACTION_ORIGINAL_ID_TOKEN(applicationId, token), options, ); // If the original message was edited, this will not return a message - if (!options.messageID) return result; + if (!options.messageId) return result; const message = await structures.createMessageStruct( result as MessageCreateOptions, diff --git a/src/helpers/commands/get_slash_command.ts b/src/helpers/commands/get_slash_command.ts index 111be9a8c..49857884e 100644 --- a/src/helpers/commands/get_slash_command.ts +++ b/src/helpers/commands/get_slash_command.ts @@ -1,13 +1,13 @@ -import { applicationID } from "../../bot.ts"; +import { applicationId } from "../../bot.ts"; import { RequestManager } from "../../rest/request_manager.ts"; import { endpoints } from "../../util/constants.ts"; -/** Fetchs the global command for the given ID. If a guildID is provided, the guild command will be fetched. */ -export async function getSlashCommand(commandID: string, guildID?: string) { +/** Fetchs the global command for the given Id. If a guildId is provided, the guild command will be fetched. */ +export async function getSlashCommand(commandId: string, guildId?: string) { const result = await RequestManager.get( - guildID - ? endpoints.COMMANDS_GUILD_ID(applicationID, guildID, commandID) - : endpoints.COMMANDS_ID(applicationID, commandID), + guildId + ? endpoints.COMMANDS_GUILD_ID(applicationId, guildId, commandId) + : endpoints.COMMANDS_ID(applicationId, commandId), ); return result as SlashCommand; diff --git a/src/helpers/commands/get_slash_commands.ts b/src/helpers/commands/get_slash_commands.ts index b16ad85d3..e7ea2de93 100644 --- a/src/helpers/commands/get_slash_commands.ts +++ b/src/helpers/commands/get_slash_commands.ts @@ -1,14 +1,14 @@ -import { applicationID } from "../../bot.ts"; +import { applicationId } from "../../bot.ts"; import { RequestManager } from "../../rest/request_manager.ts"; import { Collection } from "../../util/collection.ts"; import { endpoints } from "../../util/constants.ts"; /** Fetch all of the global commands for your application. */ -export async function getSlashCommands(guildID?: string) { +export async function getSlashCommands(guildId?: string) { const result = (await RequestManager.get( - guildID - ? endpoints.COMMANDS_GUILD(applicationID, guildID) - : endpoints.COMMANDS(applicationID), + guildId + ? endpoints.COMMANDS_GUILD(applicationId, guildId) + : endpoints.COMMANDS(applicationId), )) as SlashCommand[]; return new Collection(result.map((command) => [command.name, command])); diff --git a/src/helpers/commands/send_interaction_response.ts b/src/helpers/commands/send_interaction_response.ts index 69983181e..855310393 100644 --- a/src/helpers/commands/send_interaction_response.ts +++ b/src/helpers/commands/send_interaction_response.ts @@ -1,4 +1,4 @@ -import { applicationID } from "../../bot.ts"; +import { applicationId } from "../../bot.ts"; import { cache } from "../../cache.ts"; import { RequestManager } from "../../rest/request_manager.ts"; import { endpoints } from "../../util/constants.ts"; @@ -16,7 +16,7 @@ export async function sendInteractionResponse( ) { // If its already been executed, we need to send a followup response if (cache.executedSlashCommands.has(token)) { - return RequestManager.post(endpoints.WEBHOOK(applicationID, token), { + return RequestManager.post(endpoints.WEBHOOK(applicationId, token), { ...options, }); } diff --git a/src/helpers/commands/upsert_slash_command.ts b/src/helpers/commands/upsert_slash_command.ts index 8115d17ac..0861a05d7 100644 --- a/src/helpers/commands/upsert_slash_command.ts +++ b/src/helpers/commands/upsert_slash_command.ts @@ -1,4 +1,4 @@ -import { applicationID } from "../../bot.ts"; +import { applicationId } from "../../bot.ts"; import { RequestManager } from "../../rest/request_manager.ts"; import { endpoints } from "../../util/constants.ts"; import { validateSlashCommands } from "../../util/utils.ts"; @@ -7,16 +7,16 @@ import { validateSlashCommands } from "../../util/utils.ts"; * Edit an existing slash command. If this command did not exist, it will create it. */ export async function upsertSlashCommand( - commandID: string, + commandId: string, options: UpsertSlashCommandOptions, - guildID?: string, + guildId?: string, ) { validateSlashCommands([options]); const result = await RequestManager.patch( - guildID - ? endpoints.COMMANDS_GUILD_ID(applicationID, guildID, commandID) - : endpoints.COMMANDS_ID(applicationID, commandID), + guildId + ? endpoints.COMMANDS_GUILD_ID(applicationId, guildId, commandId) + : endpoints.COMMANDS_ID(applicationId, commandId), options, ); diff --git a/src/helpers/commands/upsert_slash_commands.ts b/src/helpers/commands/upsert_slash_commands.ts index c087c43ed..cb0239bc4 100644 --- a/src/helpers/commands/upsert_slash_commands.ts +++ b/src/helpers/commands/upsert_slash_commands.ts @@ -1,4 +1,4 @@ -import { applicationID } from "../../bot.ts"; +import { applicationId } from "../../bot.ts"; import { RequestManager } from "../../rest/request_manager.ts"; import { endpoints } from "../../util/constants.ts"; import { validateSlashCommands } from "../../util/utils.ts"; @@ -6,18 +6,18 @@ import { validateSlashCommands } from "../../util/utils.ts"; /** * Bulk edit existing slash commands. If a command does not exist, it will create it. * - * **NOTE:** Any slash commands that are not specified in this function will be **deleted**. If you don't provide the commandID and rename your command, the command gets a new ID. + * **NOTE:** Any slash commands that are not specified in this function will be **deleted**. If you don't provide the commandId and rename your command, the command gets a new Id. */ export async function upsertSlashCommands( options: UpsertSlashCommandsOptions[], - guildID?: string, + guildId?: string, ) { validateSlashCommands(options); const result = await RequestManager.put( - guildID - ? endpoints.COMMANDS_GUILD(applicationID, guildID) - : endpoints.COMMANDS(applicationID), + guildId + ? endpoints.COMMANDS_GUILD(applicationId, guildId) + : endpoints.COMMANDS(applicationId), options, ); diff --git a/src/helpers/emojis/create_emoji.ts b/src/helpers/emojis/create_emoji.ts index 7ed8f780f..d43b83802 100644 --- a/src/helpers/emojis/create_emoji.ts +++ b/src/helpers/emojis/create_emoji.ts @@ -5,18 +5,18 @@ import { urlToBase64 } from "../../util/utils.ts"; /** Create an emoji in the server. Emojis and animated emojis have a maximum file size of 256kb. Attempting to upload an emoji larger than this limit will fail and return 400 Bad Request and an error message, but not a JSON status code. If a URL is provided to the image parameter, Discordeno will automatically convert it to a base64 string internally. */ export async function createEmoji( - guildID: string, + guildId: string, name: string, image: string, options: CreateEmojisOptions, ) { - await requireBotGuildPermissions(guildID, ["MANAGE_EMOJIS"]); + await requireBotGuildPermissions(guildId, ["MANAGE_EMOJIS"]); if (image && !image.startsWith("data:image/")) { image = await urlToBase64(image); } - const result = await RequestManager.post(endpoints.GUILD_EMOJIS(guildID), { + const result = await RequestManager.post(endpoints.GUILD_EMOJIS(guildId), { ...options, name, image, diff --git a/src/helpers/emojis/delete_emoji.ts b/src/helpers/emojis/delete_emoji.ts index a9ef8c2d8..8beb9648c 100644 --- a/src/helpers/emojis/delete_emoji.ts +++ b/src/helpers/emojis/delete_emoji.ts @@ -4,14 +4,14 @@ import { requireBotGuildPermissions } from "../../util/permissions.ts"; /** Delete the given emoji. Requires the MANAGE_EMOJIS permission. Returns 204 No Content on success. */ export async function deleteEmoji( - guildID: string, + guildId: string, id: string, reason?: string, ) { - await requireBotGuildPermissions(guildID, ["MANAGE_EMOJIS"]); + await requireBotGuildPermissions(guildId, ["MANAGE_EMOJIS"]); const result = await RequestManager.delete( - endpoints.GUILD_EMOJI(guildID, id), + endpoints.GUILD_EMOJI(guildId, id), { reason }, ); diff --git a/src/helpers/emojis/edit_emoji.ts b/src/helpers/emojis/edit_emoji.ts index 83aebeadf..ddff2997b 100644 --- a/src/helpers/emojis/edit_emoji.ts +++ b/src/helpers/emojis/edit_emoji.ts @@ -4,14 +4,14 @@ import { requireBotGuildPermissions } from "../../util/permissions.ts"; /** Modify the given emoji. Requires the MANAGE_EMOJIS permission. */ export async function editEmoji( - guildID: string, + guildId: string, id: string, options: EditEmojisOptions, ) { - await requireBotGuildPermissions(guildID, ["MANAGE_EMOJIS"]); + await requireBotGuildPermissions(guildId, ["MANAGE_EMOJIS"]); const result = await RequestManager.patch( - endpoints.GUILD_EMOJI(guildID, id), + endpoints.GUILD_EMOJI(guildId, id), { name: options.name, roles: options.roles, diff --git a/src/helpers/emojis/get_emoji.ts b/src/helpers/emojis/get_emoji.ts index 179501273..fc038c59f 100644 --- a/src/helpers/emojis/get_emoji.ts +++ b/src/helpers/emojis/get_emoji.ts @@ -3,26 +3,26 @@ import { RequestManager } from "../../rest/request_manager.ts"; import { endpoints } from "../../util/constants.ts"; /** - * Returns an emoji for the given guild and emoji ID. + * Returns an emoji for the given guild and emoji Id. * * ⚠️ **If you need this, you are probably doing something wrong. Always use cache.guilds.get()?.emojis */ export async function getEmoji( - guildID: string, - emojiID: string, + guildId: string, + emojiId: string, addToCache = true, ) { const result = (await RequestManager.get( - endpoints.GUILD_EMOJI(guildID, emojiID), + endpoints.GUILD_EMOJI(guildId, emojiId), )) as Emoji; if (addToCache) { - const guild = await cacheHandlers.get("guilds", guildID); + const guild = await cacheHandlers.get("guilds", guildId); if (!guild) throw new Error(Errors.GUILD_NOT_FOUND); guild.emojis.set(result.id ?? result.name, result); cacheHandlers.set( "guilds", - guildID, + guildId, guild, ); } diff --git a/src/helpers/emojis/get_emojis.ts b/src/helpers/emojis/get_emojis.ts index fa1fa2f18..cd9527acc 100644 --- a/src/helpers/emojis/get_emojis.ts +++ b/src/helpers/emojis/get_emojis.ts @@ -7,18 +7,18 @@ import { endpoints } from "../../util/constants.ts"; * * ⚠️ **If you need this, you are probably doing something wrong. Always use cache.guilds.get()?.emojis */ -export async function getEmojis(guildID: string, addToCache = true) { +export async function getEmojis(guildId: string, addToCache = true) { const result = (await RequestManager.get( - endpoints.GUILD_EMOJIS(guildID), + endpoints.GUILD_EMOJIS(guildId), )) as Emoji[]; if (addToCache) { - const guild = await cacheHandlers.get("guilds", guildID); + const guild = await cacheHandlers.get("guilds", guildId); if (!guild) throw new Error(Errors.GUILD_NOT_FOUND); result.forEach((emoji) => guild.emojis.set(emoji.id ?? emoji.name, emoji)); - cacheHandlers.set("guilds", guildID, guild); + cacheHandlers.set("guilds", guildId, guild); } return result; diff --git a/src/helpers/guilds/delete_server.ts b/src/helpers/guilds/delete_server.ts index dd66c9188..89696ec54 100644 --- a/src/helpers/guilds/delete_server.ts +++ b/src/helpers/guilds/delete_server.ts @@ -3,8 +3,8 @@ import { endpoints } from "../../util/constants.ts"; /** Delete a guild permanently. User must be owner. Returns 204 No Content on success. Fires a Guild Delete Gateway event. */ -export async function deleteServer(guildID: string) { - const result = await RequestManager.delete(endpoints.GUILDS_BASE(guildID)); +export async function deleteServer(guildId: string) { + const result = await RequestManager.delete(endpoints.GUILDS_BASE(guildId)); return result; } diff --git a/src/helpers/guilds/edit_guild.ts b/src/helpers/guilds/edit_guild.ts index 5ef7345f1..5b76a4558 100644 --- a/src/helpers/guilds/edit_guild.ts +++ b/src/helpers/guilds/edit_guild.ts @@ -4,8 +4,8 @@ import { requireBotGuildPermissions } from "../../util/permissions.ts"; import { urlToBase64 } from "../../util/utils.ts"; /** Modify a guilds settings. Requires the MANAGE_GUILD permission. */ -export async function editGuild(guildID: string, options: GuildEditOptions) { - await requireBotGuildPermissions(guildID, ["MANAGE_GUILD"]); +export async function editGuild(guildId: string, options: GuildEditOptions) { + await requireBotGuildPermissions(guildId, ["MANAGE_GUILD"]); if (options.icon && !options.icon.startsWith("data:image/")) { options.icon = await urlToBase64(options.icon); @@ -20,7 +20,7 @@ export async function editGuild(guildID: string, options: GuildEditOptions) { } const result = await RequestManager.patch( - endpoints.GUILDS_BASE(guildID), + endpoints.GUILDS_BASE(guildId), options, ); diff --git a/src/helpers/guilds/edit_widget.ts b/src/helpers/guilds/edit_widget.ts index 9f7a91605..10cfdb082 100644 --- a/src/helpers/guilds/edit_widget.ts +++ b/src/helpers/guilds/edit_widget.ts @@ -4,15 +4,15 @@ import { requireBotGuildPermissions } from "../../util/permissions.ts"; /** Modify a guild widget object for the guild. Requires the MANAGE_GUILD permission. */ export async function editWidget( - guildID: string, + guildId: string, enabled: boolean, - channelID?: string | null, + channelId?: string | null, ) { - await requireBotGuildPermissions(guildID, ["MANAGE_GUILD"]); + await requireBotGuildPermissions(guildId, ["MANAGE_GUILD"]); - const result = await RequestManager.patch(endpoints.GUILD_WIDGET(guildID), { + const result = await RequestManager.patch(endpoints.GUILD_WIDGET(guildId), { enabled, - channel_id: channelID, + channel_id: channelId, }); return result; diff --git a/src/helpers/guilds/get_audit_logs.ts b/src/helpers/guilds/get_audit_logs.ts index a7984f276..1fc86101e 100644 --- a/src/helpers/guilds/get_audit_logs.ts +++ b/src/helpers/guilds/get_audit_logs.ts @@ -4,12 +4,12 @@ import { requireBotGuildPermissions } from "../../util/permissions.ts"; /** Returns the audit logs for the guild. Requires VIEW AUDIT LOGS permission */ export async function getAuditLogs( - guildID: string, + guildId: string, options: GetAuditLogsOptions, ) { - await requireBotGuildPermissions(guildID, ["VIEW_AUDIT_LOG"]); + await requireBotGuildPermissions(guildId, ["VIEW_AUDIT_LOG"]); - const result = await RequestManager.get(endpoints.GUILD_AUDIT_LOGS(guildID), { + const result = await RequestManager.get(endpoints.GUILD_AUDIT_LOGS(guildId), { ...options, action_type: options.action_type ? AuditLogs[options.action_type] diff --git a/src/helpers/guilds/get_ban.ts b/src/helpers/guilds/get_ban.ts index 69cde466d..be7fda64e 100644 --- a/src/helpers/guilds/get_ban.ts +++ b/src/helpers/guilds/get_ban.ts @@ -3,11 +3,11 @@ import { endpoints } from "../../util/constants.ts"; import { requireBotGuildPermissions } from "../../util/permissions.ts"; /** Returns a ban object for the given user or a 404 not found if the ban cannot be found. Requires the BAN_MEMBERS permission. */ -export async function getBan(guildID: string, memberID: string) { - await requireBotGuildPermissions(guildID, ["BAN_MEMBERS"]); +export async function getBan(guildId: string, memberId: string) { + await requireBotGuildPermissions(guildId, ["BAN_MEMBERS"]); const result = await RequestManager.get( - endpoints.GUILD_BAN(guildID, memberID), + endpoints.GUILD_BAN(guildId, memberId), ); return result as BannedUser; diff --git a/src/helpers/guilds/get_bans.ts b/src/helpers/guilds/get_bans.ts index 1a9a33212..f7b204421 100644 --- a/src/helpers/guilds/get_bans.ts +++ b/src/helpers/guilds/get_bans.ts @@ -4,11 +4,11 @@ import { endpoints } from "../../util/constants.ts"; import { requireBotGuildPermissions } from "../../util/permissions.ts"; /** Returns a list of ban objects for the users banned from this guild. Requires the BAN_MEMBERS permission. */ -export async function getBans(guildID: string) { - await requireBotGuildPermissions(guildID, ["BAN_MEMBERS"]); +export async function getBans(guildId: string) { + await requireBotGuildPermissions(guildId, ["BAN_MEMBERS"]); const results = (await RequestManager.get( - endpoints.GUILD_BANS(guildID), + endpoints.GUILD_BANS(guildId), )) as BannedUser[]; return new Collection( diff --git a/src/helpers/guilds/get_guild.ts b/src/helpers/guilds/get_guild.ts index a17603b69..f4482d181 100644 --- a/src/helpers/guilds/get_guild.ts +++ b/src/helpers/guilds/get_guild.ts @@ -8,8 +8,8 @@ import { endpoints } from "../../util/constants.ts"; * This function fetches a guild's data. This is not the same data as a GUILD_CREATE. * So it does not cache the guild, you must do it manually. * */ -export async function getGuild(guildID: string, counts = true) { - const result = await RequestManager.get(endpoints.GUILDS_BASE(guildID), { +export async function getGuild(guildId: string, counts = true) { + const result = await RequestManager.get(endpoints.GUILDS_BASE(guildId), { with_counts: counts, }); diff --git a/src/helpers/guilds/get_guild_preview.ts b/src/helpers/guilds/get_guild_preview.ts index dda89c735..5ad6812d7 100644 --- a/src/helpers/guilds/get_guild_preview.ts +++ b/src/helpers/guilds/get_guild_preview.ts @@ -2,8 +2,8 @@ import { RequestManager } from "../../rest/request_manager.ts"; import { endpoints } from "../../util/constants.ts"; /** Returns the guild preview object for the given id. If the bot is not in the guild, then the guild must be Discoverable. */ -export async function getGuildPreview(guildID: string) { - const result = await RequestManager.get(endpoints.GUILD_PREVIEW(guildID)); +export async function getGuildPreview(guildId: string) { + const result = await RequestManager.get(endpoints.GUILD_PREVIEW(guildId)); return result; } diff --git a/src/helpers/guilds/get_prune_count.ts b/src/helpers/guilds/get_prune_count.ts index e66ec1985..200ad5d39 100644 --- a/src/helpers/guilds/get_prune_count.ts +++ b/src/helpers/guilds/get_prune_count.ts @@ -1,19 +1,19 @@ import { RequestManager } from "../../rest/request_manager.ts"; import { endpoints } from "../../util/constants.ts"; import { requireBotGuildPermissions } from "../../util/permissions.ts"; -import { camelKeysToSnakeCase, urlToBase64 } from "../../util/utils.ts"; +import { camelKeysToSnakeCase } from "../../util/utils.ts"; /** Check how many members would be removed from the server in a prune operation. Requires the KICK_MEMBERS permission */ -export async function getPruneCount(guildID: string, options?: PruneOptions) { +export async function getPruneCount(guildId: string, options?: PruneOptions) { if (options?.days && options.days < 1) throw new Error(Errors.PRUNE_MIN_DAYS); if (options?.days && options.days > 30) { throw new Error(Errors.PRUNE_MAX_DAYS); } - await requireBotGuildPermissions(guildID, ["KICK_MEMBERS"]); + await requireBotGuildPermissions(guildId, ["KICK_MEMBERS"]); const result = await RequestManager.get( - endpoints.GUILD_PRUNE(guildID), + endpoints.GUILD_PRUNE(guildId), camelKeysToSnakeCase(options ?? {}), ) as PrunePayload; diff --git a/src/helpers/guilds/get_vainty_url.ts b/src/helpers/guilds/get_vainty_url.ts index 1b6e044cd..9c44fb19a 100644 --- a/src/helpers/guilds/get_vainty_url.ts +++ b/src/helpers/guilds/get_vainty_url.ts @@ -2,8 +2,8 @@ import { RequestManager } from "../../rest/request_manager.ts"; import { endpoints } from "../../util/constants.ts"; /** Returns the code and uses of the vanity url for this server if it is enabled. Requires the MANAGE_GUILD permission. */ -export async function getVanityURL(guildID: string) { - const result = await RequestManager.get(endpoints.GUILD_VANITY_URL(guildID)); +export async function getVanityURL(guildId: string) { + const result = await RequestManager.get(endpoints.GUILD_VANITY_URL(guildId)); return result; } diff --git a/src/helpers/guilds/get_voice_regions.ts b/src/helpers/guilds/get_voice_regions.ts index 008652087..828d7af62 100644 --- a/src/helpers/guilds/get_voice_regions.ts +++ b/src/helpers/guilds/get_voice_regions.ts @@ -2,8 +2,8 @@ import { RequestManager } from "../../rest/request_manager.ts"; import { endpoints } from "../../util/constants.ts"; /** Returns a list of voice region objects for the guild. Unlike the similar /voice route, this returns VIP servers when the guild is VIP-enabled. */ -export async function getVoiceRegions(guildID: string) { - const result = await RequestManager.get(endpoints.GUILD_REGIONS(guildID)); +export async function getVoiceRegions(guildId: string) { + const result = await RequestManager.get(endpoints.GUILD_REGIONS(guildId)); return result; } diff --git a/src/helpers/guilds/get_widget.ts b/src/helpers/guilds/get_widget.ts index 50908a39e..52f7adef7 100644 --- a/src/helpers/guilds/get_widget.ts +++ b/src/helpers/guilds/get_widget.ts @@ -3,12 +3,12 @@ import { RequestManager } from "../../rest/request_manager.ts"; import { endpoints } from "../../util/constants.ts"; /** Returns the widget for the guild. */ -export async function getWidget(guildID: string, options?: { force: boolean }) { +export async function getWidget(guildId: string, options?: { force: boolean }) { if (!options?.force) { - const guild = await cacheHandlers.get("guilds", guildID); + const guild = await cacheHandlers.get("guilds", guildId); if (!guild) throw new Error(Errors.GUILD_NOT_FOUND); if (!guild?.widgetEnabled) throw new Error(Errors.GUILD_WIDGET_NOT_ENABLED); } - return RequestManager.get(`${endpoints.GUILD_WIDGET(guildID)}.json`); + return RequestManager.get(`${endpoints.GUILD_WIDGET(guildId)}.json`); } diff --git a/src/helpers/guilds/get_widget_image_url.ts b/src/helpers/guilds/get_widget_image_url.ts index 6c58eb547..10605f4d8 100644 --- a/src/helpers/guilds/get_widget_image_url.ts +++ b/src/helpers/guilds/get_widget_image_url.ts @@ -3,18 +3,18 @@ import { endpoints } from "../../util/constants.ts"; /** Returns the widget image URL for the guild. */ export async function getWidgetImageURL( - guildID: string, + guildId: string, options?: { style?: "shield" | "banner1" | "banner2" | "banner3" | "banner4"; force?: boolean; }, ) { if (!options?.force) { - const guild = await cacheHandlers.get("guilds", guildID); + const guild = await cacheHandlers.get("guilds", guildId); if (!guild) throw new Error(Errors.GUILD_NOT_FOUND); if (!guild.widgetEnabled) throw new Error(Errors.GUILD_WIDGET_NOT_ENABLED); } - return `${endpoints.GUILD_WIDGET(guildID)}.png?style=${options?.style ?? + return `${endpoints.GUILD_WIDGET(guildId)}.png?style=${options?.style ?? "shield"}`; } diff --git a/src/helpers/guilds/get_widget_settings.ts b/src/helpers/guilds/get_widget_settings.ts index a4893eefb..dca0b2e7a 100644 --- a/src/helpers/guilds/get_widget_settings.ts +++ b/src/helpers/guilds/get_widget_settings.ts @@ -3,10 +3,10 @@ import { endpoints } from "../../util/constants.ts"; import { requireBotGuildPermissions } from "../../util/permissions.ts"; /** Returns the guild widget object. Requires the MANAGE_GUILD permission. */ -export async function getWidgetSettings(guildID: string) { - await requireBotGuildPermissions(guildID, ["MANAGE_GUILD"]); +export async function getWidgetSettings(guildId: string) { + await requireBotGuildPermissions(guildId, ["MANAGE_GUILD"]); - const result = await RequestManager.get(endpoints.GUILD_WIDGET(guildID)); + const result = await RequestManager.get(endpoints.GUILD_WIDGET(guildId)); return result; } diff --git a/src/helpers/guilds/leave_guild.ts b/src/helpers/guilds/leave_guild.ts index 78f1e3ed4..d52bf4eff 100644 --- a/src/helpers/guilds/leave_guild.ts +++ b/src/helpers/guilds/leave_guild.ts @@ -2,8 +2,8 @@ import { RequestManager } from "../../rest/request_manager.ts"; import { endpoints } from "../../util/constants.ts"; /** Leave a guild */ -export async function leaveGuild(guildID: string) { - const result = await RequestManager.delete(endpoints.GUILD_LEAVE(guildID)); +export async function leaveGuild(guildId: string) { + const result = await RequestManager.delete(endpoints.GUILD_LEAVE(guildId)); return result; } diff --git a/src/helpers/integrations/delete_integration.ts b/src/helpers/integrations/delete_integration.ts index 69f269a58..da0952ce8 100644 --- a/src/helpers/integrations/delete_integration.ts +++ b/src/helpers/integrations/delete_integration.ts @@ -3,11 +3,11 @@ import { endpoints } from "../../util/constants.ts"; import { requireBotGuildPermissions } from "../../util/permissions.ts"; /** Delete the attached integration object for the guild with this id. Requires MANAGE_GUILD permission. */ -export async function deleteIntegration(guildID: string, id: string) { - await requireBotGuildPermissions(guildID, ["MANAGE_GUILD"]); +export async function deleteIntegration(guildId: string, id: string) { + await requireBotGuildPermissions(guildId, ["MANAGE_GUILD"]); const result = await RequestManager.delete( - endpoints.GUILD_INTEGRATION(guildID, id), + endpoints.GUILD_INTEGRATION(guildId, id), ); return result; diff --git a/src/helpers/integrations/edit_integration.ts b/src/helpers/integrations/edit_integration.ts index a5d1e1c94..99b5c7b0c 100644 --- a/src/helpers/integrations/edit_integration.ts +++ b/src/helpers/integrations/edit_integration.ts @@ -4,14 +4,14 @@ import { requireBotGuildPermissions } from "../../util/permissions.ts"; /** Modify the behavior and settings of an integration object for the guild. Requires the MANAGE_GUILD permission. */ export async function editIntegration( - guildID: string, + guildId: string, id: string, options: EditIntegrationOptions, ) { - await requireBotGuildPermissions(guildID, ["MANAGE_GUILD"]); + await requireBotGuildPermissions(guildId, ["MANAGE_GUILD"]); const result = await RequestManager.patch( - endpoints.GUILD_INTEGRATION(guildID, id), + endpoints.GUILD_INTEGRATION(guildId, id), options, ); diff --git a/src/helpers/integrations/get_integrations.ts b/src/helpers/integrations/get_integrations.ts index 508862d8d..6ecf20487 100644 --- a/src/helpers/integrations/get_integrations.ts +++ b/src/helpers/integrations/get_integrations.ts @@ -3,11 +3,11 @@ import { endpoints } from "../../util/constants.ts"; import { requireBotGuildPermissions } from "../../util/permissions.ts"; /** Returns a list of integrations for the guild. Requires the MANAGE_GUILD permission. */ -export async function getIntegrations(guildID: string) { - await requireBotGuildPermissions(guildID, ["MANAGE_GUILD"]); +export async function getIntegrations(guildId: string) { + await requireBotGuildPermissions(guildId, ["MANAGE_GUILD"]); const result = await RequestManager.get( - endpoints.GUILD_INTEGRATIONS(guildID), + endpoints.GUILD_INTEGRATIONS(guildId), ); return result; diff --git a/src/helpers/integrations/sync_integration.ts b/src/helpers/integrations/sync_integration.ts index 43d4e0fa5..46c9656f3 100644 --- a/src/helpers/integrations/sync_integration.ts +++ b/src/helpers/integrations/sync_integration.ts @@ -3,11 +3,11 @@ import { endpoints } from "../../util/constants.ts"; import { requireBotGuildPermissions } from "../../util/permissions.ts"; /** Sync an integration. Requires the MANAGE_GUILD permission. */ -export async function syncIntegration(guildID: string, id: string) { - await requireBotGuildPermissions(guildID, ["MANAGE_GUILD"]); +export async function syncIntegration(guildId: string, id: string) { + await requireBotGuildPermissions(guildId, ["MANAGE_GUILD"]); const result = await RequestManager.post( - endpoints.GUILD_INTEGRATION_SYNC(guildID, id), + endpoints.GUILD_INTEGRATION_SYNC(guildId, id), ); return result; diff --git a/src/helpers/invites/create_invite.ts b/src/helpers/invites/create_invite.ts index 34ebc7a89..4b1c0cdb7 100644 --- a/src/helpers/invites/create_invite.ts +++ b/src/helpers/invites/create_invite.ts @@ -4,27 +4,27 @@ import { requireBotChannelPermissions } from "../../util/permissions.ts"; /** Creates a new invite for this channel. Requires CREATE_INSTANT_INVITE */ export async function createInvite( - channelID: string, + channelId: string, options: CreateInviteOptions, ) { - await requireBotChannelPermissions(channelID, ["CREATE_INSTANT_INVITE"]); + await requireBotChannelPermissions(channelId, ["CREATE_INSTANT_INVITE"]); if (options.max_age && (options.max_age > 604800 || options.max_age < 0)) { console.log( - `The max age for invite created in ${channelID} was not between 0-604800. Using default values instead.`, + `The max age for invite created in ${channelId} was not between 0-604800. Using default values instead.`, ); options.max_age = undefined; } if (options.max_uses && (options.max_uses > 100 || options.max_uses < 0)) { console.log( - `The max uses for invite created in ${channelID} was not between 0-100. Using default values instead.`, + `The max uses for invite created in ${channelId} was not between 0-100. Using default values instead.`, ); options.max_uses = undefined; } const result = await RequestManager.post( - endpoints.CHANNEL_INVITES(channelID), + endpoints.CHANNEL_INVITES(channelId), options, ); diff --git a/src/helpers/invites/delete_invite.ts b/src/helpers/invites/delete_invite.ts index 53ec1b9d0..25d3650de 100644 --- a/src/helpers/invites/delete_invite.ts +++ b/src/helpers/invites/delete_invite.ts @@ -7,8 +7,8 @@ import { } from "../../util/permissions.ts"; /** Deletes an invite for the given code. Requires `MANAGE_CHANNELS` or `MANAGE_GUILD` permission */ -export async function deleteInvite(channelID: string, inviteCode: string) { - const channel = await cacheHandlers.get("channels", channelID); +export async function deleteInvite(channelId: string, inviteCode: string) { + const channel = await cacheHandlers.get("channels", channelId); if (!channel) throw new Error(Errors.CHANNEL_NOT_FOUND); @@ -17,7 +17,7 @@ export async function deleteInvite(channelID: string, inviteCode: string) { ]); if (!hasPerm) { - await requireBotGuildPermissions(channel!.guildID, ["MANAGE_GUILD"]); + await requireBotGuildPermissions(channel!.guildId, ["MANAGE_GUILD"]); } const result = await RequestManager.delete(endpoints.INVITE(inviteCode)); diff --git a/src/helpers/invites/get_channel_invites.ts b/src/helpers/invites/get_channel_invites.ts index 65cac8155..893e63613 100644 --- a/src/helpers/invites/get_channel_invites.ts +++ b/src/helpers/invites/get_channel_invites.ts @@ -3,10 +3,10 @@ import { endpoints } from "../../util/constants.ts"; import { requireBotChannelPermissions } from "../../util/permissions.ts"; /** Gets the invites for this channel. Requires MANAGE_CHANNEL */ -export async function getChannelInvites(channelID: string) { - await requireBotChannelPermissions(channelID, ["MANAGE_CHANNELS"]); +export async function getChannelInvites(channelId: string) { + await requireBotChannelPermissions(channelId, ["MANAGE_CHANNELS"]); - const result = await RequestManager.get(endpoints.CHANNEL_INVITES(channelID)); + const result = await RequestManager.get(endpoints.CHANNEL_INVITES(channelId)); return result; } diff --git a/src/helpers/invites/get_invites.ts b/src/helpers/invites/get_invites.ts index 8dc9ed713..b8a3e80da 100644 --- a/src/helpers/invites/get_invites.ts +++ b/src/helpers/invites/get_invites.ts @@ -3,10 +3,10 @@ import { endpoints } from "../../util/constants.ts"; import { requireBotGuildPermissions } from "../../util/permissions.ts"; /** Get all the invites for this guild. Requires MANAGE_GUILD permission */ -export async function getInvites(guildID: string) { - await requireBotGuildPermissions(guildID, ["MANAGE_GUILD"]); +export async function getInvites(guildId: string) { + await requireBotGuildPermissions(guildId, ["MANAGE_GUILD"]); - const result = await RequestManager.get(endpoints.GUILD_INVITES(guildID)); + const result = await RequestManager.get(endpoints.GUILD_INVITES(guildId)); return result; } diff --git a/src/helpers/members/ban_member.ts b/src/helpers/members/ban_member.ts index 4eeedec30..cd070399e 100644 --- a/src/helpers/members/ban_member.ts +++ b/src/helpers/members/ban_member.ts @@ -3,10 +3,10 @@ import { endpoints } from "../../util/constants.ts"; import { requireBotGuildPermissions } from "../../util/permissions.ts"; /** Ban a user from the guild and optionally delete previous messages sent by the user. Requires the BAN_MEMBERS permission. */ -export async function ban(guildID: string, id: string, options: BanOptions) { - await requireBotGuildPermissions(guildID, ["BAN_MEMBERS"]); +export async function ban(guildId: string, id: string, options: BanOptions) { + await requireBotGuildPermissions(guildId, ["BAN_MEMBERS"]); - const result = await RequestManager.put(endpoints.GUILD_BAN(guildID, id), { + const result = await RequestManager.put(endpoints.GUILD_BAN(guildId, id), { ...options, delete_message_days: options.days, }); diff --git a/src/helpers/members/disconnect_member.ts b/src/helpers/members/disconnect_member.ts index a9f192cb0..1d308a255 100644 --- a/src/helpers/members/disconnect_member.ts +++ b/src/helpers/members/disconnect_member.ts @@ -1,6 +1,6 @@ import { editMember } from "./edit_member.ts"; /** Kicks a member from a voice channel */ -export function disconnectMember(guildID: string, memberID: string) { - return editMember(guildID, memberID, { channel_id: null }); +export function disconnectMember(guildId: string, memberId: string) { + return editMember(guildId, memberId, { channel_id: null }); } diff --git a/src/helpers/members/edit_bot_nickname.ts b/src/helpers/members/edit_bot_nickname.ts index 66cdc206e..1f76fbc65 100644 --- a/src/helpers/members/edit_bot_nickname.ts +++ b/src/helpers/members/edit_bot_nickname.ts @@ -4,13 +4,13 @@ import { requireBotGuildPermissions } from "../../util/permissions.ts"; /** Edit the nickname of the bot in this guild */ export async function editBotNickname( - guildID: string, + guildId: string, nickname: string | null, ) { - await requireBotGuildPermissions(guildID, ["CHANGE_NICKNAME"]); + await requireBotGuildPermissions(guildId, ["CHANGE_NICKNAME"]); const response = await RequestManager.patch( - endpoints.USER_NICK(guildID), + endpoints.USER_NICK(guildId), { nick: nickname }, ) as { nick: string }; diff --git a/src/helpers/members/edit_member.ts b/src/helpers/members/edit_member.ts index 5868369f4..4543ac1f2 100644 --- a/src/helpers/members/edit_member.ts +++ b/src/helpers/members/edit_member.ts @@ -9,8 +9,8 @@ import { /** Edit the member */ export async function editMember( - guildID: string, - memberID: string, + guildId: string, + memberId: string, options: EditMemberOptions, ) { const requiredPerms: Set = new Set(); @@ -29,10 +29,10 @@ export async function editMember( typeof options.deaf !== "undefined" || (typeof options.channel_id !== "undefined" || "null") ) { - const memberVoiceState = (await cacheHandlers.get("guilds", guildID)) - ?.voiceStates.get(memberID); + const memberVoiceState = (await cacheHandlers.get("guilds", guildId)) + ?.voiceStates.get(memberId); - if (!memberVoiceState?.channelID) { + if (!memberVoiceState?.channelId) { throw new Error(Errors.MEMBER_NOT_IN_VOICE_CHANNEL); } @@ -51,7 +51,7 @@ export async function editMember( ]); if (memberVoiceState) { await requireBotChannelPermissions( - memberVoiceState?.channelID, + memberVoiceState?.channelId, [...requiredVoicePerms], ); } @@ -62,13 +62,13 @@ export async function editMember( } } - await requireBotGuildPermissions(guildID, [...requiredPerms]); + await requireBotGuildPermissions(guildId, [...requiredPerms]); const result = await RequestManager.patch( - endpoints.GUILD_MEMBER(guildID, memberID), + endpoints.GUILD_MEMBER(guildId, memberId), options, ) as MemberCreatePayload; - const member = await structures.createMemberStruct(result, guildID); + const member = await structures.createMemberStruct(result, guildId); return member; } diff --git a/src/helpers/members/fetch_members.ts b/src/helpers/members/fetch_members.ts index f8596f14f..448f13eac 100644 --- a/src/helpers/members/fetch_members.ts +++ b/src/helpers/members/fetch_members.ts @@ -12,8 +12,8 @@ import { requestAllMembers } from "../../ws/shard_manager.ts"; * GW(this function): 120/m(PER shard) rate limit. Meaning if you have 8 shards your limit is now 960/m. */ export function fetchMembers( - guildID: string, - shardID: number, + guildId: string, + shardId: number, options?: FetchMembersOptions, ) { // You can request 1 member without the intent @@ -24,11 +24,11 @@ export function fetchMembers( throw new Error(Errors.MISSING_INTENT_GUILD_MEMBERS); } - if (options?.userIDs?.length) { - options.limit = options.userIDs.length; + if (options?.userIds?.length) { + options.limit = options.userIds.length; } return new Promise((resolve) => { - return requestAllMembers(guildID, shardID, resolve, options); + return requestAllMembers(guildId, shardId, resolve, options); }) as Promise>; } diff --git a/src/helpers/members/get_member.ts b/src/helpers/members/get_member.ts index bb647d600..4603ee0ca 100644 --- a/src/helpers/members/get_member.ts +++ b/src/helpers/members/get_member.ts @@ -8,18 +8,18 @@ import { endpoints } from "../../util/constants.ts"; * ⚠️ **ADVANCED USE ONLY: Your members will be cached in your guild most likely. Only use this when you are absolutely sure the member is not cached.** */ export async function getMember( - guildID: string, + guildId: string, id: string, options?: { force?: boolean }, ) { - const guild = await cacheHandlers.get("guilds", guildID); + const guild = await cacheHandlers.get("guilds", guildId); if (!guild && !options?.force) return; const data = (await RequestManager.get( - endpoints.GUILD_MEMBER(guildID, id), + endpoints.GUILD_MEMBER(guildId, id), )) as MemberCreatePayload; - const memberStruct = await structures.createMemberStruct(data, guildID); + const memberStruct = await structures.createMemberStruct(data, guildId); await cacheHandlers.set("members", memberStruct.id, memberStruct); return memberStruct; diff --git a/src/helpers/members/get_members.ts b/src/helpers/members/get_members.ts index 8d9928caf..19ec8f2f3 100644 --- a/src/helpers/members/get_members.ts +++ b/src/helpers/members/get_members.ts @@ -13,12 +13,12 @@ import { endpoints } from "../../util/constants.ts"; * REST(this function): 50/s global(across all shards) rate limit with ALL requests this included * GW(fetchMembers): 120/m(PER shard) rate limit. Meaning if you have 8 shards your limit is 960/m. */ -export async function getMembers(guildID: string, options?: GetMemberOptions) { +export async function getMembers(guildId: string, options?: GetMemberOptions) { if (!(identifyPayload.intents && Intents.GUILD_MEMBERS)) { throw new Error(Errors.MISSING_INTENT_GUILD_MEMBERS); } - const guild = await cacheHandlers.get("guilds", guildID); + const guild = await cacheHandlers.get("guilds", guildId); if (!guild) throw new Error(Errors.GUILD_NOT_FOUND); const members = new Collection(); @@ -40,7 +40,7 @@ export async function getMembers(guildID: string, options?: GetMemberOptions) { } const result = (await RequestManager.get( - `${endpoints.GUILD_MEMBERS(guildID)}?limit=${ + `${endpoints.GUILD_MEMBERS(guildId)}?limit=${ membersLeft > 1000 ? 1000 : membersLeft }${options?.after ? `&after=${options.after}` : ""}`, )) as MemberCreatePayload[]; @@ -49,7 +49,7 @@ export async function getMembers(guildID: string, options?: GetMemberOptions) { result.map(async (member) => { const memberStruct = await structures.createMemberStruct( member, - guildID, + guildId, ); await cacheHandlers.set("members", memberStruct.id, memberStruct); diff --git a/src/helpers/members/get_members_by_query.ts b/src/helpers/members/get_members_by_query.ts index d2a296aca..770f8147d 100644 --- a/src/helpers/members/get_members_by_query.ts +++ b/src/helpers/members/get_members_by_query.ts @@ -8,15 +8,15 @@ import { requestAllMembers } from "../../ws/shard_manager.ts"; * ⚠️ **ADVANCED USE ONLY: Your members will be cached in your guild most likely. Only use this when you are absolutely sure the member is not cached.** */ export async function getMembersByQuery( - guildID: string, + guildId: string, name: string, limit = 1, ) { - const guild = await cacheHandlers.get("guilds", guildID); + const guild = await cacheHandlers.get("guilds", guildId); if (!guild) return; return new Promise((resolve) => { - return requestAllMembers(guild.id, guild.shardID, resolve, { + return requestAllMembers(guild.id, guild.shardId, resolve, { query: name, limit, }); diff --git a/src/helpers/members/kick_member.ts b/src/helpers/members/kick_member.ts index d42bdadd0..60b62ba90 100644 --- a/src/helpers/members/kick_member.ts +++ b/src/helpers/members/kick_member.ts @@ -1,4 +1,4 @@ -import { botID } from "../../bot.ts"; +import { botId } from "../../bot.ts"; import { RequestManager } from "../../rest/request_manager.ts"; import { endpoints } from "../../util/constants.ts"; import { @@ -7,9 +7,9 @@ import { } from "../../util/permissions.ts"; /** Kick a member from the server */ -export async function kick(guildID: string, memberID: string, reason?: string) { - const botsHighestRole = await highestRole(guildID, botID); - const membersHighestRole = await highestRole(guildID, memberID); +export async function kick(guildId: string, memberId: string, reason?: string) { + const botsHighestRole = await highestRole(guildId, botId); + const membersHighestRole = await highestRole(guildId, memberId); if ( botsHighestRole && membersHighestRole && botsHighestRole.position <= membersHighestRole.position @@ -17,10 +17,10 @@ export async function kick(guildID: string, memberID: string, reason?: string) { throw new Error(Errors.BOTS_HIGHEST_ROLE_TOO_LOW); } - await requireBotGuildPermissions(guildID, ["KICK_MEMBERS"]); + await requireBotGuildPermissions(guildId, ["KICK_MEMBERS"]); const result = await RequestManager.delete( - endpoints.GUILD_MEMBER(guildID, memberID), + endpoints.GUILD_MEMBER(guildId, memberId), { reason }, ); diff --git a/src/helpers/members/move_member.ts b/src/helpers/members/move_member.ts index 504cd971e..02d707974 100644 --- a/src/helpers/members/move_member.ts +++ b/src/helpers/members/move_member.ts @@ -2,14 +2,14 @@ import { editMember } from "./edit_member.ts"; /** * Move a member from a voice channel to another. - * @param guildID the id of the guild which the channel exists in - * @param memberID the id of the member to move. - * @param channelID id of channel to move user to (if they are connected to voice) + * @param guildId the id of the guild which the channel exists in + * @param memberId the id of the member to move. + * @param channelId id of channel to move user to (if they are connected to voice) */ export function moveMember( - guildID: string, - memberID: string, - channelID: string, + guildId: string, + memberId: string, + channelId: string, ) { - return editMember(guildID, memberID, { channel_id: channelID }); + return editMember(guildId, memberId, { channel_id: channelId }); } diff --git a/src/helpers/members/prune_members.ts b/src/helpers/members/prune_members.ts index 312af2f66..9529080cd 100644 --- a/src/helpers/members/prune_members.ts +++ b/src/helpers/members/prune_members.ts @@ -9,16 +9,16 @@ import { camelKeysToSnakeCase } from "../../util/utils.ts"; * By default, prune will not remove users with roles. You can optionally include specific roles in your prune by providing the roles (resolved to include_roles internally) parameter. Any inactive user that has a subset of the provided role(s) will be included in the prune and users with additional roles will not. */ export async function pruneMembers( - guildID: string, + guildId: string, options: PruneOptions, ) { if (options.days && options.days < 1) throw new Error(Errors.PRUNE_MIN_DAYS); if (options.days && options.days > 30) throw new Error(Errors.PRUNE_MAX_DAYS); - await requireBotGuildPermissions(guildID, ["KICK_MEMBERS"]); + await requireBotGuildPermissions(guildId, ["KICK_MEMBERS"]); const result = await RequestManager.post( - endpoints.GUILD_PRUNE(guildID), + endpoints.GUILD_PRUNE(guildId), camelKeysToSnakeCase(options), ); diff --git a/src/helpers/members/raw_avatar_url.ts b/src/helpers/members/raw_avatar_url.ts index 4cd366f9b..c95d5c5d6 100644 --- a/src/helpers/members/raw_avatar_url.ts +++ b/src/helpers/members/raw_avatar_url.ts @@ -3,13 +3,13 @@ import { formatImageURL } from "../../util/utils.ts"; /** The users custom avatar or the default avatar if you don't have a member object. */ export function rawAvatarURL( - userID: string, + userId: string, discriminator: string, avatar?: string | null, size: ImageSize = 128, format?: ImageFormats, ) { return avatar - ? formatImageURL(endpoints.USER_AVATAR(userID, avatar), size, format) + ? formatImageURL(endpoints.USER_AVATAR(userId, avatar), size, format) : endpoints.USER_DEFAULT_AVATAR(Number(discriminator) % 5); } diff --git a/src/helpers/members/send_direct_message.ts b/src/helpers/members/send_direct_message.ts index 5fe20fe26..ad501297c 100644 --- a/src/helpers/members/send_direct_message.ts +++ b/src/helpers/members/send_direct_message.ts @@ -6,21 +6,21 @@ import { sendMessage } from "../messages/send_message.ts"; /** Send a message to a users DM. Note: this takes 2 API calls. 1 is to fetch the users dm channel. 2 is to send a message to that channel. */ export async function sendDirectMessage( - memberID: string, + memberId: string, content: string | MessageContent, ) { - let dmChannel = await cacheHandlers.get("channels", memberID); + let dmChannel = await cacheHandlers.get("channels", memberId); if (!dmChannel) { // If not available in cache create a new one. const dmChannelData = await RequestManager.post( endpoints.USER_DM, - { recipient_id: memberID }, + { recipient_id: memberId }, ) as DMChannelCreatePayload; const channelStruct = await structures.createChannelStruct( dmChannelData as unknown as ChannelCreatePayload, ); // Recreate the channel and add it undert he users id - await cacheHandlers.set("channels", memberID, channelStruct); + await cacheHandlers.set("channels", memberId, channelStruct); dmChannel = channelStruct; } diff --git a/src/helpers/members/unban_member.ts b/src/helpers/members/unban_member.ts index f3149454f..242472bca 100644 --- a/src/helpers/members/unban_member.ts +++ b/src/helpers/members/unban_member.ts @@ -3,10 +3,10 @@ import { endpoints } from "../../util/constants.ts"; import { requireBotGuildPermissions } from "../../util/permissions.ts"; /** Remove the ban for a user. Requires BAN_MEMBERS permission */ -export async function unban(guildID: string, id: string) { - await requireBotGuildPermissions(guildID, ["BAN_MEMBERS"]); +export async function unban(guildId: string, id: string) { + await requireBotGuildPermissions(guildId, ["BAN_MEMBERS"]); - const result = await RequestManager.delete(endpoints.GUILD_BAN(guildID, id)); + const result = await RequestManager.delete(endpoints.GUILD_BAN(guildId, id)); return result; } diff --git a/src/helpers/messages/add_reaction.ts b/src/helpers/messages/add_reaction.ts index 0e8009fb7..06db2b89e 100644 --- a/src/helpers/messages/add_reaction.ts +++ b/src/helpers/messages/add_reaction.ts @@ -4,11 +4,11 @@ import { requireBotChannelPermissions } from "../../util/permissions.ts"; /** Create a reaction for the message. Reaction takes the form of **name:id** for custom guild emoji, or Unicode characters. Requires READ_MESSAGE_HISTORY and ADD_REACTIONS */ export async function addReaction( - channelID: string, - messageID: string, + channelId: string, + messageId: string, reaction: string, ) { - await requireBotChannelPermissions(channelID, [ + await requireBotChannelPermissions(channelId, [ "ADD_REACTIONS", "READ_MESSAGE_HISTORY", ]); @@ -20,7 +20,7 @@ export async function addReaction( } const result = await RequestManager.put( - endpoints.CHANNEL_MESSAGE_REACTION_ME(channelID, messageID, reaction), + endpoints.CHANNEL_MESSAGE_REACTION_ME(channelId, messageId, reaction), ); return result; diff --git a/src/helpers/messages/add_reactions.ts b/src/helpers/messages/add_reactions.ts index 57457129b..3ce1190a0 100644 --- a/src/helpers/messages/add_reactions.ts +++ b/src/helpers/messages/add_reactions.ts @@ -2,18 +2,18 @@ import { addReaction } from "./add_reaction.ts"; /** Adds multiple reactions to a message. If `ordered` is true(default is false), it will add the reactions one at a time in the order provided. Note: Reaction takes the form of **name:id** for custom guild emoji, or Unicode characters. Requires READ_MESSAGE_HISTORY and ADD_REACTIONS */ export async function addReactions( - channelID: string, - messageID: string, + channelId: string, + messageId: string, reactions: string[], ordered = false, ) { if (!ordered) { await Promise.all( - reactions.map((reaction) => addReaction(channelID, messageID, reaction)), + reactions.map((reaction) => addReaction(channelId, messageId, reaction)), ); } else { for (const reaction of reactions) { - await addReaction(channelID, messageID, reaction); + await addReaction(channelId, messageId, reaction); } } } diff --git a/src/helpers/messages/delete_message.ts b/src/helpers/messages/delete_message.ts index a1f5672ff..806b97302 100644 --- a/src/helpers/messages/delete_message.ts +++ b/src/helpers/messages/delete_message.ts @@ -1,4 +1,4 @@ -import { botID } from "../../bot.ts"; +import { botId } from "../../bot.ts"; import { cacheHandlers } from "../../cache.ts"; import { RequestManager } from "../../rest/request_manager.ts"; import { endpoints } from "../../util/constants.ts"; @@ -7,21 +7,21 @@ import { delay } from "../../util/utils.ts"; /** Delete a message with the channel id and message id only. */ export async function deleteMessage( - channelID: string, - messageID: string, + channelId: string, + messageId: string, reason?: string, delayMilliseconds = 0, ) { - const message = await cacheHandlers.get("messages", messageID); + const message = await cacheHandlers.get("messages", messageId); - if (message && message.author.id !== botID) { - await requireBotChannelPermissions(message.channelID, ["MANAGE_MESSAGES"]); + if (message && message.author.id !== botId) { + await requireBotChannelPermissions(message.channelId, ["MANAGE_MESSAGES"]); } if (delayMilliseconds) await delay(delayMilliseconds); const result = await RequestManager.delete( - endpoints.CHANNEL_MESSAGE(channelID, messageID), + endpoints.CHANNEL_MESSAGE(channelId, messageId), { reason }, ); diff --git a/src/helpers/messages/delete_messages.ts b/src/helpers/messages/delete_messages.ts index 2a3bddfe1..ac11cbea8 100644 --- a/src/helpers/messages/delete_messages.ts +++ b/src/helpers/messages/delete_messages.ts @@ -4,11 +4,11 @@ import { requireBotChannelPermissions } from "../../util/permissions.ts"; /** Delete messages from the channel. 2-100. Requires the MANAGE_MESSAGES permission */ export async function deleteMessages( - channelID: string, + channelId: string, ids: string[], reason?: string, ) { - await requireBotChannelPermissions(channelID, ["MANAGE_MESSAGES"]); + await requireBotChannelPermissions(channelId, ["MANAGE_MESSAGES"]); if (ids.length < 2) { throw new Error(Errors.DELETE_MESSAGES_MIN); @@ -21,7 +21,7 @@ export async function deleteMessages( } const result = await RequestManager.post( - endpoints.CHANNEL_BULK_DELETE(channelID), + endpoints.CHANNEL_BULK_DELETE(channelId), { messages: ids.splice(0, 100), reason, diff --git a/src/helpers/messages/edit_message.ts b/src/helpers/messages/edit_message.ts index d730faad2..1a49d0a47 100644 --- a/src/helpers/messages/edit_message.ts +++ b/src/helpers/messages/edit_message.ts @@ -1,4 +1,4 @@ -import { botID } from "../../bot.ts"; +import { botId } from "../../bot.ts"; import { RequestManager } from "../../rest/request_manager.ts"; import { Message, structures } from "../../structures/mod.ts"; import { endpoints } from "../../util/constants.ts"; @@ -9,7 +9,7 @@ export async function editMessage( message: Message, content: string | MessageContent, ) { - if (message.author.id !== botID) { + if (message.author.id !== botId) { throw "You can only edit a message that was sent by the bot."; } @@ -19,14 +19,14 @@ export async function editMessage( if (content.tts) requiredPerms.push("SEND_TTS_MESSAGES"); - await requireBotChannelPermissions(message.channelID, requiredPerms); + await requireBotChannelPermissions(message.channelId, requiredPerms); if (content.content && content.content.length > 2000) { throw new Error(Errors.MESSAGE_MAX_LENGTH); } const result = await RequestManager.patch( - endpoints.CHANNEL_MESSAGE(message.channelID, message.id), + endpoints.CHANNEL_MESSAGE(message.channelId, message.id), content, ); diff --git a/src/helpers/messages/get_message.ts b/src/helpers/messages/get_message.ts index 3eaa5bcf6..3c389b163 100644 --- a/src/helpers/messages/get_message.ts +++ b/src/helpers/messages/get_message.ts @@ -4,14 +4,14 @@ import { endpoints } from "../../util/constants.ts"; import { requireBotChannelPermissions } from "../../util/permissions.ts"; /** Fetch a single message from the server. Requires VIEW_CHANNEL and READ_MESSAGE_HISTORY */ -export async function getMessage(channelID: string, id: string) { - await requireBotChannelPermissions(channelID, [ +export async function getMessage(channelId: string, id: string) { + await requireBotChannelPermissions(channelId, [ "VIEW_CHANNEL", "READ_MESSAGE_HISTORY", ]); const result = (await RequestManager.get( - endpoints.CHANNEL_MESSAGE(channelID, id), + endpoints.CHANNEL_MESSAGE(channelId, id), )) as MessageCreateOptions; return structures.createMessageStruct(result); diff --git a/src/helpers/messages/get_messages.ts b/src/helpers/messages/get_messages.ts index fbe74316b..c3f0c8639 100644 --- a/src/helpers/messages/get_messages.ts +++ b/src/helpers/messages/get_messages.ts @@ -5,14 +5,14 @@ import { requireBotChannelPermissions } from "../../util/permissions.ts"; /** Fetches between 2-100 messages. Requires VIEW_CHANNEL and READ_MESSAGE_HISTORY */ export async function getMessages( - channelID: string, + channelId: string, options?: | GetMessagesAfter | GetMessagesBefore | GetMessagesAround | GetMessages, ) { - await requireBotChannelPermissions(channelID, [ + await requireBotChannelPermissions(channelId, [ "VIEW_CHANNEL", "READ_MESSAGE_HISTORY", ]); @@ -20,7 +20,7 @@ export async function getMessages( if (options?.limit && options.limit > 100) return; const result = (await RequestManager.get( - endpoints.CHANNEL_MESSAGES(channelID), + endpoints.CHANNEL_MESSAGES(channelId), options, )) as MessageCreateOptions[]; diff --git a/src/helpers/messages/get_reactions.ts b/src/helpers/messages/get_reactions.ts index 96f37820b..4d6ab8f52 100644 --- a/src/helpers/messages/get_reactions.ts +++ b/src/helpers/messages/get_reactions.ts @@ -4,13 +4,13 @@ import { endpoints } from "../../util/constants.ts"; /** Get a list of users that reacted with this emoji. */ export async function getReactions( - channelID: string, - messageID: string, + channelId: string, + messageId: string, reaction: string, options?: DiscordGetReactionsParams, ) { const users = (await RequestManager.get( - endpoints.CHANNEL_MESSAGE_REACTION(channelID, messageID, reaction), + endpoints.CHANNEL_MESSAGE_REACTION(channelId, messageId, reaction), options, )) as UserPayload[]; diff --git a/src/helpers/messages/pin_message.ts b/src/helpers/messages/pin_message.ts index 65cdf8161..8c860fcf8 100644 --- a/src/helpers/messages/pin_message.ts +++ b/src/helpers/messages/pin_message.ts @@ -3,11 +3,11 @@ import { endpoints } from "../../util/constants.ts"; import { requireBotChannelPermissions } from "../../util/permissions.ts"; /** Pin a message in a channel. Requires MANAGE_MESSAGES. Max pins allowed in a channel = 50. */ -export async function pin(channelID: string, messageID: string) { - await requireBotChannelPermissions(channelID, ["MANAGE_MESSAGES"]); +export async function pin(channelId: string, messageId: string) { + await requireBotChannelPermissions(channelId, ["MANAGE_MESSAGES"]); const result = await RequestManager.put( - endpoints.CHANNEL_PIN(channelID, messageID), + endpoints.CHANNEL_PIN(channelId, messageId), ); return result; diff --git a/src/helpers/messages/publish_message.ts b/src/helpers/messages/publish_message.ts index fc7b64b0c..e3dde4f59 100644 --- a/src/helpers/messages/publish_message.ts +++ b/src/helpers/messages/publish_message.ts @@ -3,9 +3,9 @@ import { structures } from "../../structures/mod.ts"; import { endpoints } from "../../util/constants.ts"; /** Crosspost a message in a News Channel to following channels. */ -export async function publishMessage(channelID: string, messageID: string) { +export async function publishMessage(channelId: string, messageId: string) { const data = (await RequestManager.post( - endpoints.CHANNEL_MESSAGE_CROSSPOST(channelID, messageID), + endpoints.CHANNEL_MESSAGE_CROSSPOST(channelId, messageId), )) as MessageCreateOptions; return structures.createMessageStruct(data); diff --git a/src/helpers/messages/remove_all_reactions.ts b/src/helpers/messages/remove_all_reactions.ts index 5fd6ddea6..e0bfdefb6 100644 --- a/src/helpers/messages/remove_all_reactions.ts +++ b/src/helpers/messages/remove_all_reactions.ts @@ -3,11 +3,11 @@ import { endpoints } from "../../util/constants.ts"; import { requireBotChannelPermissions } from "../../util/permissions.ts"; /** Removes all reactions for all emojis on this message. */ -export async function removeAllReactions(channelID: string, messageID: string) { - await requireBotChannelPermissions(channelID, ["MANAGE_MESSAGES"]); +export async function removeAllReactions(channelId: string, messageId: string) { + await requireBotChannelPermissions(channelId, ["MANAGE_MESSAGES"]); const result = await RequestManager.delete( - endpoints.CHANNEL_MESSAGE_REACTIONS(channelID, messageID), + endpoints.CHANNEL_MESSAGE_REACTIONS(channelId, messageId), ); return result; diff --git a/src/helpers/messages/remove_reaction.ts b/src/helpers/messages/remove_reaction.ts index 09de64090..c36ec4136 100644 --- a/src/helpers/messages/remove_reaction.ts +++ b/src/helpers/messages/remove_reaction.ts @@ -3,8 +3,8 @@ import { endpoints } from "../../util/constants.ts"; /** Removes a reaction from the bot on this message. Reaction takes the form of **name:id** for custom guild emoji, or Unicode characters. */ export async function removeReaction( - channelID: string, - messageID: string, + channelId: string, + messageId: string, reaction: string, ) { if (reaction.startsWith("<:")) { @@ -14,7 +14,7 @@ export async function removeReaction( } const result = await RequestManager.delete( - endpoints.CHANNEL_MESSAGE_REACTION_ME(channelID, messageID, reaction), + endpoints.CHANNEL_MESSAGE_REACTION_ME(channelId, messageId, reaction), ); return result; diff --git a/src/helpers/messages/remove_reaction_emoji.ts b/src/helpers/messages/remove_reaction_emoji.ts index 3941b3fae..a92bae07d 100644 --- a/src/helpers/messages/remove_reaction_emoji.ts +++ b/src/helpers/messages/remove_reaction_emoji.ts @@ -4,11 +4,11 @@ import { requireBotChannelPermissions } from "../../util/permissions.ts"; /** Removes all reactions for a single emoji on this message. Reaction takes the form of **name:id** for custom guild emoji, or Unicode characters. */ export async function removeReactionEmoji( - channelID: string, - messageID: string, + channelId: string, + messageId: string, reaction: string, ) { - await requireBotChannelPermissions(channelID, ["MANAGE_MESSAGES"]); + await requireBotChannelPermissions(channelId, ["MANAGE_MESSAGES"]); if (reaction.startsWith("<:")) { reaction = reaction.substring(2, reaction.length - 1); @@ -17,7 +17,7 @@ export async function removeReactionEmoji( } const result = await RequestManager.delete( - endpoints.CHANNEL_MESSAGE_REACTION(channelID, messageID, reaction), + endpoints.CHANNEL_MESSAGE_REACTION(channelId, messageId, reaction), ); return result; diff --git a/src/helpers/messages/remove_user_reaction.ts b/src/helpers/messages/remove_user_reaction.ts index 844669a1b..1fe4b951b 100644 --- a/src/helpers/messages/remove_user_reaction.ts +++ b/src/helpers/messages/remove_user_reaction.ts @@ -4,12 +4,12 @@ import { requireBotChannelPermissions } from "../../util/permissions.ts"; /** Removes a reaction from the specified user on this message. Reaction takes the form of **name:id** for custom guild emoji, or Unicode characters. */ export async function removeUserReaction( - channelID: string, - messageID: string, + channelId: string, + messageId: string, reaction: string, - userID: string, + userId: string, ) { - await requireBotChannelPermissions(channelID, ["MANAGE_MESSAGES"]); + await requireBotChannelPermissions(channelId, ["MANAGE_MESSAGES"]); if (reaction.startsWith("<:")) { reaction = reaction.substring(2, reaction.length - 1); @@ -19,10 +19,10 @@ export async function removeUserReaction( const result = await RequestManager.delete( endpoints.CHANNEL_MESSAGE_REACTION_USER( - channelID, - messageID, + channelId, + messageId, reaction, - userID, + userId, ), ); diff --git a/src/helpers/messages/send_message.ts b/src/helpers/messages/send_message.ts index d1780870c..98c53260b 100644 --- a/src/helpers/messages/send_message.ts +++ b/src/helpers/messages/send_message.ts @@ -6,12 +6,12 @@ import { requireBotChannelPermissions } from "../../util/permissions.ts"; /** Send a message to the channel. Requires SEND_MESSAGES permission. */ export async function sendMessage( - channelID: string, + channelId: string, content: string | MessageContent, ) { if (typeof content === "string") content = { content }; - const channel = await cacheHandlers.get("channels", channelID); + const channel = await cacheHandlers.get("channels", channelId); if (channel) { if ( ![ @@ -30,11 +30,11 @@ export async function sendMessage( if (content.tts) requiredPerms.add("SEND_TTS_MESSAGES"); if (content.embed) requiredPerms.add("EMBED_LINKS"); - if (content.replyMessageID || content.mentions?.repliedUser) { + if (content.replyMessageId || content.mentions?.repliedUser) { requiredPerms.add("READ_MESSAGE_HISTORY"); } - await requireBotChannelPermissions(channelID, [...requiredPerms]); + await requireBotChannelPermissions(channelId, [...requiredPerms]); } // Use ... for content length due to unicode characters and js .length handling @@ -69,7 +69,7 @@ export async function sendMessage( } const result = (await RequestManager.post( - endpoints.CHANNEL_MESSAGES(channelID), + endpoints.CHANNEL_MESSAGES(channelId), { ...content, allowed_mentions: content.mentions @@ -78,10 +78,10 @@ export async function sendMessage( replied_user: content.mentions.repliedUser, } : undefined, - ...(content.replyMessageID + ...(content.replyMessageId ? { message_reference: { - message_id: content.replyMessageID, + message_id: content.replyMessageId, fail_if_not_exists: content.failReplyIfNotExists === true, }, } diff --git a/src/helpers/messages/unpin_message.ts b/src/helpers/messages/unpin_message.ts index 0f4179142..499e533c7 100644 --- a/src/helpers/messages/unpin_message.ts +++ b/src/helpers/messages/unpin_message.ts @@ -3,11 +3,11 @@ import { endpoints } from "../../util/constants.ts"; import { requireBotChannelPermissions } from "../../util/permissions.ts"; /** Unpin a message in a channel. Requires MANAGE_MESSAGES. */ -export async function unpin(channelID: string, messageID: string) { - await requireBotChannelPermissions(channelID, ["MANAGE_MESSAGES"]); +export async function unpin(channelId: string, messageId: string) { + await requireBotChannelPermissions(channelId, ["MANAGE_MESSAGES"]); const result = await RequestManager.delete( - endpoints.CHANNEL_PIN(channelID, messageID), + endpoints.CHANNEL_PIN(channelId, messageId), ); return result; diff --git a/src/helpers/misc/get_user.ts b/src/helpers/misc/get_user.ts index b7304977c..de8a77eea 100644 --- a/src/helpers/misc/get_user.ts +++ b/src/helpers/misc/get_user.ts @@ -2,8 +2,8 @@ import { RequestManager } from "../../rest/request_manager.ts"; import { endpoints } from "../../util/constants.ts"; /** This function will return the raw user payload in the rare cases you need to fetch a user directly from the API. */ -export async function getUser(userID: string) { - const result = await RequestManager.get(endpoints.USER(userID)); +export async function getUser(userId: string) { + const result = await RequestManager.get(endpoints.USER(userId)); return result as UserPayload; } diff --git a/src/helpers/mod.ts b/src/helpers/mod.ts index a0c9fd190..5a54f89b6 100644 --- a/src/helpers/mod.ts +++ b/src/helpers/mod.ts @@ -1,4 +1,4 @@ -import { categoryChildrenIDs } from "./channels/category_children_ids.ts"; +import { categoryChildrenIds } from "./channels/category_children_ids.ts"; import { channelOverwriteHasPermission } from "./channels/channel_overwrite_has_permission.ts"; import { createChannel } from "./channels/create_channel.ts"; import { deleteChannel } from "./channels/delete_channel.ts"; @@ -124,7 +124,7 @@ export { avatarURL, ban, banMember, - categoryChildrenIDs, + categoryChildrenIds, channelOverwriteHasPermission, createChannel, createEmoji, @@ -276,7 +276,7 @@ export let helpers = { getEmoji, getEmojis, // guilds - categoryChildrenIDs, + categoryChildrenIds, createGuild, deleteServer, editGuild, diff --git a/src/helpers/roles/add_role.ts b/src/helpers/roles/add_role.ts index c982b35d6..f6b810d8e 100644 --- a/src/helpers/roles/add_role.ts +++ b/src/helpers/roles/add_role.ts @@ -1,4 +1,4 @@ -import { botID } from "../../bot.ts"; +import { botId } from "../../bot.ts"; import { RequestManager } from "../../rest/request_manager.ts"; import { endpoints } from "../../util/constants.ts"; import { @@ -8,24 +8,24 @@ import { /** Add a role to the member */ export async function addRole( - guildID: string, - memberID: string, - roleID: string, + guildId: string, + memberId: string, + roleId: string, reason?: string, ) { const isHigherRolePosition = await isHigherPosition( - guildID, - botID, - roleID, + guildId, + botId, + roleId, ); if (!isHigherRolePosition) { throw new Error(Errors.BOTS_HIGHEST_ROLE_TOO_LOW); } - await requireBotGuildPermissions(guildID, ["MANAGE_ROLES"]); + await requireBotGuildPermissions(guildId, ["MANAGE_ROLES"]); const result = await RequestManager.put( - endpoints.GUILD_MEMBER_ROLE(guildID, memberID, roleID), + endpoints.GUILD_MEMBER_ROLE(guildId, memberId, roleId), { reason }, ); diff --git a/src/helpers/roles/create_role.ts b/src/helpers/roles/create_role.ts index 7b1ae37f1..07657d428 100644 --- a/src/helpers/roles/create_role.ts +++ b/src/helpers/roles/create_role.ts @@ -9,13 +9,13 @@ import { /** Create a new role for the guild. Requires the MANAGE_ROLES permission. */ export async function createRole( - guildID: string, + guildId: string, options: CreateRoleOptions, reason?: string, ) { - await requireBotGuildPermissions(guildID, ["MANAGE_ROLES"]); + await requireBotGuildPermissions(guildId, ["MANAGE_ROLES"]); - const result = await RequestManager.post(endpoints.GUILD_ROLES(guildID), { + const result = await RequestManager.post(endpoints.GUILD_ROLES(guildId), { ...options, permissions: calculateBits(options?.permissions || []), reason, @@ -23,7 +23,7 @@ export async function createRole( const roleData = result as RoleData; const role = await structures.createRoleStruct(roleData); - const guild = await cacheHandlers.get("guilds", guildID); + const guild = await cacheHandlers.get("guilds", guildId); guild?.roles.set(role.id, role); return role; diff --git a/src/helpers/roles/delete_role.ts b/src/helpers/roles/delete_role.ts index fca6f21ed..543e12f5e 100644 --- a/src/helpers/roles/delete_role.ts +++ b/src/helpers/roles/delete_role.ts @@ -3,10 +3,10 @@ import { endpoints } from "../../util/constants.ts"; import { requireBotGuildPermissions } from "../../util/permissions.ts"; /** Delete a guild role. Requires the MANAGE_ROLES permission. */ -export async function deleteRole(guildID: string, id: string) { - await requireBotGuildPermissions(guildID, ["MANAGE_ROLES"]); +export async function deleteRole(guildId: string, id: string) { + await requireBotGuildPermissions(guildId, ["MANAGE_ROLES"]); - const result = await RequestManager.delete(endpoints.GUILD_ROLE(guildID, id)); + const result = await RequestManager.delete(endpoints.GUILD_ROLE(guildId, id)); return result; } diff --git a/src/helpers/roles/edit_role.ts b/src/helpers/roles/edit_role.ts index c645aa1d2..94ea6768d 100644 --- a/src/helpers/roles/edit_role.ts +++ b/src/helpers/roles/edit_role.ts @@ -7,13 +7,13 @@ import { /** Edit a guild role. Requires the MANAGE_ROLES permission. */ export async function editRole( - guildID: string, + guildId: string, id: string, options: CreateRoleOptions, ) { - await requireBotGuildPermissions(guildID, ["MANAGE_ROLES"]); + await requireBotGuildPermissions(guildId, ["MANAGE_ROLES"]); - const result = await RequestManager.patch(endpoints.GUILD_ROLE(guildID, id), { + const result = await RequestManager.patch(endpoints.GUILD_ROLE(guildId, id), { ...options, permissions: options.permissions ? calculateBits(options.permissions) diff --git a/src/helpers/roles/get_roles.ts b/src/helpers/roles/get_roles.ts index 509446ef1..4b5e8a6da 100644 --- a/src/helpers/roles/get_roles.ts +++ b/src/helpers/roles/get_roles.ts @@ -6,10 +6,10 @@ import { requireBotGuildPermissions } from "../../util/permissions.ts"; * * ⚠️ **If you need this, you are probably doing something wrong. This is not intended for use. Your roles will be cached in your guild.** */ -export async function getRoles(guildID: string) { - await requireBotGuildPermissions(guildID, ["MANAGE_ROLES"]); +export async function getRoles(guildId: string) { + await requireBotGuildPermissions(guildId, ["MANAGE_ROLES"]); - const result = await RequestManager.get(endpoints.GUILD_ROLES(guildID)); + const result = await RequestManager.get(endpoints.GUILD_ROLES(guildId)); return result; } diff --git a/src/helpers/roles/remove_role.ts b/src/helpers/roles/remove_role.ts index c8df51938..e59e583c0 100644 --- a/src/helpers/roles/remove_role.ts +++ b/src/helpers/roles/remove_role.ts @@ -1,4 +1,4 @@ -import { botID } from "../../bot.ts"; +import { botId } from "../../bot.ts"; import { RequestManager } from "../../rest/request_manager.ts"; import { endpoints } from "../../util/constants.ts"; import { @@ -8,15 +8,15 @@ import { /** Remove a role from the member */ export async function removeRole( - guildID: string, - memberID: string, - roleID: string, + guildId: string, + memberId: string, + roleId: string, reason?: string, ) { const isHigherRolePosition = await isHigherPosition( - guildID, - botID, - roleID, + guildId, + botId, + roleId, ); if ( !isHigherRolePosition @@ -24,10 +24,10 @@ export async function removeRole( throw new Error(Errors.BOTS_HIGHEST_ROLE_TOO_LOW); } - await requireBotGuildPermissions(guildID, ["MANAGE_ROLES"]); + await requireBotGuildPermissions(guildId, ["MANAGE_ROLES"]); const result = await RequestManager.delete( - endpoints.GUILD_MEMBER_ROLE(guildID, memberID, roleID), + endpoints.GUILD_MEMBER_ROLE(guildId, memberId, roleId), { reason }, ); diff --git a/src/helpers/roles/swap_roles.ts b/src/helpers/roles/swap_roles.ts index cdb8daf63..37b45f067 100644 --- a/src/helpers/roles/swap_roles.ts +++ b/src/helpers/roles/swap_roles.ts @@ -3,11 +3,11 @@ import { endpoints } from "../../util/constants.ts"; import { requireBotGuildPermissions } from "../../util/permissions.ts"; /** Modify the positions of a set of role objects for the guild. Requires the MANAGE_ROLES permission. */ -export async function swapRoles(guildID: string, rolePositons: PositionSwap) { - await requireBotGuildPermissions(guildID, ["MANAGE_ROLES"]); +export async function swapRoles(guildId: string, rolePositons: PositionSwap) { + await requireBotGuildPermissions(guildId, ["MANAGE_ROLES"]); const result = await RequestManager.patch( - endpoints.GUILD_ROLES(guildID), + endpoints.GUILD_ROLES(guildId), rolePositons, ); diff --git a/src/helpers/templates/create_guild_template.ts b/src/helpers/templates/create_guild_template.ts index 4e50d7063..94999710c 100644 --- a/src/helpers/templates/create_guild_template.ts +++ b/src/helpers/templates/create_guild_template.ts @@ -10,10 +10,10 @@ import { requireBotGuildPermissions } from "../../util/permissions.ts"; * @param description description for the template (0-120 characters */ export async function createGuildTemplate( - guildID: string, + guildId: string, data: CreateGuildTemplate, ) { - await requireBotGuildPermissions(guildID, ["MANAGE_GUILD"]); + await requireBotGuildPermissions(guildId, ["MANAGE_GUILD"]); if (data.name.length < 1 || data.name.length > 100) { throw new Error("The name can only be in between 1-100 characters."); @@ -24,7 +24,7 @@ export async function createGuildTemplate( } const template = (await RequestManager.post( - endpoints.GUILD_TEMPLATES(guildID), + endpoints.GUILD_TEMPLATES(guildId), data, )) as GuildTemplate; diff --git a/src/helpers/templates/delete_guild_template.ts b/src/helpers/templates/delete_guild_template.ts index 6b1a4d68f..c6ecb7faf 100644 --- a/src/helpers/templates/delete_guild_template.ts +++ b/src/helpers/templates/delete_guild_template.ts @@ -8,13 +8,13 @@ import { requireBotGuildPermissions } from "../../util/permissions.ts"; * Requires the `MANAGE_GUILD` permission. */ export async function deleteGuildTemplate( - guildID: string, + guildId: string, templateCode: string, ) { - await requireBotGuildPermissions(guildID, ["MANAGE_GUILD"]); + await requireBotGuildPermissions(guildId, ["MANAGE_GUILD"]); const deletedTemplate = (await RequestManager.delete( - `${endpoints.GUILD_TEMPLATES(guildID)}/${templateCode}`, + `${endpoints.GUILD_TEMPLATES(guildId)}/${templateCode}`, )) as GuildTemplate; return structures.createTemplateStruct(deletedTemplate); diff --git a/src/helpers/templates/edit_guild_template.ts b/src/helpers/templates/edit_guild_template.ts index 88845ae7e..b2ed01ca6 100644 --- a/src/helpers/templates/edit_guild_template.ts +++ b/src/helpers/templates/edit_guild_template.ts @@ -8,11 +8,11 @@ import { requireBotGuildPermissions } from "../../util/permissions.ts"; * Requires the `MANAGE_GUILD` permission. */ export async function editGuildTemplate( - guildID: string, + guildId: string, templateCode: string, data: EditGuildTemplate, ) { - await requireBotGuildPermissions(guildID, ["MANAGE_GUILD"]); + await requireBotGuildPermissions(guildId, ["MANAGE_GUILD"]); if (data.name?.length && (data.name.length < 1 || data.name.length > 100)) { throw new Error("The name can only be in between 1-100 characters."); @@ -23,7 +23,7 @@ export async function editGuildTemplate( } const template = (await RequestManager.patch( - `${endpoints.GUILD_TEMPLATES(guildID)}/${templateCode}`, + `${endpoints.GUILD_TEMPLATES(guildId)}/${templateCode}`, data, )) as GuildTemplate; diff --git a/src/helpers/templates/get_guild_templates.ts b/src/helpers/templates/get_guild_templates.ts index e35ea6661..a383caea8 100644 --- a/src/helpers/templates/get_guild_templates.ts +++ b/src/helpers/templates/get_guild_templates.ts @@ -7,11 +7,11 @@ import { requireBotGuildPermissions } from "../../util/permissions.ts"; * Returns an array of templates. * Requires the `MANAGE_GUILD` permission. */ -export async function getGuildTemplates(guildID: string) { - await requireBotGuildPermissions(guildID, ["MANAGE_GUILD"]); +export async function getGuildTemplates(guildId: string) { + await requireBotGuildPermissions(guildId, ["MANAGE_GUILD"]); const templates = (await RequestManager.get( - endpoints.GUILD_TEMPLATES(guildID), + endpoints.GUILD_TEMPLATES(guildId), )) as GuildTemplate[]; return templates.map((template) => structures.createTemplateStruct(template)); diff --git a/src/helpers/templates/sync_guild_template.ts b/src/helpers/templates/sync_guild_template.ts index fe0cb11ba..ba02f47f0 100644 --- a/src/helpers/templates/sync_guild_template.ts +++ b/src/helpers/templates/sync_guild_template.ts @@ -7,11 +7,11 @@ import { requireBotGuildPermissions } from "../../util/permissions.ts"; * Syncs the template to the guild's current state. * Requires the `MANAGE_GUILD` permission. */ -export async function syncGuildTemplate(guildID: string, templateCode: string) { - await requireBotGuildPermissions(guildID, ["MANAGE_GUILD"]); +export async function syncGuildTemplate(guildId: string, templateCode: string) { + await requireBotGuildPermissions(guildId, ["MANAGE_GUILD"]); const template = (await RequestManager.put( - `${endpoints.GUILD_TEMPLATES(guildID)}/${templateCode}`, + `${endpoints.GUILD_TEMPLATES(guildId)}/${templateCode}`, )) as GuildTemplate; return structures.createTemplateStruct(template); diff --git a/src/helpers/webhooks/create_webhook.ts b/src/helpers/webhooks/create_webhook.ts index a073ea343..7efa04e57 100644 --- a/src/helpers/webhooks/create_webhook.ts +++ b/src/helpers/webhooks/create_webhook.ts @@ -9,10 +9,10 @@ import { urlToBase64 } from "../../util/utils.ts"; * Webhook names cannot be: 'clyde' */ export async function createWebhook( - channelID: string, + channelId: string, options: WebhookCreateOptions, ) { - await requireBotChannelPermissions(channelID, ["MANAGE_WEBHOOKS"]); + await requireBotChannelPermissions(channelId, ["MANAGE_WEBHOOKS"]); if ( // Specific usernames that discord does not allow @@ -25,7 +25,7 @@ export async function createWebhook( } const result = await RequestManager.post( - endpoints.CHANNEL_WEBHOOKS(channelID), + endpoints.CHANNEL_WEBHOOKS(channelId), { ...options, avatar: options.avatar ? await urlToBase64(options.avatar) : undefined, diff --git a/src/helpers/webhooks/delete_webhook.ts b/src/helpers/webhooks/delete_webhook.ts index 2834aefe8..d92aca7e7 100644 --- a/src/helpers/webhooks/delete_webhook.ts +++ b/src/helpers/webhooks/delete_webhook.ts @@ -3,10 +3,10 @@ import { endpoints } from "../../util/constants.ts"; import { requireBotChannelPermissions } from "../../util/permissions.ts"; /** Delete a webhook permanently. Requires the `MANAGE_WEBHOOKS` permission. Returns a undefined on success */ -export async function deleteWebhook(channelID: string, webhookID: string) { - await requireBotChannelPermissions(channelID, ["MANAGE_WEBHOOKS"]); +export async function deleteWebhook(channelId: string, webhookId: string) { + await requireBotChannelPermissions(channelId, ["MANAGE_WEBHOOKS"]); - const result = await RequestManager.delete(endpoints.WEBHOOK_ID(webhookID)); + const result = await RequestManager.delete(endpoints.WEBHOOK_ID(webhookId)); return result; } diff --git a/src/helpers/webhooks/delete_webhook_message.ts b/src/helpers/webhooks/delete_webhook_message.ts index 4741d2b79..b8ece8d41 100644 --- a/src/helpers/webhooks/delete_webhook_message.ts +++ b/src/helpers/webhooks/delete_webhook_message.ts @@ -2,12 +2,12 @@ import { RequestManager } from "../../rest/request_manager.ts"; import { endpoints } from "../../util/constants.ts"; export async function deleteWebhookMessage( - webhookID: string, + webhookId: string, webhookToken: string, - messageID: string, + messageId: string, ) { const result = await RequestManager.delete( - endpoints.WEBHOOK_MESSAGE(webhookID, webhookToken, messageID), + endpoints.WEBHOOK_MESSAGE(webhookId, webhookToken, messageId), ); return result; diff --git a/src/helpers/webhooks/delete_webhook_with_token.ts b/src/helpers/webhooks/delete_webhook_with_token.ts index 5230f7eb7..f7e8c823e 100644 --- a/src/helpers/webhooks/delete_webhook_with_token.ts +++ b/src/helpers/webhooks/delete_webhook_with_token.ts @@ -3,11 +3,11 @@ import { endpoints } from "../../util/constants.ts"; /** Delete a webhook permanently. Returns a undefined on success */ export async function deleteWebhookWithToken( - webhookID: string, + webhookId: string, webhookToken: string, ) { const result = await RequestManager.delete( - endpoints.WEBHOOK(webhookID, webhookToken), + endpoints.WEBHOOK(webhookId, webhookToken), ); return result; diff --git a/src/helpers/webhooks/edit_webhook.ts b/src/helpers/webhooks/edit_webhook.ts index 3d2c70ca2..f5ee7d59e 100644 --- a/src/helpers/webhooks/edit_webhook.ts +++ b/src/helpers/webhooks/edit_webhook.ts @@ -4,15 +4,15 @@ import { requireBotChannelPermissions } from "../../util/permissions.ts"; /** Edit a webhook. Requires the `MANAGE_WEBHOOKS` permission. Returns the updated webhook object on success. */ export async function editWebhook( - channelID: string, - webhookID: string, + channelId: string, + webhookId: string, options: WebhookEditOptions, ) { - await requireBotChannelPermissions(channelID, ["MANAGE_WEBHOOKS"]); + await requireBotChannelPermissions(channelId, ["MANAGE_WEBHOOKS"]); - const result = await RequestManager.patch(endpoints.WEBHOOK_ID(webhookID), { + const result = await RequestManager.patch(endpoints.WEBHOOK_ID(webhookId), { ...options, - channel_id: options.channelID, + channel_id: options.channelId, }); return result as WebhookPayload; diff --git a/src/helpers/webhooks/edit_webhook_message.ts b/src/helpers/webhooks/edit_webhook_message.ts index 5d3176910..4d0571803 100644 --- a/src/helpers/webhooks/edit_webhook_message.ts +++ b/src/helpers/webhooks/edit_webhook_message.ts @@ -3,9 +3,9 @@ import { structures } from "../../structures/mod.ts"; import { endpoints } from "../../util/constants.ts"; export async function editWebhookMessage( - webhookID: string, + webhookId: string, webhookToken: string, - messageID: string, + messageId: string, options: EditWebhookMessageOptions, ) { if (options.content && options.content.length > 2000) { @@ -49,7 +49,7 @@ export async function editWebhookMessage( } const result = await RequestManager.patch( - endpoints.WEBHOOK_MESSAGE(webhookID, webhookToken, messageID), + endpoints.WEBHOOK_MESSAGE(webhookId, webhookToken, messageId), { ...options, allowed_mentions: options.allowed_mentions }, ) as MessageCreateOptions; diff --git a/src/helpers/webhooks/edit_webhook_with_token.ts b/src/helpers/webhooks/edit_webhook_with_token.ts index e8f19d0b8..1563f77d5 100644 --- a/src/helpers/webhooks/edit_webhook_with_token.ts +++ b/src/helpers/webhooks/edit_webhook_with_token.ts @@ -3,12 +3,12 @@ import { endpoints } from "../../util/constants.ts"; /** Edit a webhook. Returns the updated webhook object on success. */ export async function editWebhookWithToken( - webhookID: string, + webhookId: string, webhookToken: string, - options: Omit, + options: Omit, ) { const result = await RequestManager.patch( - endpoints.WEBHOOK(webhookID, webhookToken), + endpoints.WEBHOOK(webhookId, webhookToken), options, ); diff --git a/src/helpers/webhooks/execute_webhook.ts b/src/helpers/webhooks/execute_webhook.ts index f60b7dd7f..637722aa1 100644 --- a/src/helpers/webhooks/execute_webhook.ts +++ b/src/helpers/webhooks/execute_webhook.ts @@ -2,9 +2,9 @@ import { RequestManager } from "../../rest/request_manager.ts"; import { structures } from "../../structures/mod.ts"; import { endpoints } from "../../util/constants.ts"; -/** Execute a webhook with webhook ID and webhook token */ +/** Execute a webhook with webhook Id and webhook token */ export async function executeWebhook( - webhookID: string, + webhookId: string, webhookToken: string, options: ExecuteWebhookOptions, ) { @@ -47,7 +47,7 @@ export async function executeWebhook( } const result = await RequestManager.post( - `${endpoints.WEBHOOK(webhookID, webhookToken)}${ + `${endpoints.WEBHOOK(webhookId, webhookToken)}${ options.wait ? "?wait=true" : "" }`, { diff --git a/src/helpers/webhooks/get_webhook.ts b/src/helpers/webhooks/get_webhook.ts index e983554e0..a98020ab3 100644 --- a/src/helpers/webhooks/get_webhook.ts +++ b/src/helpers/webhooks/get_webhook.ts @@ -2,8 +2,8 @@ import { RequestManager } from "../../rest/request_manager.ts"; import { endpoints } from "../../util/constants.ts"; /** Returns the new webhook object for the given id. */ -export async function getWebhook(webhookID: string) { - const result = await RequestManager.get(endpoints.WEBHOOK_ID(webhookID)); +export async function getWebhook(webhookId: string) { + const result = await RequestManager.get(endpoints.WEBHOOK_ID(webhookId)); return result as WebhookPayload; } diff --git a/src/helpers/webhooks/get_webhook_with_token.ts b/src/helpers/webhooks/get_webhook_with_token.ts index db004a13c..1bbc35218 100644 --- a/src/helpers/webhooks/get_webhook_with_token.ts +++ b/src/helpers/webhooks/get_webhook_with_token.ts @@ -2,8 +2,8 @@ import { RequestManager } from "../../rest/request_manager.ts"; import { endpoints } from "../../util/constants.ts"; /** Returns the new webhook object for the given id, this call does not require authentication and returns no user in the webhook object. */ -export async function getWebhookWithToken(webhookID: string, token: string) { - const result = await RequestManager.get(endpoints.WEBHOOK(webhookID, token)); +export async function getWebhookWithToken(webhookId: string, token: string) { + const result = await RequestManager.get(endpoints.WEBHOOK(webhookId, token)); return result as WebhookPayload; } diff --git a/src/helpers/webhooks/get_webhooks.ts b/src/helpers/webhooks/get_webhooks.ts index 680921958..dd4e08667 100644 --- a/src/helpers/webhooks/get_webhooks.ts +++ b/src/helpers/webhooks/get_webhooks.ts @@ -3,10 +3,10 @@ import { endpoints } from "../../util/constants.ts"; import { requireBotGuildPermissions } from "../../util/permissions.ts"; /** Returns a list of guild webhooks objects. Requires the MANAGE_WEBHOOKs permission. */ -export async function getWebhooks(guildID: string) { - await requireBotGuildPermissions(guildID, ["MANAGE_WEBHOOKS"]); +export async function getWebhooks(guildId: string) { + await requireBotGuildPermissions(guildId, ["MANAGE_WEBHOOKS"]); - const result = await RequestManager.get(endpoints.GUILD_WEBHOOKS(guildID)); + const result = await RequestManager.get(endpoints.GUILD_WEBHOOKS(guildId)); return result; } diff --git a/src/rest/queue.ts b/src/rest/queue.ts index ec08e130a..90ee1fcc8 100644 --- a/src/rest/queue.ts +++ b/src/rest/queue.ts @@ -27,8 +27,8 @@ export async function processQueue(id: string) { continue; } // IF A BUCKET EXISTS, CHECK THE BUCKET'S RATE LIMITS - const bucketResetIn = queuedRequest.payload.bucketID - ? checkRateLimits(queuedRequest.payload.bucketID) + const bucketResetIn = queuedRequest.payload.bucketId + ? checkRateLimits(queuedRequest.payload.bucketId) : false; // THIS BUCKET IS STILL RATELIMITED, RE-ADD TO QUEUE if (bucketResetIn) continue; @@ -56,7 +56,7 @@ export async function processQueue(id: string) { createRequestBody(queuedRequest), ); restCache.eventHandlers.fetched(queuedRequest.payload); - const bucketIDFromHeaders = processRequestHeaders( + const bucketIdFromHeaders = processRequestHeaders( queuedRequest.request.url, response.headers, ); @@ -125,9 +125,9 @@ export async function processQueue(id: string) { continue; } - // SET THE BUCKET ID IF IT WAS PRESENT - if (bucketIDFromHeaders) { - queuedRequest.payload.bucketID = bucketIDFromHeaders; + // SET THE BUCKET Id IF IT WAS PRESENT + if (bucketIdFromHeaders) { + queuedRequest.payload.bucketId = bucketIdFromHeaders; } // SINCE IT WAS RATELIMITE, RETRY AGAIN continue; diff --git a/src/rest/request.ts b/src/rest/request.ts index 84913774e..75851df04 100644 --- a/src/rest/request.ts +++ b/src/rest/request.ts @@ -93,7 +93,7 @@ export function processRequestHeaders(url: string, headers: Headers) { const resetTimestamp = headers.get("x-ratelimit-reset"); const retryAfter = headers.get("retry-after"); const global = headers.get("x-ratelimit-global"); - const bucketID = headers.get("x-ratelimit-bucket"); + const bucketId = headers.get("x-ratelimit-bucket"); // IF THERE IS NO REMAINING RATE LIMIT, MARK IT AS RATE LIMITED if (remaining && remaining === "0") { @@ -103,15 +103,15 @@ export function processRequestHeaders(url: string, headers: Headers) { restCache.ratelimitedPaths.set(url, { url, resetTimestamp: Number(resetTimestamp) * 1000, - bucketID, + bucketId, }); // SAVE THE BUCKET AS LIMITED SINCE DIFFERENT URLS MAY SHARE A BUCKET - if (bucketID) { - restCache.ratelimitedPaths.set(bucketID, { + if (bucketId) { + restCache.ratelimitedPaths.set(bucketId, { url, resetTimestamp: Number(resetTimestamp) * 1000, - bucketID, + bucketId, }); } } @@ -126,19 +126,19 @@ export function processRequestHeaders(url: string, headers: Headers) { restCache.ratelimitedPaths.set("global", { url: "global", resetTimestamp: reset, - bucketID, + bucketId, }); - if (bucketID) { - restCache.ratelimitedPaths.set(bucketID, { + if (bucketId) { + restCache.ratelimitedPaths.set(bucketId, { url: "global", resetTimestamp: reset, - bucketID, + bucketId, }); } } - return ratelimited ? bucketID : undefined; + return ratelimited ? bucketId : undefined; } /** This wll create a infinite loop running in 1 seconds using tail recursion to keep rate limits clean. When a rate limit resets, this will remove it so the queue can proceed. */ diff --git a/src/rest/request_manager.ts b/src/rest/request_manager.ts index 65db5c2bc..7a13f77d0 100644 --- a/src/rest/request_manager.ts +++ b/src/rest/request_manager.ts @@ -60,8 +60,8 @@ async function processQueue() { const rateLimitedURLResetIn = await checkRatelimits(request.url); - if (request.bucketID) { - const rateLimitResetIn = await checkRatelimits(request.bucketID); + if (request.bucketId) { + const rateLimitResetIn = await checkRatelimits(request.bucketId); if (rateLimitResetIn) { // This request is still rate limited readd to queue addToQueue(request); @@ -73,7 +73,7 @@ async function processQueue() { const result = await request.callback(); if (result && result.rateLimited) { addToQueue( - { ...request, bucketID: result.bucketID || request.bucketID }, + { ...request, bucketId: result.bucketId || request.bucketId }, ); } } @@ -86,7 +86,7 @@ async function processQueue() { const result = await request.callback(); if (request && result && result.rateLimited) { addToQueue( - { ...request, bucketID: result.bucketID || request.bucketID }, + { ...request, bucketId: result.bucketId || request.bucketId }, ); } } @@ -179,12 +179,12 @@ function runMethod( url: string, body?: unknown, retryCount = 0, - bucketID?: string | null, + bucketId?: string | null, ) { eventHandlers.debug?.( { type: "requestCreate", - data: { method, url, body, retryCount, bucketID }, + data: { method, url, body, retryCount, bucketId }, }, ); @@ -221,7 +221,7 @@ function runMethod( try { const rateLimitResetIn = await checkRatelimits(url); if (rateLimitResetIn) { - return { rateLimited: rateLimitResetIn, beforeFetch: true, bucketID }; + return { rateLimited: rateLimitResetIn, beforeFetch: true, bucketId }; } const query = method === "get" && body @@ -237,17 +237,17 @@ function runMethod( eventHandlers.debug?.( { type: "requestFetch", - data: { method, url, body, retryCount, bucketID }, + data: { method, url, body, retryCount, bucketId }, }, ); const response = await fetch(urlToUse, createRequestBody(body, method)); eventHandlers.debug?.( { type: "requestFetched", - data: { method, url, body, retryCount, bucketID, response }, + data: { method, url, body, retryCount, bucketId, response }, }, ); - const bucketIDFromHeaders = processHeaders(url, response.headers); + const bucketIdFromHeaders = processHeaders(url, response.headers); await handleStatusCode(response, errorStack); // Sometimes Discord returns an empty 204 response that can't be made to JSON. @@ -262,7 +262,7 @@ function runMethod( eventHandlers.debug?.( { type: "error", - data: { method, url, body, retryCount, bucketID, errorStack }, + data: { method, url, body, retryCount, bucketId, errorStack }, }, ); throw new Error(Errors.RATE_LIMIT_RETRY_MAXED); @@ -271,14 +271,14 @@ function runMethod( return { rateLimited: json.retry_after, beforeFetch: false, - bucketID: bucketIDFromHeaders, + bucketId: bucketIdFromHeaders, }; } eventHandlers.debug?.( { type: "requestSuccess", - data: { method, url, body, retryCount, bucketID }, + data: { method, url, body, retryCount, bucketId }, }, ); return resolve(json); @@ -286,7 +286,7 @@ function runMethod( eventHandlers.debug?.( { type: "error", - data: { method, url, body, retryCount, bucketID, errorStack }, + data: { method, url, body, retryCount, bucketId, errorStack }, }, ); return reject(error); @@ -295,7 +295,7 @@ function runMethod( addToQueue({ callback, - bucketID, + bucketId, url, }); if (!queueInProcess) { @@ -376,7 +376,7 @@ function processHeaders(url: string, headers: Headers) { const resetTimestamp = headers.get("x-ratelimit-reset"); const retryAfter = headers.get("retry-after"); const global = headers.get("x-ratelimit-global"); - const bucketID = headers.get("x-ratelimit-bucket"); + const bucketId = headers.get("x-ratelimit-bucket"); // If there is no remaining rate limit for this endpoint, we save it in cache if (remaining && remaining === "0") { @@ -385,14 +385,14 @@ function processHeaders(url: string, headers: Headers) { ratelimitedPaths.set(url, { url, resetTimestamp: Number(resetTimestamp) * 1000, - bucketID, + bucketId, }); - if (bucketID) { - ratelimitedPaths.set(bucketID, { + if (bucketId) { + ratelimitedPaths.set(bucketId, { url, resetTimestamp: Number(resetTimestamp) * 1000, - bucketID, + bucketId, }); } } @@ -409,14 +409,14 @@ function processHeaders(url: string, headers: Headers) { ratelimitedPaths.set("global", { url: "global", resetTimestamp: reset, - bucketID, + bucketId, }); - if (bucketID) { - ratelimitedPaths.set(bucketID, { + if (bucketId) { + ratelimitedPaths.set(bucketId, { url: "global", resetTimestamp: reset, - bucketID, + bucketId, }); } } @@ -424,7 +424,7 @@ function processHeaders(url: string, headers: Headers) { if (ratelimited) { eventHandlers.rateLimit?.({ remaining, - bucketID, + bucketId, global, resetTimestamp, retryAfter, @@ -432,5 +432,5 @@ function processHeaders(url: string, headers: Headers) { }); } - return ratelimited ? bucketID : undefined; + return ratelimited ? bucketId : undefined; } diff --git a/src/structures/channel.ts b/src/structures/channel.ts index e9af9169d..e04f49b20 100644 --- a/src/structures/channel.ts +++ b/src/structures/channel.ts @@ -8,23 +8,20 @@ import { sendMessage } from "../helpers/messages/send_message.ts"; import { disconnectMember } from "../helpers/mod.ts"; import { Collection } from "../util/collection.ts"; import { createNewProp } from "../util/utils.ts"; -import { CleanVoiceState, Guild } from "./guild.ts"; -import { Member } from "./member.ts"; -import { Message } from "./message.ts"; const baseChannel: Partial = { get guild() { - return cache.guilds.get(this.guildID!); + return cache.guilds.get(this.guildId!); }, get messages() { - return cache.messages.filter((m) => m.channelID === this.id!); + return cache.messages.filter((m) => m.channelId === this.id!); }, get mention() { return `<#${this.id!}>`; }, get voiceStates() { return this.guild?.voiceStates.filter((voiceState) => - voiceState.channelID === this.id + voiceState.channelId === this.id ); }, get connectedMembers() { @@ -38,21 +35,21 @@ const baseChannel: Partial = { send(content) { return sendMessage(this.id!, content); }, - disconnect(memberID) { - return disconnectMember(this.guildID!, memberID); + disconnect(memberId) { + return disconnectMember(this.guildId!, memberId); }, delete() { - return deleteChannel(this.guildID!, this.id!); + return deleteChannel(this.guildId!, this.id!); }, editOverwrite(id, options) { - return editChannelOverwrite(this.guildID!, this.id!, id, options); + return editChannelOverwrite(this.guildId!, this.id!, id, options); }, deleteOverwrite(id) { - return deleteChannelOverwrite(this.guildID!, this.id!, id); + return deleteChannelOverwrite(this.guildId!, this.id!, id); }, hasPermission(overwrites, permissions) { return channelOverwriteHasPermission( - this.guildID!, + this.guildId!, this.id!, overwrites, permissions, @@ -66,14 +63,14 @@ const baseChannel: Partial = { // deno-lint-ignore require-await export async function createChannelStruct( data: ChannelCreatePayload, - guildID?: string, + guildId?: string, ) { const { - guild_id: rawGuildID = "", - last_message_id: lastMessageID, + guild_id: rawGuildId = "", + last_message_id: lastMessageId, user_limit: userLimit, rate_limit_per_user: rateLimitPerUser, - parent_id: parentID = undefined, + parent_id: parentId = undefined, last_pin_timestamp: lastPinTimestamp, permission_overwrites: permissionOverwrites = [], nsfw = false, @@ -88,11 +85,11 @@ export async function createChannelStruct( const channel = Object.create(baseChannel, { ...restProps, - guildID: createNewProp(guildID || rawGuildID), - lastMessageID: createNewProp(lastMessageID), + guildId: createNewProp(guildId || rawGuildId), + lastMessageId: createNewProp(lastMessageId), userLimit: createNewProp(userLimit), rateLimitPerUser: createNewProp(rateLimitPerUser), - parentID: createNewProp(parentID), + parentId: createNewProp(parentId), lastPinTimestamp: createNewProp( lastPinTimestamp ? Date.parse(lastPinTimestamp) : undefined, ), diff --git a/src/structures/guild.ts b/src/structures/guild.ts index 90e6d16ca..c3e896b9d 100644 --- a/src/structures/guild.ts +++ b/src/structures/guild.ts @@ -1,4 +1,4 @@ -import { botID } from "../bot.ts"; +import { botId } from "../bot.ts"; import { cache, cacheHandlers } from "../cache.ts"; import { deleteServer } from "../helpers/guilds/delete_server.ts"; import { editGuild } from "../helpers/guilds/edit_guild.ts"; @@ -13,8 +13,7 @@ import { banMember } from "../helpers/members/ban_member.ts"; import { unbanMember } from "../helpers/members/unban_member.ts"; import { Collection } from "../util/collection.ts"; import { createNewProp } from "../util/utils.ts"; -import { Member } from "./member.ts"; -import { Channel, Role, structures } from "./mod.ts"; +import { Role, structures } from "./mod.ts"; export const initialMemberLoadQueue = new Map(); @@ -23,31 +22,31 @@ const baseGuild: Partial = { return cache.members.filter((member) => member.guilds.has(this.id!)); }, get channels() { - return cache.channels.filter((channel) => channel.guildID === this.id); + return cache.channels.filter((channel) => channel.guildId === this.id); }, get afkChannel() { - return cache.channels.get(this.afkChannelID!); + return cache.channels.get(this.afkChannelId!); }, get publicUpdatesChannel() { - return cache.channels.get(this.publicUpdatesChannelID!); + return cache.channels.get(this.publicUpdatesChannelId!); }, get rulesChannel() { - return cache.channels.get(this.rulesChannelID!); + return cache.channels.get(this.rulesChannelId!); }, get systemChannel() { - return cache.channels.get(this.systemChannelID!); + return cache.channels.get(this.systemChannelId!); }, get bot() { - return cache.members.get(botID); + return cache.members.get(botId); }, get botMember() { return this.bot?.guilds.get(this.id!); }, get botVoice() { - return this.voiceStates?.get(botID); + return this.voiceStates?.get(botId); }, get owner() { - return cache.members.get(this.ownerID!); + return cache.members.get(this.ownerId!); }, get partnered() { return Boolean(this.features?.includes("PARTNERED")); @@ -67,17 +66,17 @@ const baseGuild: Partial = { auditLogs(options) { return getAuditLogs(this.id!, options); }, - getBan(memberID) { - return getBan(this.id!, memberID); + getBan(memberId) { + return getBan(this.id!, memberId); }, bans() { return getBans(this.id!); }, - ban(memberID, options) { - return banMember(this.id!, memberID, options); + ban(memberId, options) { + return banMember(this.id!, memberId, options); }, - unban(memberID) { - return unbanMember(this.id!, memberID); + unban(memberId) { + return unbanMember(this.id!, memberId); }, invites() { return getInvites(this.id!); @@ -92,26 +91,26 @@ const baseGuild: Partial = { export async function createGuildStruct( data: CreateGuildPayload, - shardID: number, + shardId: number, ) { const { disovery_splash: discoverySplash, default_message_notifications: defaultMessageNotifications, explicit_content_filter: explicitContentFilter, system_channel_flags: systemChannelFlags, - rules_channel_id: rulesChannelID, - public_updates_channel_id: publicUpdatesChannelID, + rules_channel_id: rulesChannelId, + public_updates_channel_id: publicUpdatesChannelId, max_video_channel_users: maxVideoChannelUsers, approximate_member_count: approximateMemberCount, approximate_presence_count: approximatePresenceCount, - owner_id: ownerID, - afk_channel_id: afkChannelID, + owner_id: ownerId, + afk_channel_id: afkChannelId, afk_timeout: afkTimeout, widget_enabled: widgetEnabled, - widget_channel_id: widgetChannelID, + widget_channel_id: widgetChannelId, verification_level: verificationLevel, mfa_level: mfaLevel, - system_channel_id: systemChannelID, + system_channel_id: systemChannelId, max_presences: maxPresences, max_members: maxMembers, vanity_url_code: vanityURLCode, @@ -151,20 +150,20 @@ export async function createGuildStruct( discoverySplash: createNewProp(discoverySplash), defaultMessageNotifications: createNewProp(defaultMessageNotifications), explicitContentFilter: createNewProp(explicitContentFilter), - rulesChannelID: createNewProp(rulesChannelID), - publicUpdatesChannelID: createNewProp(publicUpdatesChannelID), + rulesChannelId: createNewProp(rulesChannelId), + publicUpdatesChannelId: createNewProp(publicUpdatesChannelId), maxVideoChannelUsers: createNewProp(maxVideoChannelUsers), approximateMemberCount: createNewProp(approximateMemberCount), approximatePresenceCount: createNewProp(approximatePresenceCount), - shardID: createNewProp(shardID), - ownerID: createNewProp(ownerID), - afkChannelID: createNewProp(afkChannelID), + shardId: createNewProp(shardId), + ownerId: createNewProp(ownerId), + afkChannelId: createNewProp(afkChannelId), afkTimeout: createNewProp(afkTimeout), widgetEnabled: createNewProp(widgetEnabled), - widgetChannelID: createNewProp(widgetChannelID), + widgetChannelId: createNewProp(widgetChannelId), verificationLevel: createNewProp(verificationLevel), mfaLevel: createNewProp(mfaLevel), - systemChannelID: createNewProp(systemChannelID), + systemChannelId: createNewProp(systemChannelId), maxPresences: createNewProp(maxPresences), maxMembers: createNewProp(maxMembers), vanityURLCode: createNewProp(vanityURLCode), @@ -186,10 +185,10 @@ export async function createGuildStruct( vs.user_id, { ...vs, - guildID: vs.guild_id, - channelID: vs.channel_id, - userID: vs.user_id, - sessionID: vs.session_id, + guildId: vs.guild_id, + channelId: vs.channel_id, + userId: vs.user_id, + sessionId: vs.session_id, selfDeaf: vs.self_deaf, selfMute: vs.self_mute, selfStream: vs.self_stream, diff --git a/src/structures/member.ts b/src/structures/member.ts index 38337b6d0..00cc0108e 100644 --- a/src/structures/member.ts +++ b/src/structures/member.ts @@ -8,7 +8,6 @@ import { addRole } from "../helpers/roles/add_role.ts"; import { removeRole } from "../helpers/roles/remove_role.ts"; import { Collection } from "../util/collection.ts"; import { createNewProp } from "../util/utils.ts"; -import { Guild } from "./guild.ts"; const baseMember: Partial = { get avatarURL() { @@ -31,38 +30,38 @@ const baseMember: Partial = { options.format, ); }, - guild(guildID) { - return cache.guilds.get(guildID); + guild(guildId) { + return cache.guilds.get(guildId); }, - name(guildID) { - return this.guildMember!(guildID)?.nick || this.username!; + name(guildId) { + return this.guildMember!(guildId)?.nick || this.username!; }, - guildMember(guildID) { - return this.guilds?.get(guildID); + guildMember(guildId) { + return this.guilds?.get(guildId); }, sendDM(content) { return sendDirectMessage(this.id!, content); }, - kick(guildID, reason) { - return kickMember(guildID, this.id!, reason); + kick(guildId, reason) { + return kickMember(guildId, this.id!, reason); }, - edit(guildID, options) { - return editMember(guildID, this.id!, options); + edit(guildId, options) { + return editMember(guildId, this.id!, options); }, - ban(guildID, options) { - return banMember(guildID, this.id!, options); + ban(guildId, options) { + return banMember(guildId, this.id!, options); }, - addRole(guildID, roleID, reason) { - return addRole(guildID, this.id!, roleID, reason); + addRole(guildId, roleId, reason) { + return addRole(guildId, this.id!, roleId, reason); }, - removeRole(guildID, roleID, reason) { - return removeRole(guildID, this.id!, roleID, reason); + removeRole(guildId, roleId, reason) { + return removeRole(guildId, this.id!, roleId, reason); }, }; export async function createMemberStruct( data: MemberCreatePayload, - guildID: string, + guildId: string, ) { const { joined_at: joinedAt, @@ -106,7 +105,7 @@ export async function createMemberStruct( } // User was never cached before - member.guilds.set(guildID, { + member.guilds.set(guildId, { nick: nick, roles: roles, joinedAt: Date.parse(joinedAt), diff --git a/src/structures/message.ts b/src/structures/message.ts index 322c590c9..4cce057fe 100644 --- a/src/structures/message.ts +++ b/src/structures/message.ts @@ -10,37 +10,33 @@ import { removeReaction } from "../helpers/messages/remove_reaction.ts"; import { removeReactionEmoji } from "../helpers/messages/remove_reaction_emoji.ts"; import { sendMessage } from "../helpers/messages/send_message.ts"; import { createNewProp } from "../util/utils.ts"; -import { Channel } from "./channel.ts"; -import { Guild } from "./guild.ts"; -import { Member } from "./member.ts"; -import { Role } from "./role.ts"; const baseMessage: Partial = { get channel() { - if (this.guildID) return cache.channels.get(this.channelID!); + if (this.guildId) return cache.channels.get(this.channelId!); return cache.channels.get(this.author?.id!); }, get guild() { - if (!this.guildID) return undefined; - return cache.guilds.get(this.guildID); + if (!this.guildId) return undefined; + return cache.guilds.get(this.guildId); }, get member() { if (!this.author?.id) return undefined; return cache.members.get(this.author?.id); }, get guildMember() { - if (!this.guildID) return undefined; - return this.member?.guilds.get(this.guildID); + if (!this.guildId) return undefined; + return this.member?.guilds.get(this.guildId); }, get link() { - return `https://discord.com/channels/${this.guildID || - "@me"}/${this.channelID}/${this.id}`; + return `https://discord.com/channels/${this.guildId || + "@me"}/${this.channelId}/${this.id}`; }, get mentionedRoles() { - return this.mentionRoleIDs?.map((id) => this.guild?.roles.get(id)) || []; + return this.mentionRoleIds?.map((id) => this.guild?.roles.get(id)) || []; }, get mentionedChannels() { - return this.mentionChannelIDs?.map((id) => cache.channels.get(id)) || []; + return this.mentionChannelIds?.map((id) => cache.channels.get(id)) || []; }, get mentionedMembers() { return this.mentions?.map((id) => cache.members.get(id)) || []; @@ -49,7 +45,7 @@ const baseMessage: Partial = { // METHODS delete(reason, delayMilliseconds) { return deleteMessage( - this.channelID!, + this.channelId!, this.id!, reason, delayMilliseconds, @@ -59,39 +55,39 @@ const baseMessage: Partial = { return editMessage(this as Message, content); }, pin() { - return pinMessage(this.channelID!, this.id!); + return pinMessage(this.channelId!, this.id!); }, addReaction(reaction) { - return addReaction(this.channelID!, this.id!, reaction); + return addReaction(this.channelId!, this.id!, reaction); }, addReactions(reactions, ordered) { - return addReactions(this.channelID!, this.id!, reactions, ordered); + return addReactions(this.channelId!, this.id!, reactions, ordered); }, reply(content) { const contentWithMention = typeof content === "string" ? { content, mentions: { repliedUser: true }, - replyMessageID: this.id, + replyMessageId: this.id, failReplyIfNotExists: false, } : { ...content, mentions: { ...(content.mentions || {}), repliedUser: true }, - replyMessageID: this.id, + replyMessageId: this.id, failReplyIfNotExists: content.failReplyIfNotExists === true, }; - if (this.guildID) return sendMessage(this.channelID!, contentWithMention); + if (this.guildId) return sendMessage(this.channelId!, contentWithMention); return sendDirectMessage(this.author!.id, contentWithMention); }, send(content) { - if (this.guildID) return sendMessage(this.channelID!, content); + if (this.guildId) return sendMessage(this.channelId!, content); return sendDirectMessage(this.author!.id, content); }, alert(content, timeout = 10, reason = "") { - if (this.guildID) { - return sendMessage(this.channelID!, content).then((response) => { + if (this.guildId) { + return sendMessage(this.channelId!, content).then((response) => { response.delete(reason, timeout * 1000).catch(console.error); }); } @@ -106,27 +102,27 @@ const baseMessage: Partial = { ); }, removeAllReactions() { - return removeAllReactions(this.channelID!, this.id!); + return removeAllReactions(this.channelId!, this.id!); }, removeReactionEmoji(reaction) { - return removeReactionEmoji(this.channelID!, this.id!, reaction); + return removeReactionEmoji(this.channelId!, this.id!, reaction); }, removeReaction(reaction) { - return removeReaction(this.channelID!, this.id!, reaction); + return removeReaction(this.channelId!, this.id!, reaction); }, }; export async function createMessageStruct(data: MessageCreateOptions) { const { - guild_id: guildID = "", - channel_id: channelID, + guild_id: guildId = "", + channel_id: channelId, mentions_everyone: mentionsEveryone, - mention_channels: mentionChannelIDs = [], - mention_roles: mentionRoleIDs, - webhook_id: webhookID, + mention_channels: mentionChannelIds = [], + mention_roles: mentionRoleIds, + webhook_id: webhookId, message_reference: messageReference, edited_timestamp: editedTimestamp, - referenced_message: referencedMessageID, + referenced_message: referencedMessageId, member, ...rest } = data; @@ -138,20 +134,20 @@ export async function createMessageStruct(data: MessageCreateOptions) { } // Discord doesnt give guild id for getMessage() so this will fill it in - const guildIDFinal = guildID || - (await cacheHandlers.get("channels", channelID))?.guildID || ""; + const guildIdFinal = guildId || + (await cacheHandlers.get("channels", channelId))?.guildId || ""; const message = Object.create(baseMessage, { ...restProps, /** The message id of the original message if this message was sent as a reply. If null, the original message was deleted. */ - referencedMessageID: createNewProp(referencedMessageID), - channelID: createNewProp(channelID), - guildID: createNewProp(guildID || guildIDFinal), + referencedMessageId: createNewProp(referencedMessageId), + channelId: createNewProp(channelId), + guildId: createNewProp(guildId || guildIdFinal), mentions: createNewProp(data.mentions.map((m) => m.id)), mentionsEveryone: createNewProp(mentionsEveryone), - mentionRoleIDs: createNewProp(mentionRoleIDs), - mentionChannelIDs: createNewProp(mentionChannelIDs.map((m) => m.id)), - webhookID: createNewProp(webhookID), + mentionRoleIds: createNewProp(mentionRoleIds), + mentionChannelIds: createNewProp(mentionChannelIds.map((m) => m.id)), + webhookId: createNewProp(webhookId), messageReference: createNewProp(messageReference), timestamp: createNewProp(Date.parse(data.timestamp)), editedTimestamp: createNewProp( diff --git a/src/structures/role.ts b/src/structures/role.ts index f998923f2..3d3a5fae9 100644 --- a/src/structures/role.ts +++ b/src/structures/role.ts @@ -1,10 +1,7 @@ import { cache } from "../cache.ts"; import { deleteRole } from "../helpers/roles/delete_role.ts"; import { editRole } from "../helpers/roles/edit_role.ts"; -import { Collection } from "../util/collection.ts"; import { createNewProp } from "../util/utils.ts"; -import { Guild } from "./guild.ts"; -import { Member } from "./member.ts"; const baseRole: Partial = { get guild() { @@ -23,43 +20,43 @@ const baseRole: Partial = { }, // METHODS - delete(guildID?: string) { + delete(guildId?: string) { // If not guild id was provided try and find one - if (!guildID) guildID = guildID || this.guild?.id; + if (!guildId) guildId = guildId || this.guild?.id; // If a guild id is still not available error out - if (!guildID) { + if (!guildId) { throw new Error( - "role.delete() did not find a valid guild in cache. Please provide the guildID like role.delete(guildID)", + "role.delete() did not find a valid guild in cache. Please provide the guildId like role.delete(guildId)", ); } - return deleteRole(guildID, this.id!).catch(console.error); + return deleteRole(guildId, this.id!).catch(console.error); }, - edit(options: CreateRoleOptions, guildID?: string) { + edit(options: CreateRoleOptions, guildId?: string) { // If not guild id was provided try and find one - if (!guildID) guildID = guildID || this.guild?.id; + if (!guildId) guildId = guildId || this.guild?.id; // If a guild id is still not available error out - if (!guildID) { + if (!guildId) { throw new Error( - "role.edit() did not find a valid guild in cache. Please provide the guildID like role.edit({}, guildID)", + "role.edit() did not find a valid guild in cache. Please provide the guildId like role.edit({}, guildId)", ); } - return editRole(guildID, this.id!, options); + return editRole(guildId, this.id!, options); }, - higherThanRoleID(roleID: string, position?: number) { + higherThanRoleId(roleId: string, position?: number) { // If no position try and find one from cache - if (!position) position = this.guild?.roles.get(roleID)?.position; + if (!position) position = this.guild?.roles.get(roleId)?.position; // If still none error out. if (!position) { throw new Error( - "role.higherThanRoleID() did not have a position provided and the role or guild was not found in cache. Please provide a position like role.higherThanRoleID(roleID, position)", + "role.higherThanRoleId() did not have a position provided and the role or guild was not found in cache. Please provide a position like role.higherThanRoleId(roleId, position)", ); } // Rare edge case handling if (this.position === position) { - return this.id! < roleID; + return this.id! < roleId; } return this.position! > position; @@ -76,9 +73,9 @@ export async function createRoleStruct({ tags = {}, ...rest }: RoleData) { const role = Object.create(baseRole, { ...restProps, - botID: createNewProp(tags.bot_id), + botId: createNewProp(tags.bot_id), isNitroBoostRole: createNewProp("premium_subscriber" in tags), - integrationID: createNewProp(tags.integration_id), + integrationId: createNewProp(tags.integration_id), }); return role as Role; diff --git a/src/structures/template.ts b/src/structures/template.ts index 5ce36d732..41498888b 100644 --- a/src/structures/template.ts +++ b/src/structures/template.ts @@ -1,12 +1,11 @@ import { cache } from "../cache.ts"; import { createNewProp } from "../util/utils.ts"; -import { Guild } from "./guild.ts"; const baseTemplate: Partial