@aarekaz/switchboard-discord
v0.3.5
Published
Discord adapter for Switchboard SDK
Maintainers
Readme
@aarekaz/switchboard-discord
Discord adapter for Switchboard SDK.
Installation
npm install @aarekaz/switchboard-core @aarekaz/switchboard-discord
# or
pnpm add @aarekaz/switchboard-core @aarekaz/switchboard-discordUsage
Simply import the Discord adapter and it will auto-register with Switchboard core:
import { createBot } from '@aarekaz/switchboard-core';
import '@aarekaz/switchboard-discord'; // Auto-registers Discord adapter
const bot = createBot({
platform: 'discord',
credentials: {
token: process.env.DISCORD_TOKEN,
},
});
bot.onMessage(async (message) => {
if (message.text.includes('ping')) {
await bot.reply(message, 'pong! 🏓');
}
});
await bot.start();Getting a Discord Bot Token
- Go to Discord Developer Portal
- Create a new application
- Go to "Bot" → "Add Bot"
- Copy the token
- Enable "Message Content Intent" under "Privileged Gateway Intents"
Inviting Your Bot
- Go to "OAuth2" → "URL Generator"
- Select scopes:
bot - Select permissions:
Send Messages,Read Message History,Add Reactions - Copy the generated URL and open it in your browser
- Select a server and authorize
Discord-Specific Features
You can use Discord-specific features by passing platform-specific options:
import { EmbedBuilder } from 'discord.js';
await bot.sendMessage('channel-id', 'Check out this embed!', {
discord: {
embeds: [
new EmbedBuilder()
.setTitle('Hello!')
.setDescription('This is a Discord embed')
.setColor(0x0099ff),
],
},
});Known Limitations
- Message editing/deletion: Requires implementing message caching (coming in Phase 5)
- Reactions: Requires implementing message caching (coming in Phase 5)
- Threads: Requires implementing message caching (coming in Phase 5)
These features will be fully supported once we implement the message cache system.
Documentation
For full documentation, visit github.com/Aarekaz/switchboard
License
MIT
