Get All Users With a Role
Last updated
Last updated
In this guide, you will learn how to setup an API Request inside of BotGhost and get all of the users who have a specific role inside of your own personal Discord server from your bot!
First off, you need the "Send an API Request" from either your command or event builder.
Once you have added the API Request block into your command or event builder, find the labeled section called Name, here you should insert the plain text of roles
. This will allow you to reference the API Request in further actions.
After you have set the name of your request, click the "Request Builder" button. This will open up the builder of your request to our API, here you will need to add all of the required information.
Paste: https://api.erensko.xyz/v1/role-members
to the URL at the top of the builder.
Once you have added the URL into your request's builder, find to the "URL Params" section and press the "Add" button so you have 2 sets of keys & values.
Once you're here, setup the keys and values for your URL Params, this is necessary.
role-id
The discord role ID to get the members of.
server-id
The discord server ID of where the role is.
After you have added your URL Params, it's time to finish the request by adding your HTTP Headers. Click on the "HTTP Headers" button and use the following set in the table. Your bot's token is required. To get your bot's token, you will need to reset it from the Discord Developer Portal. You also must have your own API key from us in order for you to send the request.
Authorization
Your own personal API key, create one by clicking here.
bot-token
The plain token of your Discord bot
In order to display all the members who have the role, you can use the following BotGhost variables.