Guild
- class Guild()
A Discord guild and the entry point for guild-scoped resources. Fetch and mutation methods call Discord unless their documentation explicitly identifies a gateway-cache lookup.
Omitted fields are
undefined, not synthesized defaults.nullmeans Discord sent null. Cache-backedfetchGuild()may only populateid,name, and ownerId.Example
const guild = await message.fetchGuild(); const member = guild && message.author ? await guild.fetchMember(message.author.id) : null;
exported from
lib.weeble.dProperties
- Guild.banner
type: readonly string | null | undefined
Hash of the guild’s banner, or
nullif not set.
- Guild.defaultMessageNotifications
type: readonly NotificationsLevel | undefined
Default notification level for the guild.
- Guild.description
type: readonly string | null | undefined
The guild’s description shown in the Server Discovery listing, or
null. undefined when the payload omitted it.
- Guild.explicitContentFilter
type: readonly ExplicitContentFilterLevel | undefined
Level of content filtering applied to messages.
- Guild.icon
type: readonly string | null | undefined
Hash of the guild’s icon, or
nullif not set. undefined when the payload omitted it (cache-backed fetches do not inventnull).
- Guild.memberCount
type: readonly number | undefined
Member count reported by the gateway or latest guild REST response. undefined when the payload did not include a count.
- Guild.ownerId
type: readonly string | null | undefined
ID of the guild owner, when the payload included it.
- Guild.preferredLocale
type: readonly string | undefined
The guild’s preferred locale (e.g.
"en-US").
type: readonly PremiumTier | undefined
The guild’s Nitro boost tier.
undefinedwhen omitted;0only when Discord sent 0.
- Guild.vanityUrlCode
type: readonly string | null | undefined
The vanity invite code, or
nullif the guild doesn’t have a vanity URL.
- Guild.verificationLevel
type: readonly VerificationLevel | undefined
Verification level required to send messages.
Methods
- async Guild.addRole(userId: string, roleId: string, reason: string) Promise<void>
Add a role to a guild member.
- async Guild.ban(userId: string, options: { deleteMessageSeconds?: number; reason?: string; }) Promise<void>
Ban a user from the guild.
- Parameters:
userId — – The ID of the user to ban.
options — – Ban options (message deletion duration, reason).
- Guild.bannerURL(options: { format?: “png” | “jpg” | “webp”; size?: number; }) string | null
Get the CDN URL for the guild’s banner.
-
async Guild.beginPrune(options:
GuildPruneOptions) Promise<{ pruned: number | null; }> Permanently removes members that match Discord’s inactivity rules. Use previewPrune first when you need to inspect the estimated count.
- Parameters:
options — – Prune options (inactivity days, included roles, reason).
- Returns:
The prune result with member count.
-
async Guild.createAutoModRule(options:
AutoModRuleCreateOptions) Promise<AutoModRule> Create a new auto moderation rule.
- Parameters:
options — – Auto moderation rule options.
- Returns:
The newly created rule.
-
async Guild.createChannel(options:
GuildChannelCreateOptions) Promise<AnyGuildChannel> Create a new channel in this guild.
- Parameters:
options — – Channel creation options.
- Returns:
The newly created channel.
-
async Guild.createEmoji(options:
EmojiCreateOptions) Promise<Emoji> Create a new custom emoji.
- Parameters:
options — – Emoji creation options.
- Returns:
The newly created emoji.
-
async Guild.createRole(options:
RoleCreateOptions) Promise<Role> Create a new role.
- Parameters:
options — – Role creation options.
- Returns:
The newly created role.
-
async Guild.createScheduledEvent(options:
ScheduledEventCreateOptions) Promise<ScheduledEvent> Create a new scheduled event.
- Parameters:
options — – Event creation options.
- Returns:
The newly created event.
-
async Guild.createStageInstance(options:
StageInstanceCreateOptions) Promise<StageInstance> Create a stage instance in a stage channel.
- Parameters:
options — – Stage instance creation options.
- Returns:
The newly created stage instance.
-
async Guild.createSticker(options:
StickerCreateOptions) Promise<Sticker> Create a new sticker.
- Parameters:
options — – Sticker creation options.
- Returns:
The newly created sticker.
-
async Guild.createTemplate(options: { description?: string; name: string; }) Promise<
GuildTemplate> Create a new guild template from current settings.
- Parameters:
options — – Template creation options.
- Returns:
The newly created template.
- async Guild.deleteStageInstance(channelId: string, reason: string) Promise<void>
Delete the active stage instance.
- Parameters:
channelId — – Stage channel whose active instance should be deleted.
reason — – Reason for deletion, shown in audit log.
-
async Guild.edit(options:
GuildEditOptions) Promise<Guild> Edit guild properties.
- Parameters:
options — – Guild properties to update.
-
async Guild.editRolePositions(positions: { id: string; position: number; }[], reason: string) Promise<
Role[]> Batch-edit role positions.
- Parameters:
positions — – Array of role entries with new positions.
reason — – Audit-log reason for changing the positions.
- Returns:
The updated roles in their new order.
-
async Guild.fetch() Promise<
Guild> Refetch the latest guild data from Discord.
- Returns:
The updated guild object.
-
async Guild.fetchAuditLogs(options:
AuditLogFetchOptions) Promise<AuditLog> Fetch a page of guild audit log entries and related resolved resources. Requires the bot to have PermissionFlags.VIEW_AUDIT_LOG.
- Parameters:
options — – Optional filters and pagination options.
-
async Guild.fetchAutoModRules() Promise<
AutoModRule[]> Fetch all auto moderation rules.
- Returns:
An array of all auto moderation rules.
- async Guild.fetchChannel(channelId: string) Promise<AnyGuildChannel | null>
Fetch a specific channel by ID.
- Parameters:
channelId — – The ID of the channel to fetch.
- Returns:
The channel, or null if not found.
- async Guild.fetchChannels() Promise<AnyGuildChannel[]>
Fetch all channels in this guild.
- Returns:
An array of all guild channels.
-
async Guild.fetchMember(userId: string) Promise<
GuildMember| null> Fetches a guild member from Discord by user ID.
- Parameters:
userId — – The ID of the user to fetch.
- Returns:
The guild member, or
nullwhen it cannot be retrieved.
-
async Guild.fetchRole(roleId: string) Promise<
Role| null> Fetch a role by ID.
- Parameters:
roleId — – The ID of the role to fetch.
- Returns:
The role, or null if not found.
-
async Guild.fetchRoles() Promise<
Role[]> Fetch all roles in this guild.
- Returns:
An array of all roles.
-
async Guild.fetchScheduledEvents(options: { withUserCount?: boolean; }) Promise<
ScheduledEvent[]> Fetch all scheduled events.
- Returns:
An array of all scheduled events.
-
async Guild.fetchStageInstance(channelId: string) Promise<
StageInstance| null> Fetch the active stage instance.
- Returns:
The stage instance, or null if none is running.
-
async Guild.fetchStickers() Promise<
Sticker[]> Fetch all stickers for this guild.
- Returns:
An array of all stickers.
-
async Guild.fetchTemplates() Promise<
GuildTemplate[]> Fetch all guild templates.
- Returns:
An array of all templates.
-
async Guild.fetchWebhooks() Promise<
Webhook[]> Fetch all webhooks for this guild.
- Returns:
An array of all webhooks.
-
async Guild.getBan(userId: string) Promise<
GuildBan| null> Fetch the ban record for a specific user.
- Parameters:
userId — – The ID of the banned user.
- Returns:
The ban object.
-
async Guild.getBans() Promise<
GuildBan[]> Fetch all bans in this guild.
- Returns:
An array of all guild bans.
-
async Guild.getCachedPresence(userId: string) Promise<
Presence| null> Read a member’s presence from Weeble’s gateway cache, if currently known.
-
async Guild.getEmoji(emojiId: string) Promise<
Emoji| null> Fetch a specific emoji by ID.
- Parameters:
emojiId — – The ID of the emoji to fetch.
- Returns:
The emoji, or null if not found.
-
async Guild.getEmojis() Promise<
Emoji[]> Fetch all emojis for this guild.
- Returns:
An array of all custom emojis.
-
async Guild.getInvites() Promise<
Invite[]> Fetch all invites for this guild.
- Returns:
An array of all guild invites.
- Guild.iconURL(options: { format?: “png” | “jpg” | “webp” | “gif”; size?: number; }) string | null
Get the CDN URL for the guild’s icon.
- Parameters:
options — – Icon size and format options.
- Returns:
The icon URL, or null if no icon is set.
-
Guild.iterAuditLogs(options: { actionType?:
AuditLogActionType; limit?: number; userId?: string; }) AsyncIterableIterator<AnyAuditLogEntry> Iterate guild audit log entries, optionally filtered by action or user.
-
Guild.iterMembers(options:
FetchMembersOptions) AsyncIterableIterator<GuildMember> Iterate over all guild members with optional pagination.
- Parameters:
options — – Pagination options (limit, after, etc.).
- Returns:
An async iterable yielding members one at a time.
-
async Guild.me() Promise<
GuildMember> Fetch the bot’s own member object for this guild.
- Returns:
The bot’s guild member object.
- async Guild.previewPrune(options: { days?: number; includeRoles?: string[]; }) Promise<{ pruned: number | null; }>
Preview how many members would be pruned.
- Parameters:
options — – Prune criteria (inactivity days, excluded roles).
- Returns:
The estimated prune count.
- async Guild.removeRole(userId: string, roleId: string, reason: string) Promise<void>
Remove a role from a guild member.
-
async Guild.searchMembers(query: string, options: { limit?: number; }) Promise<
GuildMember[]> Search for guild members by username or nickname prefix via Discord API.
- Parameters:
query — – The username or nickname prefix to search for.
options — – Optional search options.
- Returns:
Matching guild members.
-
async Guild.searchMessages(options:
GuildMessageSearchOptions) Promise<GuildMessageSearchResult> Search messages across the guild while preserving grouped matches.