Skip to content

Guild

Guild wraps a Discord guild object, exposing server metadata, CDN image URL helpers, and feature flag checks.

import { Guild } from "lunibee";
Property Type Description
id string Snowflake ID.
name string Server name.
icon string | null Icon hash. Use iconURL() to get the full URL.
splash string | null Invite splash hash.
banner string | null Banner hash.
description string | null Server description.
ownerId string | undefined Snowflake of the guild owner.
features string[] List of guild feature flags (e.g. "COMMUNITY").
verificationLevel number Verification level (0–4).
premiumTier number Boost level (0–3).
premiumSubscriptionCount number Total boosts.
memberCount number | undefined Member count (member_count, else the approximate count).
approximateMemberCount / approximatePresenceCount number | undefined Approximate counts, when Discord sent them.
vanityUrlCode string | null Custom invite slug.
preferredLocale string Server locale (e.g. "en-US").
nsfwLevel number NSFW level (0–3).
rulesChannelId string | null Rules channel (Community guilds).
systemChannelId string | null System messages channel.
maxMembers number Member cap.
mfaLevel number MFA requirement for moderators.
discoverySplash string | null Discovery splash hash.
systemChannelFlags number System channel flags bitfield.
explicitContentFilter, defaultMessageNotifications number Content filter and default notification levels.
afkChannelId / afkTimeout string | null / number | undefined AFK channel and timeout (seconds).
widgetEnabled / widgetChannelId boolean / string | null Server widget settings.
applicationId string | null Application that created the guild, if a bot did.
publicUpdatesChannelId, safetyAlertsChannelId string | null Community update and safety alert channels.
maxPresences number | null Presence cap (null for the default).
maxVideoChannelUsers number | undefined Video channel user cap.
premiumProgressBarEnabled boolean Whether the boost progress bar shows.
Getter Description
isCommunity true if the guild is a Community server.
isPartnered true if the guild is a Discord Partner.
isVerified true if the guild is Discord Verified.
isBoosted true if there are any active boosts.
hasVanityUrl true if a vanity URL is configured.
boostLevel Boost tier (alias of premiumTier).
vanityURL Full vanity URL string, or null.

All image methods accept an optional ImageURLOptions object:

interface ImageURLOptions {
extension?: "png" | "jpg" | "webp" | "gif" | "jpeg";
size?: 16 | 32 | 64 | 128 | 256 | 512 | 1024 | 2048 | 4096;
forceStatic?: boolean;
}

Returns the guild icon URL, or null if no icon is set.

const icon = guild.iconURL({ size: 256, extension: "png" });

Returns the invite splash URL, or null.

Returns the banner URL, or null.

Returns the discovery splash URL, or null.

Returns a guild widget image URL. style is "shield" (default), "banner1", "banner2", "banner3" or "banner4".

const widget = guild.widgetImageURL("banner3");

Returns true if the guild has a specific feature flag.

if (guild.hasFeature("MONETIZATION_ENABLED")) {
console.log("Subscriptions are enabled!");
}

Returns the guild name.

Log guild info on join

client.on("guildCreate", (data) => {
// guildCreate passes Discord's raw payload; the Guild structure is in the cache.
const guild = client.guilds.get(data.id);
if (!guild) return;
console.log(`Joined: ${guild.name} (${guild.id}) — ${guild.memberCount} members`);
if (guild.isCommunity) console.log(" → Community server");
if (guild.isBoosted) console.log(` → Boost Level ${guild.boostLevel}`);
});

Guild info command

client.on("interactionCreate", async (interaction) => {
if (!interaction.isChatInputCommand() || interaction.commandName !== "serverinfo") return;
const guild = client.guilds.get(interaction.guildId!);
if (!guild) return;
const embed = new CreateEmbed()
.setTitle(guild.name)
.setThumbnail(guild.iconURL({ size: 128 }) ?? "")
.addFields(
{ name: "Members", value: String(guild.memberCount ?? "?"), inline: true },
{ name: "Boost Level", value: String(guild.boostLevel), inline: true },
{ name: "Locale", value: guild.preferredLocale, inline: true },
)
.setColor(0xf59e0b);
await interaction.reply({ embeds: [embed] });
});

