/// /** @module Guild */ import Role from "./Role"; import Base from "./Base"; import Member from "./Member"; import GuildScheduledEvent from "./GuildScheduledEvent"; import type User from "./User"; import type VoiceChannel from "./VoiceChannel"; import type ClientApplication from "./ClientApplication"; import type TextChannel from "./TextChannel"; import type CategoryChannel from "./CategoryChannel"; import Integration from "./Integration"; import AutoModerationRule from "./AutoModerationRule"; import Permission from "./Permission"; import VoiceState from "./VoiceState"; import StageInstance from "./StageInstance"; import type GuildTemplate from "./GuildTemplate"; import type GuildPreview from "./GuildPreview"; import type Invite from "./Invite"; import type Webhook from "./Webhook"; import { type DefaultMessageNotificationLevels, type ExplicitContentFilterLevels, type GuildFeature, type GuildNSFWLevels, type ImageFormat, type MFALevels, type PremiumTiers, type VerificationLevels, type GuildChannelTypesWithoutThreads } from "../Constants"; import type Client from "../Client"; import TypedCollection from "../util/TypedCollection"; import type { AnyGuildChannel, AnyGuildChannelWithoutThreads, AnyGuildTextChannel, AnyThreadChannel, InviteChannel, RawGuildChannel, RawThreadChannel } from "../types/channels"; import type { AddMemberOptions, BeginPruneOptions, CreateBanOptions, CreateChannelOptions, CreateEmojiOptions, CreateRoleOptions, EditCurrentMemberOptions, EditCurrentUserVoiceStateOptions, EditEmojiOptions, EditGuildOptions, EditMemberOptions, EditRoleOptions, EditRolePositionsEntry, EditUserVoiceStateOptions, EditWelcomeScreenOptions, GetBansOptions, GetMembersOptions, GetPruneCountOptions, GuildEmoji, ModifyChannelPositionsEntry, RawGuild, RawMember, RawRole, SearchMembersOptions, WelcomeScreen, WidgetImageStyle, WidgetSettings, RawIntegration, CreateChannelReturn, Widget, GetActiveThreadsResponse, Ban, GetVanityURLResponse, RawWidget, RawStageInstance, EditMFALevelOptions, RESTMember, CreateStickerOptions, Sticker, EditStickerOptions } from "../types/guilds"; import type { CreateScheduledEventOptions, EditScheduledEventOptions, GetScheduledEventUsersOptions, RawScheduledEvent, ScheduledEventUser } from "../types/scheduled-events"; import type { CreateAutoModerationRuleOptions, EditAutoModerationRuleOptions, RawAutoModerationRule } from "../types/auto-moderation"; import type { AuditLog, GetAuditLogOptions } from "../types/audit-log"; import type { CreateTemplateOptions, EditGuildTemplateOptions } from "../types/guild-template"; import type { JoinVoiceChannelOptions, RawVoiceState, VoiceRegion } from "../types/voice"; import type { JSONGuild } from "../types/json"; import type { RequestGuildMembersOptions } from "../types/gateway"; import type Shard from "../gateway/Shard"; import Collection from "../util/Collection"; import type { DiscordGatewayAdapterCreator, VoiceConnection } from "@discordjs/voice"; /** Represents a Discord server. */ export default class Guild extends Base { private _clientMember?; private _shard?; /** This guild's afk voice channel. */ afkChannel?: VoiceChannel | null; /** The ID of this guild's afk voice channel. */ afkChannelID: string | null; /** The seconds after which voice users will be moved to the afk channel. */ afkTimeout: number; /** The application that created this guild, if applicable. */ application?: ClientApplication | null; /** The ID of the application that created this guild, if applicable. */ applicationID: string | null; /** The approximate number of members in this guild (if retrieved with counts). */ approximateMemberCount?: number; /** The approximate number of non-offline members in this guild (if retrieved with counts). */ approximatePresenceCount?: number; /** The auto moderation rules in this guild. */ autoModerationRules: TypedCollection; /** The hash of this guild's banner. */ banner: string | null; /** The channels in this guild. */ channels: TypedCollection; /** The default [message notifications level](https://discord.com/developers/docs/resources/guild#guild-object-default-message-notification-level) of this guild. */ defaultMessageNotifications: DefaultMessageNotificationLevels; /** The description of this guild. */ description: string | null; /** The discovery splash of this guild. Only present if the guild has the `DISCOVERABLE` feature. */ discoverySplash: string | null; /** The custom emojis of this guild. */ emojis: Array; /** The [explicit content filter](https://discord.com/developers/docs/resources/guild#guild-object-explicit-content-filter-level) of this guild. */ explicitContentFilter: ExplicitContentFilterLevels; /** The [features](https://discord.com/developers/docs/resources/guild#guild-object-guild-features) this guild has. */ features: Array; /** The icon hash of this guild. */ icon: string | null; /** The integrations in this guild. */ integrations: TypedCollection; /** The cached invites in this guild. This will only be populated by invites created while the client is active. */ invites: Collection; /** The date at which this guild was joined. */ joinedAt: Date | null; /** If this guild is considered large. */ large: boolean; /** The maximum amount of members this guild can have. */ maxMembers?: number; /** The maximum amount of people that can be present at a time in this guild. Only present for very large guilds. */ maxPresences?: number; /** The maximum amount of users that can be present in a stage video channel. */ maxStageVideoChannelUsers?: number; /** The maximum amount of users that can be present in a video channel. */ maxVideoChannelUsers?: number; /** The number of members in this guild. */ memberCount: number; /** The cached members in this guild. */ members: TypedCollection; /** The required [mfa level](https://discord.com/developers/docs/resources/guild#guild-object-mfa-level) for moderators of this guild. */ mfaLevel: MFALevels; /** The name of this guild. */ name: string; /** The [nsfw level](https://discord.com/developers/docs/resources/guild#guild-object-guild-nsfw-level) of this guild. */ nsfwLevel: GuildNSFWLevels; /** The owner of this guild. */ owner?: User; /** The ID of the owner of this guild. */ ownerID: string; /** The [preferred locale](https://discord.com/developers/docs/reference#locales) of this guild. */ preferredLocale: string; /** If this guild has the boost progress bar enabled. */ premiumProgressBarEnabled: boolean; /** The number of nitro boosts this guild has. */ premiumSubscriptionCount?: number; /** The [boost level](https://discord.com/developers/docs/resources/guild#guild-object-premium-tier) of this guild. */ premiumTier: PremiumTiers; /** The channel where notices from Discord are received. Only present in guilds with the `COMMUNITY` feature. */ publicUpdatesChannel?: AnyGuildTextChannel | null; /** The id of the channel where notices from Discord are received. Only present in guilds with the `COMMUNITY` feature. */ publicUpdatesChannelID: string | null; /** @deprecated The region of this guild.*/ region?: string | null; /** The roles in this guild. */ roles: TypedCollection; /** The channel where rules/guidelines are displayed. Only present in guilds with the `COMMUNITY` feature. */ rulesChannel?: TextChannel | null; /** The id of the channel where rules/guidelines are displayed. Only present in guilds with the `COMMUNITY` feature. */ rulesChannelID: string | null; /** The channel where safety related notices are posted. */ safetyAlertsChannel?: TextChannel | null; /** The ID if the channel where safety related notices are posted. */ safetyAlertsChannelID: string | null; /** The scheduled events in this guild. */ scheduledEvents: TypedCollection; /** The invite splash hash of this guild. */ splash: string | null; /** The stage instances in this guild. */ stageInstances: TypedCollection; /** The custom stickers of this guild. */ stickers: Array; /** The channel where welcome messages and boosts notices are posted. */ systemChannel?: TextChannel | null; /** The [flags](https://discord.com/developers/docs/resources/guild#guild-object-system-channel-flags) for the system channel. */ systemChannelFlags: number; /** The ID of the channel where welcome messages and boosts notices are posted. */ systemChannelID: string | null; /** The threads in this guild. */ threads: TypedCollection; /** If this guild is unavailable. */ unavailable: boolean; /** The vanity url of this guild. Only present in guilds with the `VANITY_URL` feature. */ vanityURLCode: string | null; /** The [verification level](https://discord.com/developers/docs/resources/guild#guild-object-verification-level) of this guild. */ verificationLevel: VerificationLevels; /** The voice states of members in voice channels. */ voiceStates: TypedCollection; /** The welcome screen configuration. Only present in guilds with the `WELCOME_SCREEN_ENABLED` feature. */ welcomeScreen?: WelcomeScreen; /** The channel the widget will generate an invite to, or `null` if set to no invite. */ widgetChannel?: Exclude | null; /** The id of the channel the widget will generate an invite to, or `null` if set to no invite. */ widgetChannelID: string | null; /** If the widget is enabled. */ widgetEnabled?: boolean; constructor(data: RawGuild, client: Client); private toggleFeature; private updateMemberLimit; protected update(data: Partial): void; /** The client's member for this guild. This will throw an error if the guild was obtained via rest and the member is not cached.*/ get clientMember(): Member; /** The shard this guild is on. Gateway only. */ get shard(): Shard; /** The voice adapter creator for this guild that can be used with [@discordjs/voice](https://discord.js.org/#/docs/voice/main/general/welcome) to play audio in voice and stage channels. */ get voiceAdapterCreator(): DiscordGatewayAdapterCreator; /** * Add a member to this 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 userID The ID of the user to add. * @param options The options for adding the member. */ addMember(userID: string, options: AddMemberOptions): Promise; /** * Add a role to a member. * @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(memberID: string, roleID: string, reason?: string): Promise; /** * The url of this guild's banner. * @param format The format the url should be. * @param size The dimensions of the image. */ bannerURL(format?: ImageFormat, size?: number): string | null; /** * Begin a prune. * @param options The options for the prune. */ beginPrune(options?: BeginPruneOptions): Promise; /** * Create an auto moderation rule for this guild. * @param options The options for the rule. */ createAutoModerationRule(options: CreateAutoModerationRuleOptions): Promise; /** * Create a bon for a user. * @param userID The ID of the user. * @param options The options for creating the bon. */ createBan(userID: string, options?: CreateBanOptions): Promise; /** * Create a channel in this guild. * @param options The options for creating the channel. */ createChannel(type: T, options: Omit): Promise>; /** * Create an emoji in this guild. * @param options The options for creating the emoji. */ createEmoji(options: CreateEmojiOptions): Promise; /** * Create a role. * @param options The options for creating the role. */ createRole(options?: CreateRoleOptions): Promise; /** * Create a scheduled event in this guild. * @param options The options for creating the scheduled event. */ createScheduledEvent(options: CreateScheduledEventOptions): Promise; /** * Create a sticker. * @param options The options for creating the sticker. */ createSticker(options: CreateStickerOptions): Promise; /** * Create a guild template. * @param options The options for creating the template. */ createTemplate(options: CreateTemplateOptions): Promise; /** * Delete this guild. */ delete(): Promise; /** * Delete an auto moderation rule in this guild. * @param ruleID The ID of the rule to delete. * @param reason The reason for deleting the rule. */ deleteAutoModerationRule(ruleID: string, reason?: string): Promise; /** * Delete an emoji in this guild. * @param emojiID The ID of the emoji. * @param reason The reason for deleting the emoji. */ deleteEmoji(emojiID: string, reason?: string): Promise; /** * Delete an integration. * @param integrationID The ID of the integration. * @param reason The reason for deleting the integration. */ deleteIntegration(integrationID: string, reason?: string): Promise; /** * Delete a role. * @param roleID The ID of the role to delete. * @param reason The reason for deleting the role. */ deleteRole(roleID: string, reason?: string): Promise; /** * Delete a scheduled event. * @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(eventID: string, reason?: string): Promise; /** * Delete a sticker. * @param stickerID The ID of the sticker to delete. * @param reason The reason for deleting the sticker. */ deleteSticker(stickerID: string, reason?: string): Promise; /** * Delete a template. * @param code The code of the template. */ deleteTemplate(code: string): Promise; /** * Disable the `COMMUNITY` feature for this guild. Requires the **Administrator** permission. * @param reason The reason for disable the feature. */ disableCommunity(reason?: string): Promise; /** * Disable the `DISCOVERABLE` feature for this guild. Requires the **Administrator** permission. * @param reason The reason for disabling the feature. */ disableDiscovery(reason?: string): Promise; /** * Disable the `INVITES_DISABLED` feature for this guild. Requires the **Manage Guild** permission. * @param reason The reason for disabling the feature. */ disableInvites(reason?: string): Promise; /** * Disable the `RAID_ALERTS_ENABLED` feature for this guild. Requires the **Manage Guild** permission. * @param reason The reason for disabling the feature. */ disableRaidAlerts(reason?: string): Promise; /** * The url of this guild's discovery splash. * @param format The format the url should be. * @param size The dimensions of the image. */ discoverySplashURL(format?: ImageFormat, size?: number): string | null; /** * Edit this guild. * @param options The options for editing the guild. */ edit(options: EditGuildOptions): Promise; /** * Edit an existing auto moderation rule in this guild. * @param ruleID The ID of the rule to edit. * @param options The options for editing the rule. */ editAutoModerationRule(ruleID: string, options: EditAutoModerationRuleOptions): Promise; /** * Edit the positions of channels in this guild. * @param options The channels to move. Unedited channels do not need to be specified. */ editChannelPositions(options: Array): Promise; /** * Modify the current member in this guild. * @param options The options for editing the member. */ editCurrentMember(options: EditCurrentMemberOptions): Promise; /** * Edit the current member's voice state in this 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 options The options for editing the voice state. */ editCurrentUserVoiceState(options: EditCurrentUserVoiceStateOptions): Promise; /** * Edit an existing emoji in this guild. * @param options The options for editing the emoji. */ editEmoji(emojiID: string, options: EditEmojiOptions): Promise; /** * Edit the [mfa level](https://discord.com/developers/docs/resources/guild#guild-object-mfa-level) of this guild. This can only be used by the guild owner. * @param options The options for editing the MFA level. */ editMFALevel(options: EditMFALevelOptions): Promise; /** * Edit a member of this guild. Use \.editCurrentMember if you wish to update the nick of this client using the CHANGE_NICKNAME permission. * @param memberID The ID of the member. * @param options The options for editing the member. */ editMember(memberID: string, options: EditMemberOptions): Promise; /** * Edit an existing role. * @param options The options for editing the role. */ editRole(roleID: string, options: EditRoleOptions): Promise; /** * Edit the position of roles in this guild. * @param options The roles to move. */ editRolePositions(options: Array, reason?: string): Promise>; /** * Edit an existing scheduled event in this guild. * @param options The options for editing the scheduled event. */ editScheduledEvent(options: EditScheduledEventOptions): Promise; /** * Edit a sticker. * @param options The options for editing the sticker. */ editSticker(stickerID: string, options: EditStickerOptions): Promise; /** * Edit a template. * @param code The code of the template. * @param options The options for editing the template. */ editTemplate(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 memberID The ID of the member. * @param options The options for editing the voice state. */ editUserVoiceState(memberID: string, options: EditUserVoiceStateOptions): Promise; /** * Edit the welcome screen in this guild. * @param options The options for editing the welcome screen. */ editWelcomeScreen(options: EditWelcomeScreenOptions): Promise; /** * Edit the widget of this guild. * @param options The options for editing the widget. */ editWidget(options: WidgetSettings): Promise; /** * Enable the `COMMUNITY` feature for this guild. Requires the **Administrator** permission. * @param reason The reason for enabling the feature. */ enableCommunity(reason?: string): Promise; /** * Enable the `DISCOVERABLE` feature for this guild. Requires the **Administrator** permission. The server must also be passing all discovery requirements. * @param reason The reason for enabling the feature. */ enableDiscovery(reason?: string): Promise; /** * Enable the `INVITES_DISABLED` feature for this guild. Requires the **Manage Guild** permission. * @param reason The reason for enabling the feature. */ enableInvites(reason?: string): Promise; /** * Enable the `RAID_ALERTS_ENABLED` feature for this guild. Requires the **Manage Guild** permission. * @param reason The reason for enabling the feature. */ enableRaidAlerts(reason?: string): Promise; /** * Request members from this guild. * @param options The options for fetching the members. */ fetchMembers(options?: RequestGuildMembersOptions): Promise>; /** * Get the active threads in this guild. */ getActiveThreads(): Promise; /** * Get this guild's audit log. * @param options The options for the audit log. */ getAuditLog(options?: GetAuditLogOptions): Promise; /** * Get an auto moderation rule for this guild. * @param ruleID The ID of the rule to get. */ getAutoModerationRule(ruleID: string): Promise; /** * Get the auto moderation rules for this guild. */ getAutoModerationRules(): Promise>; /** * Get a ban in this guild. * @param userID The ID of the user to get the ban of. */ getBan(userID: string): Promise; /** * Get the bans in this guild. * @param options The options for getting the bans. */ getBans(options?: GetBansOptions): Promise>; /** * Get the channels in a guild. Does not include threads. Only use this if you need to. See the `channels` collection. */ getChannels(): Promise>; /** * Get an emoji in this guild. * @param emojiID The ID of the emoji to get. */ getEmoji(emojiID: string): Promise; /** * Get the emojis in this guild. */ getEmojis(): Promise>; /** * Get the integrations in this guild. */ getIntegrations(): Promise>; /** * Get the invites of this guild. */ getInvites(): Promise>>; /** * Get a member of this guild. * @param memberID The ID of the member. */ getMember(memberID: string): Promise; /** * Get this guild's members. This requires the `GUILD_MEMBERS` intent. * @param options The options for getting the members. */ getMembers(options?: GetMembersOptions): Promise>; /** * Get a preview of this guild. */ getPreview(): Promise; /** * Get the prune count of this guild. * @param options The options for getting the prune count. */ getPruneCount(options?: GetPruneCountOptions): Promise; /** * Get the roles in this guild. Only use this if you need to. See the `roles` collection. */ getRoles(): Promise>; /** * Get a scheduled event. * @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(eventID: string, withUserCount?: number): Promise; /** * Get the users subscribed to a scheduled event. * @param eventID The ID of the scheduled event to get the users of. * @param options The options for getting the users. */ getScheduledEventUsers(eventID: string, options?: GetScheduledEventUsersOptions): Promise>; /** * Get this guild's scheduled events * @param withUserCount If the number of users subscribed to the event should be included. */ getScheduledEvents(withUserCount?: number): Promise>; /** * Get a sticker. Response will include a user if the client has the `MANAGE_EMOJIS_AND_STICKERS` permissions. * @param stickerID The ID of the sticker to get. */ getSticker(stickerID: string): Promise; /** * Get this guild's stickers. Stickers will include a user if the client has the `MANAGE_EMOJIS_AND_STICKERS` permissions. */ getStickers(): Promise>; /** * Get this guild's templates. */ getTemplates(): Promise>; /** * Get the vanity url of this guild. */ getVanityURL(): Promise; /** * Get the list of usable voice regions for this guild. This will return VIP servers when the guild is VIP-enabled. */ getVoiceRegions(): Promise>; /** * Get the webhooks in this guild. */ getWebhooks(): Promise>; /** * Get the welcome screen for this guild. */ getWelcomeScreen(): Promise; /** * Get the widget of this guild. */ getWidget(): Promise; /** * Get the widget image of this guild. * @param style The style of the image. */ getWidgetImage(style?: WidgetImageStyle): Promise; /** * Get the raw JSON widget of this guild. */ getWidgetJSON(): Promise; /** * Get this guild's widget settings. */ getWidgetSettings(): Promise; /** * The url of this guild's icon. * @param format The format the url should be. * @param size The dimensions of the image. */ iconURL(format?: ImageFormat, size?: number): string | null; /** * Join a voice or stage channel. * @param options The options to join the channel with. */ joinChannel(options: Omit): VoiceConnection; /** * Leave this guild. */ leave(): Promise; /** Leave the connected voice or stage channel on this guild. */ leaveChannel(): void; /** * Get the permissions of a member. If providing an id, the member must be cached. * @param member The member to get the permissions of. */ permissionsOf(member: string | Member): Permission; /** * Remove a ban. * @param userID The ID of the user to remove the ban from. * @param reason The reason for removing the ban. */ removeBan(userID: string, reason?: string): Promise; /** * Remove a member from this guild. * @param memberID The ID of the user to remove. * @param reason The reason for the removal. */ removeMember(memberID: string, reason?: string): Promise; /** * remove a role from a member. * @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(memberID: string, roleID: string, reason?: string): Promise; /** * Search the username & nicknames of members in this guild. * @param options The options for the search. */ searchMembers(options: SearchMembersOptions): Promise>; /** * The url of this guild's invite splash. * @param format The format the url should be. * @param size The dimensions of the image. */ splashURL(format?: ImageFormat, size?: number): string | null; /** * Sync a guild template. * @param code The code of the template to sync. */ syncTemplate(code: string): Promise; toJSON(): JSONGuild; }