Create Discord Feed

User Intent

"How do I sync Discord server messages? Show me Discord feed configuration."

Operation

SDK Method: createFeed() with FeedTypes.Discord Auth: Bot token required


Code Example (TypeScript)

import { Graphlit } from 'graphlit-client';
import {
  FeedTypes,
  FeedListingTypes,
  DiscordChannelsInput,
  DiscordGuildsInput,
} from 'graphlit-client/dist/generated/graphql-types';

const graphlit = new Graphlit();

const discordAuth: DiscordGuildsInput = {
  token: process.env.DISCORD_BOT_TOKEN!,
};

// Enumerate guilds (servers) the bot can access
const guildsResponse = await graphlit.queryDiscordGuilds(discordAuth);
const guilds = guildsResponse.discordGuilds?.results ?? [];

if (guilds.length === 0) {
  throw new Error('No Discord guilds available for the provided bot token');
}

const guild = guilds[0]!;
console.log(`Using Discord guild: ${guild.guildName} (${guild.guildId})`);

// Enumerate channels inside the selected guild
const channelsResponse = await graphlit.queryDiscordChannels({
  guildId: guild.guildId!,
  token: discordAuth.token,
});

const channels = channelsResponse.discordChannels?.results ?? [];

if (channels.length === 0) {
  throw new Error('No Discord channels available in the selected guild');
}

const channel = channels[0]!;
console.log(`Using Discord channel: ${channel.channelName}`);

const feed = await graphlit.createFeed({
  name: 'Discord Server',
  type: FeedTypes.Discord,
  discord: {
    type: FeedListingTypes.Past,
    token: discordAuth.token,
    channel: channel.channelName!,
    readLimit: 500,
    includeAttachments: true,
  },
  // Optional: assign workflow for custom processing
  // workflow: { id: workflow.createWorkflow.id }
});

console.log(`Created Discord feed: ${feed.createFeed.id}`);

Configuration

token: Discord bot token (from Developer Portal) channel: Discord channel name (enumerate via queryDiscordChannels) type: FeedListingTypes.Past or FeedListingTypes.New readLimit: Messages per sync window includeAttachments: Enable to capture file uploads


Discord Bot Setup

  1. Discord Developer Portal → Create Application

  2. Bot → Add Bot

  3. Copy bot token

  4. Invite bot to server with Read Messages, Read Message History, and Attach Files permissions

  5. Use helper queries to discover guild and channel names


What Gets Synced

  • Text messages

  • Mentions

  • Embeds

  • Attachments

  • Message reactions (metadata)


Last updated

Was this helpful?