npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@metagames/channel-bot-sdk

v1.0.2

Published

Brickverse guild channel bot SDK

Readme

Brickverse Channel Bot SDK

TypeScript SDK for building Brickverse guild channel bots.

What is included

  • WebSocket gateway client for bot events
  • Bot runtime REST helpers for sending/editing/deleting messages
  • Command router with convenience reply helpers
  • Typed event payloads
  • Examples and docs

Creating a Bot Account

A BrickVerse.gg bot account is required, you can create one for free at https://brickverse.gg/my/guild-bots.

Getting your bot verified

Verifications are issued at the discretion of BrickVerse automatically, we only grant verification checkmark to tools being popularly used in large amount of guilds, official partnerships, etc.

Install

npm i @metagames/channel-bot-sdk

Quick Example

import {
	ChannelBotClient,
	CommandRouter,
	DEFAULT_ROUTER_SUBSCRIBED_EVENTS,
} from "@metagames/channel-bot-sdk";

const client = new ChannelBotClient({
	token: process.env.BOT_TOKEN!,
	apiBaseUrl: "https://api.brickverse.gg",
	subscribedEvents: DEFAULT_ROUTER_SUBSCRIBED_EVENTS,
});

const router = new CommandRouter()
	.command("ping", async (ctx) => {
		await ctx.replyMention("pong");
	})
	.button("verify", async (ctx) => {
		await ctx.replyEphemeral("Verification flow started.");
	})
	.selectMenu("role-picker", async (ctx) => {
		await ctx.reply(`You selected: ${ctx.selectedValues.join(", ") || "none"}`);
	})
	.modal("support-form", async (ctx) => {
		await ctx.replyEphemeral(
			`Received form fields: ${Object.keys(ctx.modalValues).join(", ")}`,
		);
	})
	.command("echo", async (ctx) => {
		await ctx.reply(ctx.args.join(" ") || "Nothing to echo.");
	});

client.useCommandRouter(router);

client.on("guildBot.ready", (event) => {
	console.log(`Logged in as ${event.bot.username}`);
});

await client.connect();

Event Subscriptions (Required vs Optional)

The gateway supports filtered subscriptions. You choose which events your bot receives with subscribedEvents.

  • Required for slash command handling: guildBot.interactionCreate
  • Strongly recommended operational defaults: guildBot.installationCreate, guildBot.installationDelete

These three defaults are exported as DEFAULT_ROUTER_SUBSCRIBED_EVENTS and are used in SDK examples. If you use CommandRouter, the SDK also auto-adds these defaults so command handling keeps working.

Add more events only when your bot needs them (for example, member moderation or message analytics) to reduce gateway traffic and simplify handlers.

Permission-Aware Events

Interaction and message events now include guild permission context for users.

  • event.interaction.user.permissions (string bitfield)
  • event.interaction.user.rankLevel
  • event.interaction.user.isPlatformAdmin
  • event.interaction.user.isGuildOwner
  • event.interaction.user.isGuildAdmin

You can use SDK helpers to check permissions:

import { GuildPermissions, hasAnyPermission } from "@metagames/channel-bot-sdk";

client.on("guildBot.interactionCreate", async (event) => {
	if (
		event.interaction.user.isPlatformAdmin ||
		hasAnyPermission(event.interaction.user.permissions, [
			GuildPermissions.ADMINISTRATOR,
			GuildPermissions.MANAGE_MEMBERS,
		])
	) {
		console.log("User can manage members");
	}
});

Command Reply Helpers

The command handler receives a CommandContext with:

  • ctx.reply("text")
  • ctx.reply({ content, embeds })
  • ctx.reply("text", { ephemeral: true })
  • ctx.reply({ content, embeds, ephemeral: true })
  • ctx.replyMention("text")
  • ctx.replyEmbed(embed, optionalContent)
  • ctx.followUp("text")
  • ctx.followUp("text", { ephemeral: true })
  • ctx.timeoutMember(userId, durationMinutes)
  • ctx.clearMemberTimeout(userId)
  • ctx.hasPermission(permission)
  • ctx.hasAnyPermission(permissions)
  • ctx.hasAllPermissions(permissions)
  • ctx.canManageMembers()
  • ctx.interactionType
  • ctx.buttonId
  • ctx.selectId
  • ctx.selectedValues
  • ctx.modalId
  • ctx.modalValues
  • ctx.isSlashCommand()
  • ctx.isButtonInteraction()
  • ctx.isSelectMenuInteraction()
  • ctx.isModalSubmitInteraction()

