Connect Discord
Tasks call Discord through qbash.integrations.discord with a bot token you store on the Connectors page. The connector reads servers, channels, messages, members, threads and scheduled events. It posts messages, adds reactions, starts threads, creates and updates scheduled events, and posts through an incoming webhook. It edits and deletes only messages the bot posted.
Moderation and administration are left out: no kick, ban or role changes, no Administrator or Manage Server actions, and no OAuth sign-in. The full Discord developer documentation covers the rest.
After you connect Discord, you can add its tools to a qbash MCP server for ChatGPT, Claude and other MCP clients, or call it from a Python task.
Get a Discord account and a server
Discord API access is free, with no paid plan or card. Sign up at discord.com if you do not have an account. Discord lets you create a test server for free, which is a good place to try the connector first.
Create the bot
- Open the Discord Developer Portal and click New Application. Name it and accept the terms.
- Open the Bot page. Click Reset Token and copy the token right away. Discord shows it once. If you lose it, reset it again, which makes the old one stop working.
- Open Installation. Under Installation Contexts keep Guild Install. Under Default Install Settings, add the
botscope to Guild Install and choose the permissions below. - Copy the Install Link from the same page, open it, pick your server and authorize. The person who authorizes needs the Manage Server permission in that server. You do this once per server.
Permissions to grant
| Permission | Needed for |
|---|---|
| View Channels | Every channel method |
| Send Messages | create_message in a channel |
| Send Messages in Threads | create_message in a thread. Send Messages has no effect there |
| Read Message History | list_channel_messages, get_message, add_reaction, archived threads |
| Embed Links | Messages and webhook posts with embeds |
| Manage Events (optional) | update_guild_scheduled_event, and creating or updating events the bot did not create |
| Create Events (optional) | create_guild_scheduled_event |
| Connect (optional) | Voice events. Stage events also need Manage Channels, Mute Members and Move Members |
| Create Public Threads (optional) | create_thread |
| Add Reactions (optional) | add_reaction on a message nobody has reacted to with that emoji yet |
Do not grant Administrator or Manage Server to the bot. The connector never needs them.
Intents
Leave privileged intents off under Privileged Gateway Intents on the Bot page unless you need one of the two features below. The connector works without them, with two limits:
- With the Message Content Intent off,
list_channel_messagesandget_messagereturn emptycontentfor messages from other people. Messages that mention the bot, direct messages to it and its own messages still carry their text. - With the Server Members Intent off,
list_guild_membersfails with a 403. To list members, turn on Server Members Intent in the Developer Portal under Bot, then Privileged Gateway Intents. No other method needs it.
Every other method works with all intents off. Turn on the Message Content Intent only if Tasks must read what other people wrote.
Add the token in qbash
- Open Connectors, then Discord, and click Connect.
- Fill in Credential Name, such as "Community bot", and paste the token into Bot Token.
- Optionally list Channel IDs, separated by commas or spaces. When set, every channel method refuses a channel outside the list. Webhook posts and external scheduled events are not checked against it, because a webhook goes to the channel its URL belongs to and an external event has no channel. To copy an ID, turn on Developer Mode in Discord under Settings, Advanced, then right-click a channel and choose Copy Channel ID.
- Save. qbash checks the token format only and does not call Discord on save. The first call from a task shows whether Discord accepts the token.
- In the task editor, choose Add connector from the Package + menu and select the credential. See Task resources.
Post to a channel from a task
servers = qbash.integrations.discord.list_guilds()
guild_id = servers["guilds"][0]["id"]
channels = qbash.integrations.discord.list_channels(guild_id=guild_id)
general = next(c for c in channels["channels"] if c["name"] == "general")
qbash.integrations.discord.create_message(channel_id=general["id"], content="The nightly report is ready.")
List methods return has_more and next_cursor where Discord pages the list. Pass next_cursor back as cursor until has_more is False. The SDK Reference lists every method and its parameters.
Methods
| Method | Resource | Access |
|---|---|---|
get_bot_user | Bot user | Read |
list_guilds | Servers | Read |
get_guild | Servers | Read |
list_guild_members | Members | Read |
list_channels | Channels | Read |
get_channel | Channels | Read |
list_channel_messages | Messages | Read |
get_message | Messages | Read |
create_message | Messages | Write |
edit_own_message | Messages | Write |
delete_own_message | Messages | Write |
add_reaction | Messages | Write |
list_threads | Threads | Read |
create_thread | Threads | Write |
list_guild_scheduled_events | Scheduled events | Read |
create_guild_scheduled_event | Scheduled events | Write |
update_guild_scheduled_event | Scheduled events | Write |
post_webhook_message | Webhooks | Write |
edit_own_message and delete_own_message read the message first and refuse one written by anyone else. create_message, edit_own_message and post_webhook_message show mentions as text, so @everyone, roles and users are not notified. post_webhook_message needs no bot. Copy the webhook URL from a channel's Integrations settings and paste it into the credential's Webhook URL field, so it stays encrypted and out of Task code and execution logs. The call takes no URL, so the secret never appears in tool arguments or logs. Treat the URL as a secret, because it lets anyone post to the channel. edit_own_message takes embeds=[] to remove a message's embeds.
Limits and details
- Discord limits each bot to 50 requests per second, and each route has its own limit. A 429 reaches your task with the wait Discord asks for.
- Discord may limit or revoke tokens that go unused for 30 days. If calls start failing with a 401 after a long gap, reset the token and update the credential.
- Message pages hold up to 100 messages, member pages up to 1000 and server pages up to 200. Messages come newest first.
- Scheduled events are visible to server members only. An external event needs
locationandscheduled_end_time, and voice and stage events needchannel_id. A server can hold 100 scheduled or active events. create_threadstarts public threads only, from a message or on its own. Announcement channels needmessage_id, because Discord does not allow standalone threads there. If you set Channel IDs, a new thread is its own channel, so add its ID before posting in it.post_webhook_messageis not limited by that list.- The optional permissions Create Public Threads and Add Reactions go beyond the minimal set. Grant them only if you use those methods.
- A 401 marks the credential as needing a new token, unless the credential also holds a Webhook URL. Then the credential stays usable so webhook posts keep working, and you reset the token yourself. A 403 does not: it means the bot lacks a permission in that channel or is not installed in the server, and the message includes Discord's error code.
- Error messages never contain the token.