Discord 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
Create a Discord Application:
Go to Discord Developer Portal
Create a new application
Add a bot user
Copy the bot token
Configure Permissions:
Required Permissions:
- Send Messages
- Read Messages/View Channels
- Use Slash Commands
- Embed Links
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}!")
Keep your bot token secure and never share it publicly!
Last updated