/// /** @module Routes/Guilds */ import type { CreateEmojiOptions, CreateGuildOptions, EditEmojiOptions, EditGuildOptions, GuildEmoji, ModifyChannelPositionsEntry, GetActiveThreadsResponse, GetMembersOptions, SearchMembersOptions, AddMemberOptions, EditMemberOptions, EditCurrentMemberOptions, GetBansOptions, Ban, CreateBanOptions, CreateRoleOptions, EditRolePositionsEntry, EditRoleOptions, GetPruneCountOptions, BeginPruneOptions, WidgetSettings, RawWidget, Widget, WidgetImageStyle, WelcomeScreen, EditWelcomeScreenOptions, GetVanityURLResponse, EditUserVoiceStateOptions, EditCurrentUserVoiceStateOptions, CreateChannelReturn, CreateChannelOptions, EditMFALevelOptions, Sticker, CreateStickerOptions, EditStickerOptions } from "../types/guilds"; import type { CreateAutoModerationRuleOptions, EditAutoModerationRuleOptions } from "../types/auto-moderation"; import type { GuildChannelTypesWithoutThreads, MFALevels } from "../Constants"; import type { AuditLog, GetAuditLogOptions } from "../types/audit-log"; import GuildScheduledEvent from "../structures/GuildScheduledEvent"; import type { CreateScheduledEventOptions, EditScheduledEventOptions, GetScheduledEventUsersOptions, ScheduledEventUser } from "../types/scheduled-events"; import GuildTemplate from "../structures/GuildTemplate"; import type { CreateGuildFromTemplateOptions, CreateTemplateOptions, EditGuildTemplateOptions } from "../types/guild-template"; import GuildPreview from "../structures/GuildPreview"; import type { AnyGuildChannelWithoutThreads, InviteChannel, PartialInviteChannel } from "../types/channels"; import Role from "../structures/Role"; import type { VoiceRegion } from "../types/voice"; import Invite from "../structures/Invite"; import Integration from "../structures/Integration"; import AutoModerationRule from "../structures/AutoModerationRule"; import type RESTManager from "../rest/RESTManager"; import Guild from "../structures/Guild"; import type Member from "../structures/Member"; import type { Uncached } from "../types/shared"; /** Various methods for interacting with guilds. */ export default class Guilds { #private; constructor(manager: RESTManager); /** * Add a member to a guild. Requires an access token with the `guilds.join` scope. * * Returns the newly added member upon success, or void if the member is already in the guild. * @param guildID The ID of the guild. * @param userID The ID of the user to add. * @param options The options for adding the member. */ addMember(guildID: string, userID: string, options: AddMemberOptions): Promise; /** * Add a role to a member. * @param guildID The ID of the guild. * @param memberID The ID of the member. * @param roleID The ID of the role to add. * @param reason The reason for adding the role. */ addMemberRole(guildID: string, memberID: string, roleID: string, reason?: string): Promise; /** * Begin a prune. * @param guildID The ID of the guild. * @param options The options for the prune. */ beginPrune(guildID: string, options?: BeginPruneOptions): Promise; /** * Create a guild. This can only be used by bots in under 10 guilds. * * Note: This does NOT add the guild to the client's cache. * @param options The options for creating the guild. */ create(options: CreateGuildOptions): Promise; /** * Create an auto moderation rule for a guild. * @param guildID The ID of the guild. * @param options The options for creating the rule. */ createAutoModerationRule(guildID: string, options: CreateAutoModerationRuleOptions): Promise; /** * Create a bon for a user. * @param guildID The ID of the guild. * @param userID The ID of the user to ban. * @param options The options for creating the bon. */ createBan(guildID: string, userID: string, options?: CreateBanOptions): Promise; /** * Create a channel in a guild. * @param guildID The ID of the guild. * @param options The options for creating the channel. */ createChannel(guildID: string, type: T, options: Omit): Promise>; /** * Create an emoji in a guild. * @param guildID The ID of the guild. * @param options The options for creating the emoji. */ createEmoji(guildID: string, options: CreateEmojiOptions): Promise; /** * Create a guild from a template. This can only be used by bots in less than 10 guilds. * * Note: This does NOT add the guild to the client's cache. * @param code The code of the template to use. * @param options The options for creating the guild. */ createFromTemplate(code: string, options: CreateGuildFromTemplateOptions): Promise; /** * Create a role. * @param guildID The ID of the guild. * @param options The options for creating the role. */ createRole(guildID: string, options?: CreateRoleOptions): Promise; /** * Create a scheduled event in a guild. * @param guildID The ID of the guild. * @param options The options for creating the scheduled event. */ createScheduledEvent(guildID: string, options: CreateScheduledEventOptions): Promise; /** * Create a sticker. * @param guildID The ID of the guild. * @param options The options for creating the sticker. */ createSticker(guildID: string, options: CreateStickerOptions): Promise; /** * Create a guild template. * @param guildID The ID of the guild to create a template from. * @param options The options for creating the template. */ createTemplate(guildID: string, options: CreateTemplateOptions): Promise; /** * Delete a guild. * @param guildID The ID of the guild. */ delete(guildID: string): Promise; /** * Delete an auto moderation rule. * @param guildID The ID of the guild. * @param ruleID The ID of the rule to delete. * @param reason The reason for deleting the rule. */ deleteAutoModerationRule(guildID: string, ruleID: string, reason?: string): Promise; /** * Delete an emoji. * @param guildID The ID of the guild. * @param emojiID The ID of the emoji. * @param reason The reason for deleting the emoji. */ deleteEmoji(guildID: string, emojiID: string, reason?: string): Promise; /** * Delete an integration. * @param guildID The ID of the guild. * @param integrationID The ID of the integration. * @param reason The reason for deleting the integration. */ deleteIntegration(guildID: string, integrationID: string, reason?: string): Promise; /** * Delete a role. * @param guildID The ID of the guild. * @param roleID The ID of the role to delete. * @param reason The reason for deleting the role. */ deleteRole(guildID: string, roleID: string, reason?: string): Promise; /** * Delete a scheduled event. * @param guildID The ID of the guild. * @param eventID The ID of the scheduled event. * @param reason The reason for deleting the scheduled event. Discord's docs do not explicitly state a reason can be provided, so it may not be used. */ deleteScheduledEvent(guildID: string, eventID: string, reason?: string): Promise; /** * Delete a sticker. * @param guildID The ID of the guild. * @param stickerID The ID of the sticker to delete. * @param reason The reason for deleting the sticker. */ deleteSticker(guildID: string, stickerID: string, reason?: string): Promise; /** * Delete a template. * @param guildID The ID of the guild. * @param code The code of the template. */ deleteTemplate(guildID: string, code: string): Promise; /** * Edit a guild. * * Note: If the client's cache does not already contain the guild, it will not be added. * @param guildID The ID of the guild. * @param options The options for editing the guild. */ edit(guildID: string, options: EditGuildOptions): Promise; /** * Edit an existing auto moderation rule. * @param guildID The ID of the guild. * @param ruleID The ID of the rule to edit. * @param options The options for editing the rule. */ editAutoModerationRule(guildID: string, ruleID: string, options: EditAutoModerationRuleOptions): Promise; /** * Edit the positions of channels in a guild. * @param guildID The ID of the guild. * @param options The channels to move. Unedited channels do not need to be specified. */ editChannelPositions(guildID: string, options: Array): Promise; /** * Modify the current member in a guild. * @param guildID The ID of the guild. * @param options The options for editing the member. */ editCurrentMember(guildID: string, options: EditCurrentMemberOptions): Promise; /** * Edit the current member's voice state in a guild. `channelID` is required, and the current member must already be in that channel. See [Discord's docs](https://discord.com/developers/docs/resources/guild#modify-current-user-voice-state-caveats) for more information. * @param guildID The ID of the guild. * @param options The options for editing the voice state. */ editCurrentUserVoiceState(guildID: string, options: EditCurrentUserVoiceStateOptions): Promise; /** * Edit an existing emoji. * @param guildID The ID of the guild the emoji is in. * @param options The options for editing the emoji. */ editEmoji(guildID: string, emojiID: string, options: EditEmojiOptions): Promise; /** * Edit the [mfa level](https://discord.com/developers/docs/resources/guild#guild-object-mfa-level) of a guild. This can only be used by the guild owner. * @param guildID The ID of the guild. * @param options The options for editing the MFA level. */ editMFALevel(guildID: string, options: EditMFALevelOptions): Promise; /** * Edit a guild member. Use editCurrentMember if you wish to update the nick of this client using the CHANGE_NICKNAME permission. * @param guildID The ID of the guild. * @param memberID The ID of the member. * @param options The options for editing the member. */ editMember(guildID: string, memberID: string, options: EditMemberOptions): Promise; /** * Edit an existing role. * @param guildID The ID of the guild. * @param options The options for editing the role. */ editRole(guildID: string, roleID: string, options: EditRoleOptions): Promise; /** * Edit the position of roles in a guild. * @param guildID The ID of the guild. * @param options The roles to move. */ editRolePositions(guildID: string, options: Array, reason?: string): Promise>; /** * Edit an existing scheduled event in a guild. * @param guildID The ID of the guild. * @param options The options for editing the scheduled event. */ editScheduledEvent(guildID: string, options: EditScheduledEventOptions): Promise; /** * Edit a sticker. * @param guildID The ID of the guild. * @param options The options for editing the sticker. */ editSticker(guildID: string, stickerID: string, options: EditStickerOptions): Promise; /** * Edit a guild template. * @param guildID The ID of the guild. * @param code The code of the template. * @param options The options for editing the template. */ editTemplate(guildID: string, code: string, options: EditGuildTemplateOptions): Promise; /** * Edit a guild member's voice state. `channelID` is required, and the user must already be in that channel. See [Discord's docs](https://discord.com/developers/docs/resources/guild#modify-user-voice-state) for more information. * @param guildID The ID of the guild. * @param memberID The ID of the member. * @param options The options for editing the voice state. */ editUserVoiceState(guildID: string, memberID: string, options: EditUserVoiceStateOptions): Promise; /** * Edit the welcome screen in a guild. * @param guildID The ID of the guild. * @param options The options for editing the welcome screen. */ editWelcomeScreen(guildID: string, options: EditWelcomeScreenOptions): Promise; /** * Edit the widget of a guild. * @param guildID The ID of the guild. * @param options The options for editing the widget. */ editWidget(guildID: string, options: WidgetSettings): Promise; /** * Get a guild. * * Note: If the guild is not already in the client's cache, this will not add it. * @param guildID The ID of the guild. * @param withCounts If the approximate number of members and online members should be included. */ get(guildID: string, withCounts?: boolean): Promise; /** * Get the active threads in a guild. * @param guildID The ID of the guild. */ getActiveThreads(guildID: string): Promise; /** * Get a guild's audit log. * @param guildID The ID of the guild. * @param options The options for getting the audit logs. */ getAuditLog(guildID: string, options?: GetAuditLogOptions): Promise; /** * Get an auto moderation rule for a guild. * @param guildID The ID of the guild. * @param ruleID The ID of the rule to get. */ getAutoModerationRule(guildID: string, ruleID: string): Promise; /** * Get the auto moderation rules for a guild. * @param guildID The ID of the guild. */ getAutoModerationRules(guildID: string): Promise>; /** * Get a ban. * @param guildID The ID of the guild. * @param userID The ID of the user to get the ban of. */ getBan(guildID: string, userID: string): Promise; /** * Get the bans in a guild. * @param guildID The ID of the guild. * @param options The options for getting the bans. */ getBans(guildID: string, options?: GetBansOptions): Promise>; /** * Get the channels in a guild. Does not include threads. * @param guildID The ID of the guild. */ getChannels(guildID: string): Promise>; /** * Get an emoji in a guild. * @param guildID The ID of the guild. * @param emojiID The ID of the emoji to get. */ getEmoji(guildID: string, emojiID: string): Promise; /** * Get the emojis in a guild. * @param guildID The ID of the guild. */ getEmojis(guildID: string): Promise>; /** * Get the integrations in a guild. * @param guildID The ID of the guild. */ getIntegrations(guildID: string): Promise>; /** * Get the invites of a guild. * @param guildID The ID of the guild to get the invites of. */ getInvites(guildID: string): Promise>>; /** * Get a guild member. * @param guildID The ID of the guild. * @param memberID The ID of the member. */ getMember(guildID: string, memberID: string): Promise; /** * Get a guild's members. This requires the `GUILD_MEMBERS` intent. * @param guildID The ID of the guild. * @param options The options for getting the members. */ getMembers(guildID: string, options?: GetMembersOptions): Promise>; /** * Get a preview of a guild. If the client is not already in this guild, the guild must be lurkable. * @param guildID The ID of the guild. */ getPreview(guildID: string): Promise; /** * Get the prune count of a guild. * @param guildID The ID of the guild. * @param options The options for getting the prune count. */ getPruneCount(guildID: string, options?: GetPruneCountOptions): Promise; /** * Get the roles in a guild. * @param guildID The ID of the guild. */ getRoles(guildID: string): Promise>; /** * Get a scheduled event. * @param guildID The ID of the guild. * @param eventID The ID of the scheduled event to get. * @param withUserCount If the number of users subscribed to the event should be included. */ getScheduledEvent(guildID: string, eventID: string, withUserCount?: number): Promise; /** * Get the users subscribed to a scheduled event. * @param guildID The ID of the guild. * @param eventID The ID of the scheduled event. * @param options The options for getting the users. */ getScheduledEventUsers(guildID: string, eventID: string, options?: GetScheduledEventUsersOptions): Promise>; /** * Get a guild's scheduled events. * @param guildID The ID of the guild. * @param withUserCount If the number of users subscribed to the event should be included. */ getScheduledEvents(guildID: string, withUserCount?: number): Promise>; /** * Get a sticker. Response will include a user if the client has the `MANAGE_EMOJIS_AND_STICKERS` permissions. * @param guildID The ID of the guild. * @param stickerID The ID of the sticker to get. */ getSticker(guildID: string, stickerID: string): Promise; /** * Get a guild's stickers. Stickers will include a user if the client has the `MANAGE_EMOJIS_AND_STICKERS` permissions. * @param guildID The ID of the guild. */ getStickers(guildID: string): Promise>; /** * Get a guild template. * @param code The code of the template to get. */ getTemplate(code: string): Promise; /** * Get a guild's templates. * @param guildID The ID of the guild. */ getTemplates(guildID: string): Promise>; /** * Get the vanity url of a guild. * @param guildID The ID of the guild. */ getVanityURL(guildID: string): Promise; /** * Get the list of usable voice regions for a guild. This will return VIP servers when the guild is VIP-enabled. * @param guildID The ID of the guild. */ getVoiceRegions(guildID: string): Promise>; /** * Get the welcome screen for a guild. * @param guildID The ID of the guild. */ getWelcomeScreen(guildID: string): Promise; /** * Get the widget of a guild. * @param guildID The ID of the guild. */ getWidget(guildID: string): Promise; /** * Get the widget image of a guild. * @param guildID The ID of the guild. * @param style The style of the image. */ getWidgetImage(guildID: string, style?: WidgetImageStyle): Promise; /** * Get the raw JSON widget of a guild. * @param guildID The ID of the guild. */ getWidgetJSON(guildID: string): Promise; /** * Get a guild's widget settings. * @param guildID The ID of the guild. */ getWidgetSettings(guildID: string): Promise; /** * Remove a ban. * @param guildID The ID of the guild. * @param userID The ID of the user to remove the ban from. * @param reason The reason for removing the ban. */ removeBan(guildID: string, userID: string, reason?: string): Promise; /** * Remove a member from a guild. * @param guildID The ID of the guild. * @param memberID The ID of the user to remove. * @param reason The reason for the removal. */ removeMember(guildID: string, memberID: string, reason?: string): Promise; /** * remove a role from a member. * @param guildID The ID of the guild. * @param memberID The ID of the member. * @param roleID The ID of the role to remove. * @param reason The reason for removing the role. */ removeMemberRole(guildID: string, memberID: string, roleID: string, reason?: string): Promise; /** * Search the username & nicknames of members in a guild. * @param guildID The ID of the guild. * @param options The options to search with. */ searchMembers(guildID: string, options: SearchMembersOptions): Promise>; /** * Sync a guild template. * @param guildID The ID of the guild. * @param code The code of the template to sync. */ syncTemplate(guildID: string, code: string): Promise; }