Skip to content

parsdextra/discord-template

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

discord-template

CLI tool to export a Discord server's structure to a JSON template and import it into a blank server.

What gets exported

  • Server settings (name, icon, verification level, notification defaults, content filter, AFK channel/timeout, system channel)
  • Roles (name, permissions, color, hoist, mentionable, position)
  • Categories with permission overwrites
  • Text, voice, news, forum, and stage channels with permission overwrites
  • Channel properties (topic, NSFW, slowmode, bitrate, user limit)

Permission overwrites are stored by role name so templates are portable across servers.

Setup

Install

pip install .

After installing, the discord-template command is available. You can also run it as a module:

python -m discord_template --help

Authentication

There are two ways to authenticate for export (choose one):

Option A: User token (no bot needed)

Export uses read-only REST calls, so your own Discord user token works without creating a bot. To get your token:

  1. Open Discord in a browser and press F12 to open DevTools
  2. Go to the Network tab, then send any message or switch channels
  3. Click a request to discord.com, find the Authorization header in the request headers
  4. Copy that value
export DISCORD_USER_TOKEN="your-user-token-here"

Option B: Bot token

  1. Go to https://discord.com/developers/applications and create a new application
  2. Go to the Bot tab and click Reset Token to get your bot token
  3. Under Privileged Gateway Intents, enable Server Members Intent
  4. Go to OAuth2 > URL Generator, select the bot scope, and grant Administrator permission
  5. Use the generated URL to invite the bot to both your source and target servers
export DISCORD_BOT_TOKEN="your-bot-token-here"

A bot token is required for the import command since it makes write operations.

Usage

Export a server (user token, no bot)

discord-template export --user-token "$DISCORD_USER_TOKEN" --guild-id 123456789 -o my-server.json

Export a server (bot token)

discord-template export --token "$DISCORD_BOT_TOKEN" --guild-id 123456789 -o my-server.json

Fetch from a discord.new template link (no token needed)

If someone has shared a discord.new template link, you can convert it directly with no authentication:

discord-template fetch "https://discord.new/aBcDeFgH" -o my-server.json

You can also pass just the bare code:

discord-template fetch aBcDeFgH -o my-server.json

Native Discord templates include roles and channel structure but may lack some details (topics, NSFW flags, per-channel overwrites) compared to a full export.

Inspect a template

discord-template inspect -t my-server.json

Import into a blank server

discord-template import --guild-id 987654321 -t my-server.json

The import command runs safety checks to ensure the target server is blank:

  • At most 1 text channel (the auto-created default)
  • No voice channels or categories
  • No custom roles (only @everyone)
  • No custom emoji or stickers
  • Bot has Administrator permission

Use --dry-run to preview what would be created without making changes:

discord-template import --guild-id 987654321 -t my-server.json --dry-run

Use --force to bypass safety checks (you will still be prompted to confirm):

discord-template import --guild-id 987654321 -t my-server.json --force

Use --keep-defaults to preserve the server's original default channels instead of deleting them after import:

discord-template import --guild-id 987654321 -t my-server.json --keep-defaults

How to find a guild ID

  1. Enable Developer Mode in Discord: User Settings > App Settings > Advanced > Developer Mode
  2. Right-click the server name and select Copy Server ID

Idempotent imports

Running import twice on the same server will not create duplicates. Existing roles are matched by name and updated in place, and existing channels are matched by name, type, and parent category. Only new entries are created. The --dry-run output shows [create] or [update] next to each item so you can see what will happen.

Limitations

  • Messages, members, bans, webhooks, and integrations are not copied
  • Custom emoji and stickers are not copied
  • The bot can only reorder roles below its own highest role

About

CLI tool to export a Discord server's structure to a JSON template and import it into a blank server.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages