Templates · Messaging
Discord API collection template
Send and read channel messages and list servers with a Discord bot.
What's inside
Discord bot basics: check the bot, list the servers it is in, read a channel and send a message.
5 requests in 2 folders · Base URL https://discord.com/api/v10 · API key in the Authorization header
Set it up
- Open Discord API in Requestarium (or in the app: Import, Start from a template) and import it. You get the collection and a "Discord API" environment.
- Create an application at discord.com/developers/applications, add a bot, copy its token and invite it to your server with the Send Messages and Read Message History permissions.
- Fill in the environment, pick it in the environment menu and send the first request.
Environment variables
| Variable | What it is |
|---|---|
discordBotTokensecret | Bot token. |
channelId | Channel id (Developer Mode, right-click the channel, Copy Channel ID). |
Requests
Bot
- GETGet the bot user
/users/@meThe bot account; a quick way to check the token.
- GETList servers
/users/@me/guildsServers the bot is in.
Messages
- GETGet a channel
/channels/{{channelId}}Channel name, type and topic.
- GETRead messages
/channels/{{channelId}}/messagesThe latest messages.
- POSTSend a message
/channels/{{channelId}}/messagesPosts as the bot.