BotWiz Guides
  • BotWiz Guides
  • BotWiz Guides
    • Slash Commands
      • Warn Command
      • Ticket System
    • Migrate
      • Import
      • Export
    • Co-Create
      • Managing Co-Creators
      • Accepting an Invite
    • Apm Guides
      • Apm Ticket System
        • Ticket Limits
      • Massing Bot
    • Auto Responder
    • Server Statistics
      • Member Count
    • Using API's
      • What is an API?
      • Discord API
  • Discord Guides
    • Server Roles
      • Server Roles: PC Guide
      • Server Roles: Mobile Guide
    • Categories & Channels
      • Channels: PC Guide
      • Channels: Mobile Guide
    • Server Ownership
      • Server Ownership: PC Guide
      • Server Ownership: Mobile Guide
    • Delete Server
      • Server Deletion: PC Guide
      • Server Deletion: Mobile Guide
Powered by GitBook
On this page
  • Finding Endpoints
  • Examples

Was this helpful?

  1. BotWiz Guides
  2. Using API's

Discord API

This guide will walk you through connecting and customizing your Discord bots with API calls.

PreviousWhat is an API?NextServer Roles

Last updated 9 months ago

Was this helpful?

All the endpoints used in the guide are available at the .

If you are new to BotWiz, and have not yet added your bot: to learn how! If you have any questions throughout or get stuck, feel free to visit our .

Finding Endpoints

Head to the and have a look around the page and get comfortable with it. The search bar on the left hand side is your best friend! (Ctrl + k)

Examples

Get Channel Messages

To get channel messages from a channel in your discord server, we need to use the following endpoint: GET https://discord.com/api/v10/channels/CHANNEL-ID/messages

You will need to replace CHANNEL-ID with your guild channel ID.

API Name

For this guide our name for the API block will be get_msg.

The variable list at the bottom of the API setup page should now display the following:

  • {api_get_msg[response]}

  • {api_get_msg[status-code]}

  • {api_get_msg[status-text]}

HTTP Header

We now need to authorise our discord bot for discord to let us send a request to the endpoint.

You don't need to replace {bot_token}with your actual bot token, as this variable will grab it automatically.

Test request

If you have completed all the steps above, head to the Test Request tab, and press "Test". You should now see the latest 100 messages in your channel.

You will also notice that is displays 0 - 99 responses, this is because the response is an Array and array indexes start at 0.

The test request will display an Invalid Form Body error if you have any variables in your URL, as the test request only accepts RAW input from all fields in the API request.

Getting the latest message

To get the latest message that was sent in the channel you have chosen, head to your URL Parameters and add the following:

Head back to your test request and click on "Test" again, you will now see only 1 response (the 0 index response).

Displaying the latest message

To display the latest message that was sent in that channel, create a new message component. For this guide we will be using an embed component.

In our Embed Description we will add the variable {api_get_msg[response.0.content]}. This will display the latest message that was sent in the channel.

Displaying the ID of the message

To display the ID of the latest message, add the variable {api_get_msg[response.0.id]} into your embed / message description.

Create a Message

To get channel messages from a channel in your discord server, we need to use the following endpoint: POST https://discord.com/api/v10/channels/CHANNEL-ID/messages

You will need to replace CHANNEL-ID with your guild channel ID.

API Name

For this guide our name for the API block will be post_msg.

The variable list at the bottom of the API setup page should now display the following:

  • {api_post_msg[response]}

  • {api_post_msg[status-code]}

  • {api_post_msg[status-text]}

HTTP Header

We now need to authorise our discord bot for discord to let us send a request to the endpoint.

You don't need to replace {bot_token}with your actual bot token as this variable will grab it automatically.

Request Body

The request body allows us to add JSON data to send to the request, enabling us to specify the details of the action we want to perform. In the context of the Discord API the request body can be used to define various parameters such as the content of a message.

To be able to create a plain text message, all we need to add into the request body is the content, see the table below.

Test Request

If you have completed all the steps above, head to the Test Request tab, and press "Test". You should know see a Message Object, and if you check your discord channel, you should see a message has been sent!

Request body (Embed)

To send embed messages via Discord API it's slightly different than a plain text message. The key is changed to embeds and the value becomes an array of embed objects. That simply just means the embeds parameter can process multiple values, instead of just 1.

If you've created any embed webhook with JSON data, it's exactly the same as that.

To send an embed message that has a description of "My first API embed message" with a footer of "Sent with Botwiz.dev" follow the structure below:

"color" has to be a decimal number, it does not accept hexadecimal values (#fffff, #222). You can use a "Hexadecimal to decimal" converter to convert the hex value to decimal.

All the info about this API endpoint can be found here: 🔗

All the info about this API endpoint can be found here: 🔗

To get JSON data for an embed you want to create, you can build the embed through our free tool and retrieve the JSON data by pressing View JSON.

https://discord.com/developers/docs/resources/channel#get-channel-messages
https://discord.com/developers/docs/resources/channel#create-message
embed builder
Discord Developer Documentation
click here
Support Server
Discord Developers Documentation
Image shows a highlighted box around the search bar.