Bot Configuration
When defining a bot in DiSky, you can configure various aspects of how it connects to and interacts with Discord. This guide covers the main configuration options available.
Basic Bot Structure
Section titled “Basic Bot Structure”Here’s a complete bot definition with all available options:
define new bot named "MyBot": # Required: Your bot's token token: "YOUR_BOT_TOKEN"
# Gateway intents (what events to receive) intents: default intents
# Member cache policy policy: all
# Cache flags (what to cache) cache flags: default flags
# Gateway compression compression: none
# Auto-reconnect on disconnect auto reconnect: true
# Force reload on script reload force reload: falseConfiguration Options
Section titled “Configuration Options”Token (Required)
Section titled “Token (Required)”Your bot’s secret token from the Discord Developer Portal.
token: "YOUR_BOT_TOKEN_HERE"Intents
Section titled “Intents”Gateway intents determine which events your bot can receive from Discord. See Gateway Intents for detailed information.
# Use default intents (recommended for most bots)intents: default intents
# Or specify specific intentsintents: guild members, message content, guild presences
# Enable all intentsintents: all intentsPolicy
Section titled “Policy”The member cache policy determines how DiSky caches guild members. See Cache Policy for details.
policy: all # Cache all members (requires guild members intent)policy: none # Don't cache memberspolicy: owner # Cache only guild ownerspolicy: online # Cache only online members (requires guild presences intent)policy: voice # Cache only members in voice channelspolicy: booster # Cache only server boosterspolicy: default # Default policy (recommended)Cache Flags
Section titled “Cache Flags”Cache flags determine which entity data to cache. See Cache Policy for details.
# Use default cache (recommended)cache flags: default flags
# Specify specific flagscache flags: activity, voice state, emoji, sticker
# Cache everythingcache flags: all
# Cache nothingcache flags: noneCompression
Section titled “Compression”Gateway compression reduces bandwidth usage. Most bots should use none.
compression: none # No compression (default, recommended)compression: zlib # Use zlib compressionAuto Reconnect
Section titled “Auto Reconnect”Whether the bot should automatically reconnect if disconnected from Discord.
auto reconnect: true # Automatically reconnect (recommended)auto reconnect: false # Don't reconnect automaticallyForce Reload
Section titled “Force Reload”Whether to reload the bot’s connection when the script is reloaded.
force reload: false # Don't reload connection (recommended)force reload: true # Reload connection on script reloadReady Sections
Section titled “Ready Sections”The bot structure supports three event sections that run at specific times:
on ready
Section titled “on ready”Runs once when the bot is fully loaded (including all guilds):
define new bot named "MyBot": token: "..."
on ready: send "&a%event-bot% is ready!" to console # Register global slash commands hereEvent value: event-bot
on guild ready
Section titled “on guild ready”Runs when each guild is fully loaded:
define new bot named "MyBot": token: "..."
on guild ready: send "&a%event-guild% is ready!" to console # Register guild-specific slash commands hereEvent values: event-bot, event-guild
on shutdown
Section titled “on shutdown”Runs when the bot is about to disconnect:
define new bot named "MyBot": token: "..."
on shutdown: send "&c%event-bot% is shutting down!" to console # Clean up resourcesEvent value: event-bot
Complete Example
Section titled “Complete Example”Here’s a real-world example with optimal settings:
define new bot named "MyBot": # Bot token token: "YOUR_TOKEN_HERE"
# Enable intents we need intents: default intents, guild members, message content
# Cache all members policy: all
# Cache activity, voice, and online status cache flags: default cache
# No compression compression: none
# Auto reconnect auto reconnect: true
# Don't force reload force reload: false
# Bot is ready on ready: send "&a[Bot] %event-bot% is online!" to console send "&7Loaded %size of guilds of event-bot% guilds" to console
# Set bot presence set presence of event-bot to playing "Minecraft"
# Guild is ready on guild ready: send "&7Guild %event-guild% loaded" to console
# Bot is shutting down on shutdown: send "&c[Bot] %event-bot% is going offline" to consoleBest Practices
Section titled “Best Practices”- Start with defaults: Use
default intents,default flags, andpolicy: allunless you have specific needs - Enable required intents: Make sure to enable privileged intents in the Developer Portal if needed
- Keep force reload false: Avoid unnecessary reconnections
- Use ready sections: Initialize your bot properly in the
on readysection
Next Steps
Section titled “Next Steps”- Learn more about Gateway Intents
- Understand Cache Policy & Flags
- Set up Presence & Status