Syncs Discord guilds, channels, members and roles into dedicated Payload collections through a bot token and discord.js. Syncs can be started from the admin panel, a programmatic API, an HTTP endpoint or scheduled Payload jobs. It targets Payload 3 and needs a Discord bot with the Server Members Intent enabled. The plugin is marked experimental and does not listen to live gateway events.
Payload CMS plugin to sync Discord guilds, channels, members, and roles via discord.js
Installation
npm i @lizardglobal/payload-discord-sync0
Stars
0
Forks
1
Open Issues
3 months ago
Last Updated
3
Weekly Downloads
v0.1.7
npm Version
181.2 KB
Unpacked Size
1
Dependencies
Trends appear after 7 days of data. Collecting since Oct 22 — 5 daily snapshots so far.
Trends appear after 7 days of data. Collecting since Oct 22 — 5 daily snapshots so far.
Each point is npm's rolling 7-day download count.
Health Score
Composite score based on GitHub activity, stars, npm downloads, publish recency, dependency count, and package size.
Badge for your README
[](https://payloaddirectory.dev/plugins/1313834549-root)<a href="https://payloaddirectory.dev/plugins/1313834549-root"><img src="https://payloaddirectory.dev/badge/1313834549-root.svg" alt="Payload Directory"></a>README
@lizardglobal/payload-discord-syncPayload CMS plugin that syncs Discord guilds, channels, members, and roles into Payload collections using discord.js.
[!WARNING] This plugin is still experimental. APIs, collection schemas, and behavior may change without a stable compatibility guarantee. Use in production with caution and pin versions deliberately.
Sync is on-demand or scheduled. The plugin does not listen to live Discord gateway events (
guildUpdate,channelUpdate, etc.).
^18.20.2 || >=20.9.0pnpm add @lizardglobal/payload-discord-sync discord.js
# or
npm install @lizardglobal/payload-discord-sync discord.js
import { buildConfig } from 'payload'
import { discordSyncPlugin } from '@lizardglobal/payload-discord-sync'
export default buildConfig({
// ...
plugins: [
discordSyncPlugin({
botToken: process.env.DISCORD_BOT_TOKEN!,
// Optional: omit to sync every guild the bot is in
guildIds: ['123456789012345678'],
linkUsers: {
collection: 'users',
},
schedule: {
enabled: true,
cron: '0 */6 * * *',
seedOnInit: true, // avoid in busy serverless environments
},
}),
],
})
| Option | Type | Description |
|---|---|---|
botToken | string | Discord bot token (required unless disabled) |
disabled | boolean | Keep collections in the schema but skip sync, endpoints, and jobs |
guildIds | string[] | Limit sync to these guilds; empty/omitted = all bot guilds |
resources | object | Enable/disable or customize guilds, channels, members, roles |
linkUsers | object | Link Discord members to your users collection |
schedule | boolean | object | Recurring sync via Payload jobs (cron, queue, seedOnInit, …) |
admin.group | string | Admin sidebar group (default Discord) |
admin.syncAction | boolean | Show Sync Discord on the guilds list (default true) |
intents | number[] | Override discord.js gateway intents |
onSyncComplete | fn | Callback after a successful sync |
onSyncError | fn | Callback when a sync fails |
discordSyncPlugin({
botToken: process.env.DISCORD_BOT_TOKEN!,
resources: {
members: false, // skip this collection
guilds: {
slug: 'servers',
fields: ({ defaultFields }) => [
...defaultFields,
{ name: 'notes', type: 'textarea' },
],
},
},
})
discordSyncPlugin({
botToken: process.env.DISCORD_BOT_TOKEN!,
linkUsers: {
collection: 'users', // your users / auth collection slug
discordIdField: 'discordId', // injected on users (default)
userField: 'user', // relationship on discord-members (default)
autoLink: true, // link on sync when discordId matches
matchByEmail: false, // also match member.email → users.email
injectUserFields: true,
},
})
Automatic: on member sync, if a user already has discordId (or email when matchByEmail is on), the member’s user relationship is set.
Programmatic (typical after Discord OAuth with identify + email):
import { linkDiscordUser, unlinkDiscordUser } from '@lizardglobal/payload-discord-sync'
await linkDiscordUser({
payload,
userId: req.user.id,
discordUserId: discordProfile.id,
email: discordProfile.email,
})
await unlinkDiscordUser({
payload,
userId: req.user.id,
})
Open Discord Guilds and click Sync Discord (queues a job on the discord-sync queue).
import { syncDiscord, queueDiscordSync } from '@lizardglobal/payload-discord-sync'
// Inline
await syncDiscord({
payload,
input: {
guildIds: ['123'], // optional
resources: ['guilds', 'channels'], // optional
},
})
// Via jobs queue
await queueDiscordSync({
payload,
input: { guildIds: ['123'] },
reschedule: true,
})
POST /api/discord-sync (authenticated admin/user session)
{
"guildIds": ["123"],
"resources": ["guilds", "channels", "members", "roles"],
"async": true
}
Omit async or set false to run inline and return the result in the response.
With schedule.enabled, the plugin registers a discordSync task and an autoRun entry on the discord-sync queue. Your app must process Payload jobs (via jobs.autoRun or a worker).
Seed the first job with schedule.seedOnInit: true, the admin button, or queueDiscordSync({ reschedule: true }).
| Resource | Default slug | Key fields |
|---|---|---|
| Guilds | discord-guilds | discordId, name, icon, ownerId, memberCount |
| Channels | discord-channels | discordId, name, type, guild |
| Members | discord-members | discordId (guildId:userId), userDiscordId, username, email, user (if linkUsers), guild |
| Roles | discord-roles | discordId, name, permissions, guild |
Every document also has lastSyncedAt and a raw JSON snapshot from Discord.
See CONTRIBUTING.md for local setup, PR guidelines, and how releases work.
MIT
Topics
payload dub
Create and sync Dub shortlinks, tags and analytics for published Payload documents
77186/wk4v4
payload auditor
Hook-based audit logging for Payload collections and globals with buffered writes and automatic log cleanup
66735/wk79v3
payload plugin scheduling
Schedule future publication of draft documents in collections and globals via an isolated job queue and cron endpoint
66135/wk30v3
plugin action scheduler
Schedule one-off, recurring and cron actions with retries and an admin dashboard, run by Payload's job queue.
664/wk2v3
payload plugin deskcrew
Turn new documents in chosen collections into DeskCrew support tickets
643/wk0v2
payload plugin socials
Compose, schedule and publish posts to Pinterest, Instagram, Facebook Pages and Google Business Profile from Payload
63175/wk3v3