Package
gateway v0.9.0

About
@seedcord/gateway is the transport for a gateway bot. It holds a websocket connection to Discord through the discord.js client, which also keeps the cache. That connection carries message, member, voice, and reaction events, and Discord only sends those over a websocket. Pick this transport when your bot reacts to any of them.
A bot that only answers commands and components can use @seedcord/http instead, which keeps no connection open and also runs on Cloudflare Workers.
seedcord is pre-1.0, so a minor version can break your bot. Each release's changelog says what changed and how to update.
Installation
pnpm create seedcord sets up a new bot. To add seedcord to an existing project:
pnpm add @seedcord/gateway discord.js @discordjs/builders envapt
pnpm add -D seedcord vite typescriptdiscord.js, @discordjs/builders, envapt, and typescript are peer dependencies. seedcord is the CLI that runs the bot in dev and builds it.
Usage
bot.ts creates the bot and tells it where your handlers are:
import { Seedcord } from '@seedcord/gateway';
import { GatewayIntentBits } from 'discord.js';
import { Converters, Envapter } from 'envapt';
export default new Seedcord({
bot: {
clientOptions: { intents: [GatewayIntentBits.Guilds, GatewayIntentBits.GuildMessages] },
interactions: { path: './handlers' },
commands: {
path: './commands',
guilds: Envapter.getAs('TESTING_GUILD_IDS', Converters.array(), [])
},
events: { path: './events' }
},
subscribers: { path: null }
});Read your environment through envapt, the way TESTING_GUILD_IDS is read above. seedcord loads your .env files into envapt, and reads DISCORD_BOT_TOKEN from it too. envapt also reads your shell's variables, while process.env misses everything in your .env files.
A file in events/ reacts to any discord.js client event. Its handler receives the same arguments discord.js passes to client.on():
import { EventHandler, RegisterEvent } from '@seedcord/gateway';
import { Events } from 'discord.js';
@RegisterEvent([Events.MessageCreate])
export class Mentioned extends EventHandler<Events.MessageCreate> {
public async execute(): Promise<void> {
const [message] = this.event;
if (message.mentions.users.has(message.client.user.id)) await message.reply('hey');
}
}Slash commands, components, checks, and plugins work the same way as on http. The guide covers them.
What it adds over the core
Everything in @seedcord/core, plus:
Seedcord, which connects to Discord and holds the discord.js client- handlers that read discord.js objects, like a
ChatInputCommandInteraction - event handlers for every discord.js client event, through
EventHandlerand@RegisterEvent getConfirmation, which shows buttons and waits for the answer in oneawait