Loot
Boss loot priority signup system. Players indicate Major/Minor/Want In/Do Not Need per boss via buttons on embed messages.
Files
- •
functions/loot/checkRaidExpansions.js— Discovers active raids from Raider.io and creates loot posts - •
functions/loot/addLootPost.js— Creates a loot post message for a single boss - •
functions/loot/generateLootPost.js— Builds embed + button components for a loot post - •
functions/loot/updateLootPost.js— Refreshes loot post with current player responses - •
functions/loot/updateLootResponse.js— Records a player's response and updates the post - •
functions/loot/deleteLootPost.js— Removes a loot post message and its DB entry - •
commands/loot.js— Slash command definitions
Flow
Auto-Discovery
checkRaidExpansions(client):
- •Starts at expansion 9 (
const initialExpansion = 9) - •Calls
raiderioService.getRaidStaticData(expansion)for each expansion - •Stops when API returns 400 status (no more expansions)
- •For each expansion's raids, checks if
new Date(raid.ends.eu) > currentDate(active raid) - •Creates a loot post for each encounter/boss in the active raid via
addLootPost
Post Creation
addLootPost(channel, boss):
- •
bossobject:{ id, name, url } - •Calls
generateLootPostto build the embed and buttons - •Sends message to the provided channel
- •Stores initial data in
lootResponsesnamespace
Initial data shape:
code
{
major: [],
minor: [],
wantIn: [],
wantOut: [],
channelId: string,
messageId: string,
bossName: string,
bossUrl: string
}
Embed Structure
generateLootPost(bossName, bossId, playerResponses):
- •Embed with 4 inline fields: Major, Minor, Want In, Do not need
- •4 buttons in a single ActionRow:
| Label | Style | Custom ID Pattern |
|---|---|---|
| Major | ButtonStyle.Success (green) | updateLootResponse|major|{bossId} |
| Minor | ButtonStyle.Primary (blue) | updateLootResponse|minor|{bossId} |
| Want In | ButtonStyle.Secondary (gray) | updateLootResponse|wantIn|{bossId} |
| Do not need | ButtonStyle.Danger (red) | updateLootResponse|wantOut|{bossId} |
Response Handling
Button clicks route through interactionCreate.js (matches interaction.customId.startsWith('updateLootResponse')).
updateLootResponse(client, response, bossId, userId):
- •Fetches current boss loot responses from DB
- •Removes
userIdfrom all 4 response categories - •Adds
userIdto the selected response category - •Saves updated responses to DB
- •Calls
updateLootPostto refresh the embed message - •Returns empty string
''
Player Name Resolution
updateLootPost(client, bossId):
- •Reads all raiders from
raidersnamespace to build{ key: name, value: userId }array - •
generatePlayerResponseStringmaps user IDs to character names via.find(o => o.value === playerId) - •Reconstructs the embed with resolved player names and edits the Discord message
Keyv Namespaces
| Namespace | Key | Value |
|---|---|---|
lootResponses | Boss ID (number) | { major: [userId], minor: [userId], wantIn: [userId], wantOut: [userId], channelId, messageId, bossName, bossUrl } |
raiders | Character name | Discord user ID (read-only, for name resolution) |
Slash Commands
/loot add_post
- •No options. Creates a test loot post with hardcoded boss (id: 1, name: "Test Boss").
/loot delete_post
- •Option:
boss_id(integer, required) — Boss ID to delete.
/loot delete_posts
- •Option:
boss_ids(string, required) — Comma-separated boss IDs. Split by,and deleted viaPromise.all.
/loot create_posts
- •No options. Runs
checkRaidExpansionsto auto-discover active raids and create posts.
/loot update_priority_post
- •Option:
create_post(boolean, optional) — If true, creates new EPGP priority post. If false/omitted, updates existing one. - •Note: This subcommand bridges to the EPGP domain (
createPriorityRankingPost/updatePriorityRankingPost).
Button Custom ID Pattern
All loot buttons use: updateLootResponse|{type}|{bossId}
Parsed in interactionCreate.js via: const [, response, bossId] = interaction.customId.split('|')
Config Dependencies
- •
databaseString— Keyv connection string - •
lootChannelId— Channel where loot posts are created (used bycheckRaidExpansions)
External APIs
- •Raider.io —
getRaidStaticData(expansionId)for raid/encounter discovery