FabricFabricSDK
Plugins

Discord

Send messages and manage channels via the Discord Bot API.

Authentication

TypeDefaultDetails
bot_tokenBot Token sent as Authorization: Bot <token>
oauth_2Discord OAuth with bot scope

The plugin defaults to Bot prefix for bot tokens. OAuth access tokens are sent as Bearer. Set tokenType explicitly to override.

Endpoints

PathRiskDescription
messages.createwritePost a message to a channel.
messages.getreadGet a single message.
messages.deletedestructiveDelete a message.
channels.getreadGet channel metadata.
channels.listreadList channels in a guild.
guilds.getreadGet guild metadata.
users.mereadGet the authenticated bot user.

messages.create

Post a message to a channel.

Input:

FieldTypeRequiredDescription
channelIdstringChannel ID
contentstringMessage text (required unless embeds)
embedsarrayEmbed objects
ttsbooleanText-to-speech
message_referenceobjectReply to: { message_id: string }

Output: DiscordMessage

messages.get

Get a single message.

Input:

FieldTypeRequiredDescription
channelIdstringChannel ID
messageIdstringMessage ID

Output: DiscordMessage

messages.delete

Delete a message.

Input:

FieldTypeRequiredDescription
channelIdstringChannel ID
messageIdstringMessage ID

Output: { ok: boolean }

channels.get

Get channel metadata.

Input:

FieldTypeRequiredDescription
channelIdstringChannel ID

Output: DiscordChannel

channels.list

List channels in a guild.

Input:

FieldTypeRequiredDescription
guildIdstringGuild ID

Output: DiscordChannel[]

guilds.get

Get guild metadata.

Input:

FieldTypeRequiredDescription
guildIdstringGuild ID

Output: DiscordGuild

users.me

Get the authenticated bot user.

Input: None

Output: DiscordUser

Usage

import { createFabric } from "@fabricorg/integrations";
import { discord } from "@fabricorg/integrations/plugins";

const fabric = createFabric({
  plugins: [discord({ botToken: process.env.DISCORD_BOT_TOKEN })],
});

// Send a message
const msg = await fabric.discord.api.messages.create({
  channelId: "1234567890123456789",
  content: "Hello from Fabric!",
});

// Reply to a message
await fabric.discord.api.messages.create({
  channelId: "1234567890123456789",
  content: "Thanks for the update!",
  message_reference: { message_id: msg.id },
});

Webhooks

Discord webhooks are not yet implemented in this plugin. Slash command interactions (which require Ed25519 signature verification) are planned for a dedicated discord-interactions plugin.

Types

interface DiscordChannel {
  id: string;
  type: number;
  name?: string;
  guild_id?: string;
  topic?: string | null;
  parent_id?: string | null;
}

interface DiscordMessage {
  id: string;
  channel_id: string;
  content: string;
  author?: { id: string; username: string; bot?: boolean };
  timestamp?: string;
}

interface DiscordUser {
  id: string;
  username: string;
  discriminator?: string;
  avatar?: string | null;
  bot?: boolean;
}

interface DiscordGuild {
  id: string;
  name: string;
  owner_id?: string;
  member_count?: number;
}