Cache Policy & Flags
When defining a bot, you can control how DiSky caches members and other Discord entities. Proper cache configuration optimizes memory usage and performance.
Member Cache Policy
Section titled “Member Cache Policy”The cache policy determines which members are cached and accessible without retrieval.
Available Policies
Section titled “Available Policies”| Policy | Description | Required Intent |
|---|---|---|
all | Cache all members in all guilds | Guild Members (privileged) |
none | Don’t cache any members | None |
owner | Cache only guild owners | None |
online | Cache only online members | Guild Presences (privileged) |
voice | Cache only members in voice channels | Guild Voice States |
booster | Cache only server boosters | Guild Members (privileged) |
default | Default policy (recommended) | Guild Members + Guild Presences |
How It Works
Section titled “How It Works”Members in cache can be accessed instantly using getters:
# If member is cached, this works instantlyset {_member} to member with id "123" in {_guild}Members not in cache must be retrieved (requires API call):
# If member is not cached, you must retrieve itretrieve member with id "123" from {_guild} and store it in {_member}# Use {_member} hereChoosing a Policy
Section titled “Choosing a Policy”Use all if:
- You need access to all members
- Your bot manages members
- You have the Guild Members intent
Use online if:
- You only work with online members
- You want to save memory
- You have the Guild Presences intent
Use none if:
- You don’t work with members
- You only use slash commands
- You want minimal memory usage
Use default if:
- You’re unsure what you need
- You want balanced performance
Cache Flags
Section titled “Cache Flags”Cache flags determine what data is cached about entities.
Available Flags
Section titled “Available Flags”| Flag | Description | Required Intent |
|---|---|---|
activity | Member activities (playing, streaming, etc.) | Guild Presences (privileged) |
voice state | Member voice channel states | Guild Voice States |
emoji | Guild emojis | Guild Emojis and Stickers |
sticker | Guild stickers | Guild Emojis and Stickers |
client status | Member device status (mobile, desktop, web) | Guild Presences (privileged) |
member overrides | Member permission overrides | None |
role tags | Role tags (bot role, booster role, etc.) | None |
forum tags | Forum tags and thread tags | None |
online status | Member online status | Guild Presences (privileged) |
scheduled events | Guild scheduled events | Scheduled Events |
Special Options
Section titled “Special Options”| Option | Description |
|---|---|
all | Enable all cache flags |
none | Disable all cache flags |
default flags | Enable activity, voice state, and online status |
Choosing Cache Flags
Section titled “Choosing Cache Flags”Use default flags for most bots:
cache flags: default flagsThis enables:
- Activity (what members are playing)
- Voice state (voice channel presence)
- Online status (online, idle, dnd, offline)
Use specific flags if you have special needs:
# Only cache what you needcache flags: emoji, sticker, forum tagsUse all if you need everything:
cache flags: allUse none for minimal memory:
cache flags: noneExamples
Section titled “Examples”Minimal Configuration
Section titled “Minimal Configuration”define new bot named "MyBot": token: "YOUR_TOKEN" intents: guild messages policy: none cache flags: noneUse when:
- Only using slash commands
- No member management
- Minimal memory footprint needed
Standard Configuration
Section titled “Standard Configuration”define new bot named "MyBot": token: "YOUR_TOKEN" intents: default intents, guild members, message content policy: all cache flags: default flagsUse when:
- Working with members
- Need member status
- General-purpose bot
Voice Bot Configuration
Section titled “Voice Bot Configuration”define new bot named "MyBot": token: "YOUR_TOKEN" intents: default intents, guild voice states policy: voice cache flags: voice stateUse when:
- Music/voice bot
- Only need members in voice
- Want to optimize memory
Emoji/Sticker Bot
Section titled “Emoji/Sticker Bot”define new bot named "MyBot": token: "YOUR_TOKEN" intents: default intents, guild expressions policy: none cache flags: emoji, stickerUse when:
- Managing emojis/stickers
- Don’t need member data
Full-Featured Bot
Section titled “Full-Featured Bot”define new bot named "MyBot": token: "YOUR_TOKEN" intents: all intents policy: all cache flags: allUse when:
- Need all features
- Memory is not a concern
- Want maximum functionality
Impact on Performance
Section titled “Impact on Performance”Memory Usage
Section titled “Memory Usage”More caching = more memory usage:
none < owner < booster < voice < online < allAPI Calls
Section titled “API Calls”Less caching = more API calls needed:
- Cached data: Instant access, no API call
- Uncached data: Must retrieve, requires API call + time
Finding Balance
Section titled “Finding Balance”For most bots, this is optimal:
policy: allcache flags: default flagsIt provides:
- Instant member access
- Status/activity information
- Voice state tracking
- Reasonable memory usage
Troubleshooting
Section titled “Troubleshooting””Member not found” Error
Section titled “”Member not found” Error”Your member might not be cached.
Solutions:
- Use a wider cache policy (e.g.,
all) - Enable Guild Members intent
- Retrieve the member instead of getting it:
retrieve member with id "123" from {_guild} and store it in {_member}
High Memory Usage
Section titled “High Memory Usage”You’re caching too much.
Solutions:
- Use a narrower policy (
online,voice, ornone) - Reduce cache flags to only what you need
- Don’t use
allfor policy and cache flags unless necessary
Activity/Status Not Available
Section titled “Activity/Status Not Available”You need cache flags enabled.
Solution:
cache flags: activity, online statusAnd enable Guild Presences intent.
Best Practices
Section titled “Best Practices”- Start with defaults - They work for most bots
- Enable required intents - Cache flags won’t work without proper intents
- Monitor memory - Adjust cache settings if memory is an issue
- Cache what you use - Don’t cache data you never access
- Consider bot size - Large bots (100+ servers) should be more conservative with caching
Next Steps
Section titled “Next Steps”- Learn about Gateway Intents
- Configure Presence & Status
- Understand Bot Configuration