Guild
- class Guild
A Discord server. Most methods call Discord; the few that read Weeble’s gateway cache say so.
A field is
undefinedwhen Discord didn’t send it andnullwhen Discord sentnull. A guild fromfetchGuild()can come from the cache and then only hasid,name, andownerId.Example
const guild = await message.fetchGuild(); const member = guild && message.author ? await guild.fetchMember(message.author.id) : null;
Properties
Property
Type
Description
afkChannelIdafkTimeoutapplicationIdapproximateMemberCountapproximatePresenceCountHash of the guild’s banner, or
nullif not set.createdAtWhen this guild was created.
createdTimestampdefaultMessageNotificationsNotificationsLevel | undefined
Default notification level for the guild.
descriptionThe guild’s description shown in the Server Discovery listing, or
null.undefinedwhen the payload omitted it.discoverySplashemojisexplicitContentFilterExplicitContentFilterLevel | undefined
Level of content filtering applied to messages.
featuresFeature[] | undefined
Array of feature flags the guild has enabled.
iconHash of the guild’s icon, or
nullif not set.undefinedwhen the payload omitted it (cache-backed fetches do not inventnull).idGuild ID.
invitesPausedUntilWhen paused invites resume, or
nullwhen invites are not paused. SeepauseInvites().maxMembersmaxPresencesmaxStageVideoChannelUsersmaxVideoChannelUsersmemberCountMember count reported by the gateway or latest guild REST response.
undefinedwhen the payload did not include a count.mfaLevelnameThe guild’s name.
nsfwLevelownerIdID of the guild owner, when the payload included it.
preferredLocaleThe guild’s preferred locale (e.g.
"en-US").Number of Nitro boosts the guild currently has.
PremiumTier | undefined
The guild’s Nitro boost tier.
undefinedwhen omitted;0only when Discord sent 0.publicUpdatesChannelIdrolesrulesChannelIdsafetyAlertsChannelIdsplashstickerssystemChannelFlagssystemChannelIdvanityUrlCodeThe vanity invite code, or
nullif the guild doesn’t have a vanity URL.verificationLevelVerificationLevel | undefined
Verification level required to send messages.
widgetChannelIdwidgetEnabledMethods
- 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
previewPrunefirst 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.bulkBan(userIds: string[], options:
BulkBanOptions) Promise<BulkBanResult> Ban up to 200 users in one request. Needs Ban Members and Manage Server. Users who are already banned, or who can’t be banned, are returned in
failedUsers.const { bannedUsers, failedUsers } = await guild.bulkBan(raiderIds, { deleteMessageSeconds: 3600, reason: "Raid", });
-
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.createSoundboardSound(options:
SoundboardSoundCreateOptions) Promise<SoundboardSound> Upload a sound to this guild’s soundboard.
- Parameters:
options: The sound file and its settings.
- Returns:
The uploaded sound.
Example
const sound = await guild.createSoundboardSound({ name: "airhorn", sound: `data:audio/mpeg;base64,${base64Mp3}`, emojiName: "📯", });
-
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.deleteIntegration(integrationId: string, reason: string) Promise<void>
Remove an integration. Removing a bot’s integration also removes the bot from the server. Needs Manage Server.
- 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.editChannelPositions(positions:
ChannelPosition[]) Promise<void> Move several channels at once. Only the fields you set change.
await guild.editChannelPositions([ { id: rulesId, position: 0 }, { id: logsId, parentId: staffCategoryId, lockPermissions: true }, ]);
-
async Guild.editOnboarding(options:
GuildOnboardingEditOptions) Promise<GuildOnboarding> Replace parts of the onboarding flow.
promptsreplaces every prompt: include existing prompts and options byidto keep them. Needs Manage Server and Manage Roles.
-
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.editWelcomeScreen(options:
WelcomeScreenEditOptions) Promise<WelcomeScreen> Edit the welcome screen.
welcomeChannelsholds at most 5 channels. Needs Manage Server.
-
async Guild.editWidgetSettings(options:
GuildWidgetSettingsEditOptions) Promise<GuildWidgetSettings> Enable or disable the server widget, or change its invite channel. Needs Manage Server.
-
async Guild.fetch() Promise<
Guild> Refetch the latest guild data from Discord.
- Returns:
The updated guild object.
-
async Guild.fetchActiveThreads() Promise<
ThreadChannel[]> List every active thread in the server.
-
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.fetchBan(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.fetchBans() Promise<
GuildBan[]> Fetch all bans in this guild.
- Returns:
An array of all guild bans.
- 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.fetchEmoji(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.fetchEmojis() Promise<
Emoji[]> Fetch all emojis for this guild.
- Returns:
An array of all custom emojis.
-
async Guild.fetchIntegrations() Promise<
GuildIntegration[]> List the server’s integrations, such as bots and Twitch or YouTube links. Needs Manage Server.
-
async Guild.fetchInvites() Promise<
Invite[]> Fetch all invites for this guild.
- Returns:
An array of all guild invites.
-
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.fetchOnboarding() Promise<
GuildOnboarding> Read the server’s onboarding flow.
-
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.fetchSoundboardSounds() Promise<
SoundboardSound[]> Fetch the sounds uploaded to this guild’s soundboard.
- Returns:
An array of the guild’s sounds. Discord’s default sounds are not included.
-
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.fetchVanityUrl() Promise<
GuildVanityUrl> Read the vanity invite code and how many times it has been used. Needs Manage Server.
-
async Guild.fetchWebhooks() Promise<
Webhook[]> Fetch all webhooks for this guild.
- Returns:
An array of all webhooks.
-
async Guild.fetchWelcomeScreen() Promise<
WelcomeScreen> Read the welcome screen shown to new members of a Community server.
-
async Guild.fetchWidgetSettings() Promise<
GuildWidgetSettings> Read whether the server widget is enabled and which channel it invites to.
-
async Guild.getCachedPresence(userId: string) Promise<
Presence| null> Read a member’s presence from Weeble’s gateway cache, if currently known.
- async Guild.getChannels() Promise<AnyGuildChannel[]>
Gets this guild’s channels from the gateway cache. Cached channels have their name, type, category,
nsfwflag and permission overwrites, but not topic, position or slowmode. Falls back tofetchChannels()when the cache is empty.
-
async Guild.getMember(userId: string) Promise<
GuildMember| null> Gets a member from the gateway cache. The cached member has
user,nick,rolesandjoinedAt, which covers role checks and display names; avatar, timeout and boost fields are missing. Falls back tofetchMember()when the member isn’t cached.const member = await guild.getMember(message.author.id); if (member?.hasRole(modRoleId)) await message.reply("Hi, mod.");
- Parameters:
userId: The member’s user ID.
-
async Guild.getRole(roleId: string) Promise<
Role| null> Gets one role from the gateway cache. See
getRoles()for which fields a cached role has.- Parameters:
roleId: The role ID.
-
async Guild.getRoles() Promise<
Role[]> Gets this guild’s roles from the gateway cache. Cached roles have
name,permissionsandposition, which is enough for permission and hierarchy checks; color, icon and flags are missing. Falls back tofetchRoles()when the cache is empty.
- 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.pauseInvites(until: Date | null, reason: string) Promise<void>
Stop new members from joining through invites until
until, at most 24 hours ahead. Passnullto resume invites early. Needs Manage Server. Discord’s member-DM pause setting is left as it is.
- 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. A server that was just added may still be indexing: check
statusand retry afterretryAfterseconds.const result = await guild.searchMessages({ content: "refund", limit: 10 }); if (result.status === "ready") console.log(result.totalResults);