diff --git a/src/helpers/members/get_members.ts b/src/helpers/members/get_members.ts index e67be723a..74f554569 100644 --- a/src/helpers/members/get_members.ts +++ b/src/helpers/members/get_members.ts @@ -1,9 +1,14 @@ import { eventHandlers, identifyPayload } from "../../bot.ts"; import { cacheHandlers } from "../../cache.ts"; import { rest } from "../../rest/rest.ts"; -import { Member, structures } from "../../structures/mod.ts"; +import { DiscordenoMember } from "../../structures/member.ts"; +import { structures } from "../../structures/mod.ts"; import { DiscordGatewayIntents } from "../../types/gateway/gateway_intents.ts"; -import { DiscordGuildMember } from "../../types/guilds/guild_member.ts"; +import { + DiscordGuildMemberWithUser, + GuildMember, +} from "../../types/guilds/guild_member.ts"; +import { ListGuildMembers } from "../../types/guilds/list_guild_members.ts"; import { Errors } from "../../types/misc/errors.ts"; import { Collection } from "../../util/collection.ts"; import { endpoints } from "../../util/constants.ts"; @@ -16,7 +21,7 @@ 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?: ListGuildMembers) { if (!(identifyPayload.intents && DiscordGatewayIntents.GUILD_MEMBERS)) { throw new Error(Errors.MISSING_INTENT_GUILD_MEMBERS); } @@ -24,7 +29,7 @@ export async function getMembers(guildId: string, options?: GetMemberOptions) { const guild = await cacheHandlers.get("guilds", guildId); if (!guild) throw new Error(Errors.GUILD_NOT_FOUND); - const members = new Collection(); + const members = new Collection(); let membersLeft = options?.limit ?? guild.memberCount; let loops = 1; @@ -44,17 +49,17 @@ export async function getMembers(guildId: string, options?: GetMemberOptions) { ); } - const result = (await rest.runMethod( + const result: GuildMember[] = (await rest.runMethod( "get", `${endpoints.GUILD_MEMBERS(guildId)}?limit=${ membersLeft > 1000 ? 1000 : membersLeft }${options?.after ? `&after=${options.after}` : ""}`, - )) as DiscordGuildMember[]; + )); const discordenoMembers = await Promise.all( result.map(async (member) => { const discordenoMember = await structures.createDiscordenoMember( - member, + member as DiscordGuildMemberWithUser, guildId, ); @@ -66,7 +71,7 @@ export async function getMembers(guildId: string, options?: GetMemberOptions) { return discordenoMember; }), - ) as Member[]; + ) as DiscordenoMember[]; if (!discordenoMembers.length) break; diff --git a/src/helpers/members/prune_members.ts b/src/helpers/members/prune_members.ts index 74f48ed5b..3527136d5 100644 --- a/src/helpers/members/prune_members.ts +++ b/src/helpers/members/prune_members.ts @@ -1,4 +1,5 @@ import { rest } from "../../rest/rest.ts"; +import { BeginGuildPrune } from "../../types/guilds/begin_guild_prune.ts"; import { Errors } from "../../types/misc/errors.ts"; import { endpoints } from "../../util/constants.ts"; import { requireBotGuildPermissions } from "../../util/permissions.ts"; @@ -11,7 +12,7 @@ import { camelKeysToSnakeCase } from "../../util/utils.ts"; */ export async function pruneMembers( guildId: string, - options: PruneOptions, + options: BeginGuildPrune, ) { 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); diff --git a/src/helpers/messages/get_reactions.ts b/src/helpers/messages/get_reactions.ts index 0f9ae95e4..6d3f79f5e 100644 --- a/src/helpers/messages/get_reactions.ts +++ b/src/helpers/messages/get_reactions.ts @@ -1,4 +1,5 @@ import { rest } from "../../rest/rest.ts"; +import { User } from "../../types/users/user.ts"; import { Collection } from "../../util/collection.ts"; import { endpoints } from "../../util/constants.ts"; @@ -7,13 +8,13 @@ export async function getReactions( channelId: string, messageId: string, reaction: string, - options?: DiscordGetReactionsParams, + options?: DiscordGetReactions, ) { const users = (await rest.runMethod( "get", endpoints.CHANNEL_MESSAGE_REACTION(channelId, messageId, reaction), options, - )) as UserPayload[]; + )) as User[]; return new Collection(users.map((user) => [user.id, user])); }