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
/price <token>- Get token price/sentiment <token>- Get market sentiment/alert set <condition>- Set price alerts
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 LinksSet Environment Variables:
DISCORD_TOKEN=your_bot_token
DISCORD_PREFIX=/sand
DISCORD_GUILD_ID=your_guild_id # Optional, for single serverCommand Usage
Code Analysis
/sand analyze@program
def initialize(ctx, data):
# Your Solana program
passPrice Tracking
/price SOLResponse:
SOL/USD: $100.25 (↑2.5%)
24h Volume: $1.2BCustomization
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}!")async def send_security_alert(webhook_url, severity, message):
embed = discord.Embed(
title=f"Security Alert: {severity}",
description=message,
color=discord.Color.red()
)
async with aiohttp.ClientSession() as session:
webhook = Webhook.from_url(webhook_url, session=session)
await webhook.send(embed=embed)Keep your bot token secure and never share it publicly!
Last updated