Discord Integration

Interact with Sand Framework directly from your Discord server using our powerful bot integration.

Features

  • /sand help - Show available commands

  • /sand analyze <code> - Analyze Solana code

  • /sand explain <error> - Explain an error

  • /sand optimize <code> - Suggest optimizations

Bot Setup

  1. Create a Discord Application:

  2. Configure Permissions:

Required Permissions:
- Send Messages
- Read Messages/View Channels
- Use Slash Commands
- Embed Links
  1. Set Environment Variables:

DISCORD_TOKEN=your_bot_token
DISCORD_PREFIX=/sand
DISCORD_GUILD_ID=your_guild_id  # Optional, for single server

Command Usage

Code Analysis

/sand analyze
@program
def initialize(ctx, data):
    # Your Solana program
    pass

Price Tracking

/price SOL

Response:

SOL/USD: $100.25 (↑2.5%)
24h Volume: $1.2B

Customization

Create custom commands in bot/cogs:

from discord.ext import commands

class CustomCog(commands.Cog):
    def __init__(self, bot):
        self.bot = bot
    
    @commands.command()
    async def custom(self, ctx):
        await ctx.send("Custom command!")

def setup(bot):
    bot.add_cog(CustomCog(bot))

Webhooks

Configure Discord webhooks for automated notifications:

async def send_price_alert(webhook_url, token, price):
    async with aiohttp.ClientSession() as session:
        webhook = Webhook.from_url(webhook_url, session=session)
        await webhook.send(f"🚨 {token} reached ${price}!")

Last updated