A vote webhook is a pre-defined URL that a POST
request is made to containing information about a user that upvoted a bot (in JSON format) and an Authorization
header. It's fired whenever a user upvotes a bot, it contains some various information about what user upvoted and some extra information like if this vote counted as double because it was the weekend, and if the user who upvoted was a site admin.
You may have issues with this soloution if you get over 500 upvotes per month, intergromat only allows so many operations to take place on a free account. Scroll down for details.
This tutorial is going to focus on discordbotlist for now, but by looking at the docs for other sites, you can find how the webhooks work (though you may need to create a second webhook on your side). This tutorial is going to use integromat to host webhooks. You can use github to make an account. (This tutorial assumes you have no experience with integromat)
Once you are logged into integromat, you will be at a URL like https://www.integromat.com/org/XXXXX
. There should be a blue button in the top right saying Create a new scenario
, click this and you will be taken to a page displaying several icons and a search bar. Search Webhooks
and click the red icon with a triangle shape in the middle, then press continue in the top right. You should now see a mostly blank page with a question mark in the middle.
Click the question mark, you should see a list containing Webhooks
and Add another module
, click Webhooks
and pick Custom Webhook
, that question mark should now be the red webhook icon. Click the webhook icon and you will see a blank URL box, click Add
to the right of that, you will get a pop up, choose anyname for the webhook and leave the IP field blank and click save on the pop up. It will tell you it is now listening for data and provides a stop button and Copy address to clipboard
button. Click the copy button. It should look like this : Reference image. (I've been stupid here and forgot to censor the URL before uploading, i had to delete it from intergromat, you shoud never share your webhook URL, not intergromat nor discord, if this happens you can delete them by going to the home menu and looking for webhooks on the left hand window)
(This assumes you are using discordbotlist.com, the steps will be similar for other sites.) Sign into discordbotlist.com, go to your bot, and press Edit
, scroll down and you will see a webhook section. Paste the URL in the Upvote webhook
box and paste anything in the Webhook secret
box, and press test webhook. Reference image. After a few seconds, integromat should say the data structure was successfuly determined, this means it has worked. (If you don't see that, open up the console on the discordbotlist tab and try again, it should tell you why it isn't) Don't forget to click edit to save it afterwards.
Once a webhook has been delivered, you can perform actions with this data, just put your mouse over the right of the webhook icon so it highlights the little circle and click it, you'll see another question mark. Press add another module and search through to see what you would like to do, if it does not exist, you can use the HTTP
module and use an API for the service.
I haven't found any webhooks which are directly compatiable with discord webhooks, so my original use for this service was to send webhooks to discord, where my bot would pick them up and process them. I'm going to go over the basics of executing a discord webhook using the HTTP
module, since I've been told the discord module sometimes does not work for webhooks.
First you must create a discord webhook, this can be done by going to Server Settings
> Intergrations
, depending on if you have webhooks here already, you may see New Webhook
or View Webhooks
, if you see View Webhooks
, click that and New Webhook
. Now you will be at a screen displaying a default profile picture, a name, and a channel, you can either choose the name and profile picture now, or have them set by integromat when it executes, the channel it posts into can not be changed by integromat. Click Copy webhook URL
.
Click on the right of the webhook icon, and click Add another module
, search and pick HTTP
, then Make a request
. You will now have a blue HTTP icon linked to your webhook, click that icon to open the menu. Paste the discord webhook into the URL field, set the method to POST
, set the body type to Raw
. A Content-Type
field should appear, select JSON( application/json)
in the request body put :
{ "content" : "test" }
You have to click Ok
to save it. Reference image. (You may or may not have that red circle near the HTTP
icon, if you do this probably means you haven't saved it or filled in all the required fields, in that case, just go back over this step adding variables to the request and make sure to save)
Right-click the HTTP module and click Run this module only
. If this was set up correctly, a webhook should fire and send "test" to the channel you chose, this means the webhook is set up correctly.
People have messaged me in the past when they've had some trouble with this and I've noticed that they are on mobile, this step requires you to click inside the textbox and then click the variables, if you are on mobile, it may be best to save this and come back to it later when you have access to a computer.
You can modify the message the webhook sends, you can change the content via changing the content
in the JSON, when you click on this, you should see a window pop up beside it containing some various red buttons, these will differ based on what service you are using (example for this window is shown here). For discordbotlist, these will be id
, username
, discriminator
, avatar
and admin
, you can click these buttons to insert them into it as variables that will be corresponding to the user who upvoted. Here is the basic webhook fields you can use, more here.
field | purpose |
---|---|
content |
The contents of the actual message that gets sent over the webhook |
username |
The username that the webhook appears as |
avatar_url |
The avatar URL used for the webhook, can be an image hosted on discord or any other site (The avatar sent over webhook is not the same as a URL) |
embeds |
It's possible to make the webhook display an embed, see the docs for more info |
To make the webhook use the users username as it's own name use your site logo, use this. (The parts in angle brackets represent variables)
{ "username" : "<1.name>", "content" : "Thanks!", "avatar_url" : "https://your.site/link/to/image.png" }
- If you want to ping users using the webhook, you can use the
id
field, just put "<@" before theid
variable and a ">" after it. - If you want to count the votes from webhooks using the bot, see
counter.py
- The
avatar
field is not the same as an URL, it is a hash and putting it into the URL avatar will not work, instead you can puthttps://cdn.discordapp.com/avatars/<1.id>/<1.avatar>.png
into theavatar_url
field instead, this works following these discord docs.
If this guide helped you please star this.
As stated, integromat only allows so many operations on a free account (1000 per month), if you follow everything in this guide, your scenario will take 2 operations, meaning you can have 500 upvotes per month routed through integromat before this becomes an issue (testing webhooks also counts as operations, provided there was testing in this tutorial, you will be down some upvotes).
Do not wait until your bot upvotes are over 500 per month before looking for another soloution, start looking for other soloutions at around 450. You can either get past these limits by either upgrading your integromat plan or investing in a server.
If you add more stuff to your scenario, your operation toll will be more, thus you will have less upvotes per month avaliable to you, you can see how many operations a scenario takes by going to the intergromat dashboard and clicking the History
tab.
i want to restrict a command to voters only how can i do that please help me