client.guilds exposes one manager per guild, kept current by Gateway events and removed with the guild:

Method Holds
members(guildId) GuildMember by user ID
bans(guildId) Bans by user ID
scheduledEvents(guildId) Scheduled events by ID
roles(guildId) Role by ID
emojis(guildId) Emoji by ID
stickers(guildId) Stickers (fetchAll, create, edit, remove)
soundboard(guildId) Soundboard sounds (fetchAll, create, edit, remove)
voiceStates(guildId) Voice states by user ID
autoModerationRules(guildId) Automod rules by ID
invites(guildId) Invites by code

guilds.patch(data) merges an update into the cached guild; fields the payload omits keep their cached values.

iconURL(), avatarURL() and the other image accessors build Discord CDN URLs. The same helper is exported for assets that have no accessor, such as a guild’s old icon hash kept from an update event:

import { CDN_BASE, cdnURL, type ImageURLOptions } from "lunibee";
const options: ImageURLOptions = { size: 1024 };
cdnURL(`/icons/${guild.id}`, oldIconHash, options); // animated `a_` hashes become .gif
cdnURL(`/banners/${guild.id}`, bannerHash, { extension: "webp", forceStatic: true });
CDN_BASE; // "https://cdn.discordapp.com"

Audit log, stickers and creation time (0.3.1)

Section titled “Audit log, stickers and creation time (0.3.1)”

createdAt and createdTimestamp are on every snowflake structure (Role, Channel, Guild, …); a Message uses its own timestamp. guild.premiumProgressBarEnabled is the boost progress bar flag.

guilds.fetchAuditLogEntries(guildId, options) returns an AuditLog with typed, parsed info for the action types that carry details, and find() / filter():

import { AuditLogEvent } from "lunibee";
const log = await bot.guilds.fetchAuditLogEntries(guildId, { actionType: AuditLogEvent.MessageDelete, limit: 50 });
const entry = log.find({ type: AuditLogEvent.MessageDelete, targetId: userId, since: Date.now() - 60_000 });
if (entry?.is(AuditLogEvent.MessageDelete)) console.log(entry.info.channelId, entry.info.count); // typed: { channelId: string; count: number }
const rename = entry?.change("nick"); // { old, new }

find returns the newest match; filter returns all. type takes one action or an array, since a Date, ISO string or milliseconds. entry.options stays Discord’s raw object; entry.info is the parsed one.

new Sticker(apiSticker) wraps a raw sticker and adds url({ size }) (PNG, APNG, GIF, or the Lottie .json), animated and toItem(); stickerURL(id, formatType) builds the URL from a message’s stickers items.

VerificationLevel and PremiumTier name the numbers in guild.verificationLevel and guild.premiumTier:

VerificationLevel PremiumTier
None 0 None 0
Low 1 Tier1 1
Medium 2 Tier2 2
High 3 Tier3 3
VeryHigh 4
if (guild.premiumTier >= PremiumTier.Tier2) { /* 50 MB uploads */ }

client.guilds.fetchAutoModerationRules(guildId), fetchAutoModerationRule(guildId, ruleId) and createAutoModerationRule(guildId, data) return AutoModerationRule objects:

Property Description
id, guildId, name, creatorId Identity.
eventType, triggerType, triggerMetadata When the rule fires (Discord’s numbers and metadata).
actions What Discord does when it fires.
enabled Whether the rule is on.
exemptRoles, exemptChannels IDs the rule ignores.
toJSON() A plain object with the fields above.

Every structure with an id (Guild, Channel, User, Role, Message, AutoModerationRule…) extends BaseStructure. It provides id, createdAt and createdTimestamp (read from the snowflake), and toString().