@signalbox/discord-bot
v0.2.3
Published
signalbox plugin: a Discord gateway bot (slash commands, send, DM) via discord.js
Downloads
194
Readme
@signalbox/discord-bot
signalbox plugin: a Discord gateway bot (slash commands, send, DM) via discord.js.
Part of signalbox — see the full documentation.
Install
npm install @signalbox/discord-botUsage
import { discordBotPlugin } from "@signalbox/discord-bot"
const plugins = {
bot: discordBotPlugin({
token,
guildId, // register commands to one guild (instant) vs globally (~1h)
commands: [{ name: "ping", description: "check the bot is alive" }],
}),
}
// in a workflow:
ctx.plugins.bot.events.flow("command").effect(async cmd => {
if (cmd.command === "ping") await cmd.reply("pong")
})
await ctx.plugins.bot.dm(userId, "hi there")Registers the given slash commands on startup and emits a command event per invocation. send(channelId, content) and dm(userId, content) post messages. Build command payloads by hand or with toApplicationCommand.
License
MIT
