diff --git a/src/helpers/members/avatar_url.ts b/src/helpers/members/avatar_url.ts index 53dd62a41..2dc138c2b 100644 --- a/src/helpers/members/avatar_url.ts +++ b/src/helpers/members/avatar_url.ts @@ -1,10 +1,10 @@ import type { DiscordImageFormat } from "../../types/misc/image_format.ts"; import type { DiscordImageSize } from "../../types/misc/image_size.ts"; -import type {Bot} from "../../bot.ts"; +import type { Bot } from "../../bot.ts"; /** The users custom avatar or the default avatar if you don't have a member object. */ export function avatarURL( - bot: Bot, + bot: Bot, userId: bigint, discriminator: number, options: { diff --git a/src/helpers/members/ban_member.ts b/src/helpers/members/ban_member.ts index f39a88bee..06a986f0a 100644 --- a/src/helpers/members/ban_member.ts +++ b/src/helpers/members/ban_member.ts @@ -1,14 +1,21 @@ import type { CreateGuildBan } from "../../types/guilds/create_guild_ban.ts"; -import type {Bot} from "../../bot.ts"; +import type { Bot } from "../../bot.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(bot: Bot, guildId: bigint, id: bigint, options?: CreateGuildBan) { await bot.utils.requireBotGuildPermissions(bot, guildId, ["BAN_MEMBERS"]); - return await bot.rest.runMethod(bot.rest,"put", bot.constants.endpoints.GUILD_BAN(guildId, id), (options ? { - delete_message_days: options.deleteMessageDays, - reason: options.reason - } : {})); + return await bot.rest.runMethod( + bot.rest, + "put", + bot.constants.endpoints.GUILD_BAN(guildId, id), + options + ? { + delete_message_days: options.deleteMessageDays, + reason: options.reason, + } + : {} + ); } // aliases diff --git a/src/helpers/members/disconnect_member.ts b/src/helpers/members/disconnect_member.ts index 52488db38..71bc6897e 100644 --- a/src/helpers/members/disconnect_member.ts +++ b/src/helpers/members/disconnect_member.ts @@ -1,4 +1,4 @@ -import type {Bot} from "../../bot.ts"; +import type { Bot } from "../../bot.ts"; /** Kicks a member from a voice channel */ export function disconnectMember(bot: Bot, guildId: bigint, memberId: bigint) { diff --git a/src/helpers/members/edit_bot_nickname.ts b/src/helpers/members/edit_bot_nickname.ts index 8a39c1e67..822cc6e42 100644 --- a/src/helpers/members/edit_bot_nickname.ts +++ b/src/helpers/members/edit_bot_nickname.ts @@ -1,12 +1,17 @@ -import type {Bot} from "../../bot.ts"; +import type { Bot } from "../../bot.ts"; /** Edit the nickname of the bot in this guild */ export async function editBotNickname(bot: Bot, guildId: bigint, nickname: string | null) { - await bot.utils.requireBotGuildPermissions(bot,guildId, ["CHANGE_NICKNAME"]); + await bot.utils.requireBotGuildPermissions(bot, guildId, ["CHANGE_NICKNAME"]); - const response = await bot.rest.runMethod<{ nick: string }>(bot.rest,"patch", bot.constants.endpoints.USER_NICK(guildId), { - nick: nickname, - }); + const response = await bot.rest.runMethod<{ nick: string }>( + bot.rest, + "patch", + bot.constants.endpoints.USER_NICK(guildId), + { + nick: nickname, + } + ); return response.nick; } diff --git a/src/helpers/members/edit_member.ts b/src/helpers/members/edit_member.ts index 894c69ffa..d38d93eb2 100644 --- a/src/helpers/members/edit_member.ts +++ b/src/helpers/members/edit_member.ts @@ -1,8 +1,8 @@ import type { ModifyGuildMember } from "../../types/guilds/modify_guild_member.ts"; import type { GuildMemberWithUser } from "../../types/members/guild_member.ts"; import type { PermissionStrings } from "../../types/permissions/permission_strings.ts"; -import type {Bot} from "../../bot.ts"; -import type {SnakeCasedPropertiesDeep} from "../../types/util.ts"; +import type { Bot } from "../../bot.ts"; +import type { SnakeCasedPropertiesDeep } from "../../types/util.ts"; /** Edit the member */ export async function editMember(bot: Bot, guildId: bigint, memberId: bigint, options: ModifyGuildMember) { @@ -35,25 +35,25 @@ export async function editMember(bot: Bot, guildId: bigint, memberId: bigint, op if (options.channelId) { const requiredVoicePerms: Set = new Set(["CONNECT", "MOVE_MEMBERS"]); if (memberVoiceState) { - await bot.utils.requireBotChannelPermissions(bot,memberVoiceState?.channelId, [...requiredVoicePerms]); + await bot.utils.requireBotChannelPermissions(bot, memberVoiceState?.channelId, [...requiredVoicePerms]); } - await bot.utils.requireBotChannelPermissions(bot,options.channelId, [...requiredVoicePerms]); + await bot.utils.requireBotChannelPermissions(bot, options.channelId, [...requiredVoicePerms]); } } - await bot.utils.requireBotGuildPermissions(bot,guildId, [...requiredPerms]); + await bot.utils.requireBotGuildPermissions(bot, guildId, [...requiredPerms]); const result = await bot.rest.runMethod>( - bot.rest, + bot.rest, "patch", bot.constants.endpoints.GUILD_MEMBER(guildId, memberId), - { - nick: options.nick, - roles: options.roles, - mute: options.mute, - deaf: options.deaf, - channel_id: options.channelId - } + { + nick: options.nick, + roles: options.roles, + mute: options.mute, + deaf: options.deaf, + channel_id: options.channelId, + } ); return bot.transformers.member(bot, result, guildId); diff --git a/src/helpers/members/fetch_members.ts b/src/helpers/members/fetch_members.ts index ae243e8cb..421614bce 100644 --- a/src/helpers/members/fetch_members.ts +++ b/src/helpers/members/fetch_members.ts @@ -1,9 +1,9 @@ import type { RequestGuildMembers } from "../../types/members/request_guild_members.ts"; import { Collection } from "../../util/collection.ts"; -import type {Bot} from "../../bot.ts"; -import {DiscordGatewayIntents} from "../../types/gateway/gateway_intents.ts"; -import {DiscordGatewayOpcodes} from "../../types/codes/gateway_opcodes.ts"; -import type {DiscordenoMember} from "../../transformers/member.ts"; +import type { Bot } from "../../bot.ts"; +import { DiscordGatewayIntents } from "../../types/gateway/gateway_intents.ts"; +import { DiscordGatewayOpcodes } from "../../types/codes/gateway_opcodes.ts"; +import type { DiscordenoMember } from "../../transformers/member.ts"; /** * ⚠️ BEGINNER DEVS!! YOU SHOULD ALMOST NEVER NEED THIS AND YOU CAN GET FROM cache.members.get() @@ -13,7 +13,12 @@ import type {DiscordenoMember} from "../../transformers/member.ts"; * REST: 50/s global(across all shards) rate limit with ALL requests this included * GW(this function): 120/m(PER shard) rate limit. Meaning if you have 8 shards your limit is now 960/m. */ -export function fetchMembers(bot: Bot, guildId: bigint, shardId: number, options?: Omit) { +export function fetchMembers( + bot: Bot, + guildId: bigint, + shardId: number, + options?: Omit +) { // You can request 1 member without the intent // Check if intents is not 0 as proxy ws won't set intents in other instances if ( diff --git a/src/helpers/members/get_member.ts b/src/helpers/members/get_member.ts index dd5039fad..3620e611a 100644 --- a/src/helpers/members/get_member.ts +++ b/src/helpers/members/get_member.ts @@ -1,6 +1,6 @@ import type { GuildMemberWithUser } from "../../types/members/guild_member.ts"; -import type {Bot} from "../../bot.ts"; -import type {SnakeCasedPropertiesDeep} from "../../types/util.ts"; +import type { Bot } from "../../bot.ts"; +import type { SnakeCasedPropertiesDeep } from "../../types/util.ts"; /** Returns a guild member object for the specified user. * @@ -10,7 +10,11 @@ export async function getMember(bot: Bot, guildId: bigint, id: bigint, options?: const guild = await bot.cache.guilds.get(guildId); if (!guild && !options?.force) return; - const data = await bot.rest.runMethod>(bot.rest,"get", bot.constants.endpoints.GUILD_MEMBER(guildId, id)); + const data = await bot.rest.runMethod>( + bot.rest, + "get", + bot.constants.endpoints.GUILD_MEMBER(guildId, id) + ); const discordenoMember = await bot.transformers.member(bot, data, guildId); await bot.cache.members.set(discordenoMember.id, discordenoMember); diff --git a/src/helpers/members/get_members.ts b/src/helpers/members/get_members.ts index 73b402aee..00ec95836 100644 --- a/src/helpers/members/get_members.ts +++ b/src/helpers/members/get_members.ts @@ -1,10 +1,10 @@ import { DiscordGatewayIntents } from "../../types/gateway/gateway_intents.ts"; import type { GuildMemberWithUser } from "../../types/members/guild_member.ts"; import type { ListGuildMembers } from "../../types/members/list_guild_members.ts"; -import type {Bot} from "../../bot.ts"; -import {Collection} from "../../util/collection.ts"; -import type {DiscordenoMember} from "../../transformers/member.ts"; -import type {SnakeCasedPropertiesDeep} from "../../types/util.ts"; +import type { Bot } from "../../bot.ts"; +import { Collection } from "../../util/collection.ts"; +import type { DiscordenoMember } from "../../transformers/member.ts"; +import type { SnakeCasedPropertiesDeep } from "../../types/util.ts"; /** * ⚠️ BEGINNER DEVS!! YOU SHOULD ALMOST NEVER NEED THIS AND YOU CAN GET FROM cache.members.get() @@ -16,7 +16,10 @@ import type {SnakeCasedPropertiesDeep} from "../../types/util.ts"; */ export async function getMembers(bot: Bot, guildId: bigint, options?: ListGuildMembers & { addToCache?: boolean }) { // Check if intents is not 0 as proxy ws won't set intents in other instances - if (bot.gateway.identifyPayload.intents && !(bot.gateway.identifyPayload.intents & DiscordGatewayIntents.GuildMembers)) { + if ( + bot.gateway.identifyPayload.intents && + !(bot.gateway.identifyPayload.intents & DiscordGatewayIntents.GuildMembers) + ) { throw new Error(bot.cache.Errors.MISSING_INTENT_GUILD_MEMBERS); } @@ -35,7 +38,7 @@ export async function getMembers(bot: Bot, guildId: bigint, options?: ListGuildM } const result = await bot.rest.runMethod[]>( - bot.rest, + bot.rest, "get", `${bot.constants.endpoints.GUILD_MEMBERS(guildId)}?limit=${membersLeft > 1000 ? 1000 : membersLeft}${ options?.after ? `&after=${options.after}` : "" diff --git a/src/helpers/members/kick_member.ts b/src/helpers/members/kick_member.ts index 190753fc7..f746ee3a9 100644 --- a/src/helpers/members/kick_member.ts +++ b/src/helpers/members/kick_member.ts @@ -1,15 +1,20 @@ -import {Bot} from "../../bot.ts"; +import { Bot } from "../../bot.ts"; /** Kick a member from the server */ export async function kick(bot: Bot, guildId: bigint, memberId: bigint, reason?: string) { - const botsHighestRole = await bot.utils.highestRole(bot,guildId, botId); - const membersHighestRole = await bot.utils.highestRole(bot,guildId, memberId); + const botsHighestRole = await bot.utils.highestRole(bot, guildId, botId); + const membersHighestRole = await bot.utils.highestRole(bot, guildId, memberId); if (botsHighestRole && membersHighestRole && botsHighestRole.position <= membersHighestRole.position) { throw new Error(bot.constants.Errors.BOTS_HIGHEST_ROLE_TOO_LOW); } - await bot.utils.requireBotGuildPermissions(bot,guildId, ["KICK_MEMBERS"]); + await bot.utils.requireBotGuildPermissions(bot, guildId, ["KICK_MEMBERS"]); - return await bot.rest.runMethod(bot.rest,"delete", bot.constants.endpoints.GUILD_MEMBER(guildId, memberId), { reason }); + return await bot.rest.runMethod( + bot.rest, + "delete", + bot.constants.endpoints.GUILD_MEMBER(guildId, memberId), + { reason } + ); } // aliases diff --git a/src/helpers/members/move_member.ts b/src/helpers/members/move_member.ts index 860cdb744..ce0b061ea 100644 --- a/src/helpers/members/move_member.ts +++ b/src/helpers/members/move_member.ts @@ -1,4 +1,4 @@ -import type {Bot} from "../../bot.ts"; +import type { Bot } from "../../bot.ts"; /** * Move a member from a voice channel to another. diff --git a/src/helpers/members/prune_members.ts b/src/helpers/members/prune_members.ts index 701e61034..22924ac9f 100644 --- a/src/helpers/members/prune_members.ts +++ b/src/helpers/members/prune_members.ts @@ -1,5 +1,5 @@ import type { BeginGuildPrune } from "../../types/guilds/begin_guild_prune.ts"; -import type {Bot} from "../../bot.ts"; +import type { Bot } from "../../bot.ts"; /** * Begin a prune operation. Requires the KICK_MEMBERS permission. Returns an object with one 'pruned' key indicating the number of members that were removed in the prune operation. For large guilds it's recommended to set the computePruneCount option to false, forcing 'pruned' to null. Fires multiple Guild Member Remove Gateway events. @@ -10,13 +10,18 @@ export async function pruneMembers(bot: Bot, guildId: bigint, options: BeginGuil if (options.days && options.days < 1) throw new Error(bot.constants.Errors.PRUNE_MIN_DAYS); if (options.days && options.days > 30) throw new Error(bot.constants.Errors.PRUNE_MAX_DAYS); - await bot.utils.requireBotGuildPermissions(bot,guildId, ["KICK_MEMBERS"]); + await bot.utils.requireBotGuildPermissions(bot, guildId, ["KICK_MEMBERS"]); - const result = await bot.rest.runMethod<{ pruned: number }>(bot.rest,"post", bot.constants.endpoints.GUILD_PRUNE(guildId), { - days: options.days, - compute_prune_count: options.computePruneCount, - include_roles: options.includeRoles - }); + const result = await bot.rest.runMethod<{ pruned: number }>( + bot.rest, + "post", + bot.constants.endpoints.GUILD_PRUNE(guildId), + { + days: options.days, + compute_prune_count: options.computePruneCount, + include_roles: options.includeRoles, + } + ); return result.pruned; } diff --git a/src/helpers/members/search_members.ts b/src/helpers/members/search_members.ts index bec5cfabc..785911300 100644 --- a/src/helpers/members/search_members.ts +++ b/src/helpers/members/search_members.ts @@ -1,9 +1,9 @@ import type { GuildMemberWithUser } from "../../types/members/guild_member.ts"; import type { SearchGuildMembers } from "../../types/members/search_guild_members.ts"; import { Collection } from "../../util/collection.ts"; -import {Bot} from "../../bot.ts"; -import {DiscordenoMember} from "../../transformers/member.ts"; -import type {SnakeCasedPropertiesDeep} from "../../types/util.ts"; +import { Bot } from "../../bot.ts"; +import { DiscordenoMember } from "../../transformers/member.ts"; +import type { SnakeCasedPropertiesDeep } from "../../types/util.ts"; /** * ⚠️ BEGINNER DEVS!! YOU SHOULD ALMOST NEVER NEED THIS AND YOU CAN GET FROM cache.members.filter() @@ -13,7 +13,7 @@ import type {SnakeCasedPropertiesDeep} from "../../types/util.ts"; * @param options */ export async function searchMembers( - bot: Bot, + bot: Bot, guildId: bigint, query: string, options?: Omit & { cache?: boolean } @@ -25,10 +25,15 @@ export async function searchMembers( } } - const result = await bot.rest.runMethod[]>(bot.rest,"get", bot.constants.endpoints.GUILD_MEMBERS_SEARCH(guildId), { - ...options, - query, - }); + const result = await bot.rest.runMethod[]>( + bot.rest, + "get", + bot.constants.endpoints.GUILD_MEMBERS_SEARCH(guildId), + { + ...options, + query, + } + ); const members = await Promise.all( result.map(async (member) => { diff --git a/src/helpers/members/send_direct_message.ts b/src/helpers/members/send_direct_message.ts index d6bac3029..1d1a50ed1 100644 --- a/src/helpers/members/send_direct_message.ts +++ b/src/helpers/members/send_direct_message.ts @@ -1,7 +1,7 @@ import type { Channel } from "../../types/channels/channel.ts"; import type { CreateMessage } from "../../types/messages/create_message.ts"; -import type {Bot} from "../../bot.ts"; -import type {SnakeCasedPropertiesDeep} from "../../types/util.ts"; +import type { Bot } from "../../bot.ts"; +import type { SnakeCasedPropertiesDeep } from "../../types/util.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(bot: Bot, memberId: bigint, content: string | CreateMessage) { @@ -10,9 +10,14 @@ export async function sendDirectMessage(bot: Bot, memberId: bigint, content: str let dmChannel = await bot.cache.channels.get(memberId); if (!dmChannel) { // If not available in cache create a new one. - const dmChannelData = await bot.rest.runMethod>(bot.rest,"post", bot.constants.endpoints.USER_DM, { - recipient_id: memberId, - }); + const dmChannelData = await bot.rest.runMethod>( + bot.rest, + "post", + bot.constants.endpoints.USER_DM, + { + recipient_id: memberId, + } + ); const discordenoChannel = await bot.transformers.channel(bot, dmChannelData); // Recreate the channel and add it under the users id await bot.cache.channels.set(memberId, discordenoChannel); diff --git a/src/helpers/members/unban_member.ts b/src/helpers/members/unban_member.ts index 294a4bb63..f3ada1e2d 100644 --- a/src/helpers/members/unban_member.ts +++ b/src/helpers/members/unban_member.ts @@ -1,10 +1,10 @@ -import type {Bot} from "../../bot.ts"; +import type { Bot } from "../../bot.ts"; /** Remove the ban for a user. Requires BAN_MEMBERS permission */ export async function unban(bot: Bot, guildId: bigint, id: bigint) { await bot.utils.requireBotGuildPermissions(guildId, ["BAN_MEMBERS"]); - return await bot.rest.runMethod(bot.rest,"delete", bot.constants.endpoints.GUILD_BAN(guildId, id)); + return await bot.rest.runMethod(bot.rest, "delete", bot.constants.endpoints.GUILD_BAN(guildId, id)); } // aliases