Router interaction helpers:

  • router.command(name, handler) for slash commands (auto-registered by default)
  • router.button(id, handler) for button interactions (button:<id>)
  • router.selectMenu(id, handler) for select menu interactions (select:<id>)
  • router.modal(id, handler) for modal submissions (modal:<id>)

Automatic Slash Command Registration

When you use CommandRouter, the SDK now auto-registers missing slash commands on connect by calling createSlashCommand() for each router command.

const client = new ChannelBotClient({
	token: process.env.BOT_TOKEN!,
	apiBaseUrl: "https://api.brickverse.gg",
	autoRegisterCommands: true, // default true
	pruneMissingCommands: false, // default false
	subscribedEvents: DEFAULT_ROUTER_SUBSCRIBED_EVENTS,
});

const router = new CommandRouter()
	.command(
		"ping",
		async (ctx) => {
			await ctx.replyMention("pong");
		},
		{ description: "Health check" },
	)
	.command(
		"timeout",
		async (ctx) => {
			const userId = ctx.args[0];
			const minutes = Number(ctx.args[1] || "10");
			if (!userId) {
				await ctx.reply("Usage: /timeout <userId> [minutes]");
				return;
			}
			await ctx.timeoutMember(userId, Math.max(1, minutes));
			await ctx.followUp(`Timed out ${userId} for ${Math.max(1, minutes)}m`);
		},
		{
			description: "Timeout a guild member",
			options: [
				{
					name: "userId",
					required: true,
					description: "Target member user id",
				},
				{
					name: "minutes",
					required: false,
					description: "Duration in minutes",
				},
			],
		},
	);

client.useCommandRouter(router);
await client.connect();

API Surface

  • client.connect()
  • client.login() (alias of connect)
  • client.disconnect()
  • client.destroy() (alias of disconnect)
  • client.on(eventName, listener)
  • client.once(eventName, listener)
  • client.onAlias(eventName, listener)
  • client.onReady(listener) / client.onClose(listener)
  • client.onMessageCreate(listener) / client.onInteractionCreate(listener)
  • client.onGuildCreate(listener) / client.onGuildDelete(listener)
  • client.onCommandError(listener)
  • client.isReady() / client.isConnected()
  • client.getWebSocketReadyState() / client.getWebSocketState()
  • client.getSubscribedEvents()
  • client.setSubscribedEvents(events)
  • client.addSubscribedEvents(events)
  • client.getMe()
  • client.sendMessage({ guildId, channelId, content, embeds })
  • client.sendEmbed({ guildId, channelId, embed, content })
  • client.editMessage(messageId, { content, embeds })
  • client.deleteMessage(messageId)
  • client.createSlashCommand({ name, description, options })
  • client.deleteSlashCommand(commandId)
  • client.syncCommandRouterSlashCommands()
  • client.timeoutMember({ guildId, userId, durationMinutes })
  • client.clearMemberTimeout({ guildId, userId })
  • client.timeout(guildId, userId, durationMinutes)
  • client.removeTimeout(guildId, userId)

Installation Lifecycle Events

client.on("guildBot.installationCreate", (event) => {
	console.log(
		`Installed in ${event.guildName} (${event.guildId}) with ${event.permissions}`,
	);
});

client.on("guildBot.installationDelete", (event) => {
	console.log(`Uninstalled from ${event.guildName} (${event.guildId})`);
});

// discord.js-style aliases are also available:
client.on("guildCreate", (event) => {
	console.log(`Installed in ${event.guildName} (${event.guildId})`);
});

client.once("ready", () => {
	console.log("Gateway ready");
});

Docs

Examples