GiveawayBot’s SQLite database contains two tables:Documentation Index
Fetch the complete documentation index at: https://mintlify.com/resynceddesign/giveawaybot/llms.txt
Use this file to discover all available pages before exploring further.
giveaways, which stores every giveaway and its live entry list, and guilds, which stores per-server configuration. Both tables are created with CREATE TABLE IF NOT EXISTS on startup so the bot never errors if the file is fresh.
giveaways table
Auto-increment primary key. Used internally to identify a giveaway row and as the argument to
endGiveaway() and addEntry().Discord channel snowflake (string) where the giveaway embed was posted. Used by
processGiveaways() to fetch the channel and send winner announcements.Giveaway duration in seconds. Combined with
createdAt to calculate the end time: endTime = createdAt + duration * 1000.Number of winners to pick when the giveaway ends.
pickWinners() iterates up to this count when sampling from entries.Prize description string provided by the host via
/gcreate. Used as the embed title and in winner announcement messages.JSON array of Discord user ID strings representing everyone who clicked the entry button. Example:
["123456789", "987654321"]. Stored as text and parsed with JSON.parse() at runtime. Starts as [] on creation.UTC timestamp set automatically by SQLite when the row is inserted.
checkEnding() parses this value with new Date() to determine whether the giveaway has expired.Discord message snowflake of the giveaway embed. Set after the embed is posted. Used by
processGiveaways() to fetch and edit the message when the giveaway ends, and by fetchGiveaway() as an alternative lookup key.Discord user snowflake of the member who ran
/gcreate. Displayed in the embed footer and winner announcement messages.Discord guild snowflake. Used to look up the guild’s configured color, emoji, and ping preference from the
guilds table when rendering embeds.Active flag.
1 = giveaway is running and accepting entries. 0 = giveaway has ended. fetchActive() filters to status = 1; endGiveaway() sets this to 0.guilds table
Discord guild snowflake. Primary key. A row is inserted when the bot joins a server and used as the lookup key for all config reads during giveaway rendering.
Hex colour string applied to the giveaway embed via
EmbedBuilder.setColor(). Configurable with /gconfig color. Falls back to #ff8e4d if the row is missing.Whether to include a spoiler-wrapped
@everyone mention in the giveaway-ended message. 0 = disabled, 1 = enabled. Toggled with /gconfig ping.Emoji shown on the entry button label and in the giveaway header/footer text. Configurable with
/gconfig emoji. Falls back to 🎊 if the row is missing.GiveawayManager methods
Inserts a new row into the
giveaways table. entries defaults to [] if not provided. status defaults to 1 via the column default.Sets
status = 0 on the row with the given id. Called by processGiveaways() immediately after winners are picked.Returns all rows where
status = 1. Called every second by checkEnding() to determine which giveaways need to be checked for expiry.Looks up a giveaway by its integer
id first. If no row is found, falls back to a lookup by messageId. This makes the method work with either the database row ID or the Discord message snowflake.Calls
fetchActive() and compares each giveaway’s createdAt + duration * 1000 against Date.now(). Returns an array of id strings for every giveaway whose end time has passed.Parses
giveaway.entries as a JSON array, then randomly samples up to giveaway.winners unique user IDs by splicing from the array. Returns an empty array if there are no entries. Duplicate winners are not possible because each selected entry is removed from the pool before the next pick.Reads the current
entries array for the given giveawayId. Returns false without writing if the giveaway does not exist or if userId is already present in the array. Otherwise appends userId, serialises the array back to JSON, and updates the row. Returns true on a successful entry.GuildManager methods
Inserts a new row for the guild using
INSERT OR IGNORE, so calling it multiple times for the same guild is safe. color defaults to #ff8e4d when omitted.Updates the
color column for the given guild. Called by /gconfig color.Updates the
emoji column for the given guild. Called by /gconfig emoji.Updates
everyonePing to 1 or 0 based on the boolean argument. Called by /gconfig ping.Returns the guild’s configured embed colour, or
#ff8e4d if no row exists.Returns the guild’s configured emoji, or
🎊 if no row exists.Returns
true if everyonePing = 1 for the guild, false otherwise (including when no row exists).Giveaway TypeScript interface
The Giveaway interface is defined in gwManager.ts and used as the argument and return type for all GiveawayManager methods:
id, createdAt, and status are optional because they are supplied by SQLite (auto-increment, default timestamp, and default 1 respectively) rather than by the caller when creating a new giveaway.entries is typed as string rather than string[] because it is stored as a serialised JSON string in SQLite. Always use JSON.parse(giveaway.entries) before working with the array, and JSON.stringify(entries) before writing it back.