Most discord bot listings use webhooks as a method of telling you who upvoted your bot, to recieve these webhooks, you need to have some kind of web server that's able to process them, if you don't have a dedicated web server that you can expose to the internet, you can read how to do this using other services here.
This method of recieving webhooks is generally easier to manage since you are recieving the data directly, however you need to remember that this is a web server and it will require the same security as if you were running any other site / API. The code below by default returns 403 errors if the token provided in the Authorization
header is not correct or if header does not exist, you can use this in a firewall to determine if someone is trying to access it. (This returns a 403 for this event only, and does not stop people brute forcing for pages, or attempting a DoS attack)
There will be some variables for you to modify in the code, you should change the URL, to something long enough that people will not be able to find it through brute forcing pages. Change the token
to your own that you give to the bot listing sites, make sure this token is long enough that it can't be brute forced easily. Change the content["user"]
to content[""]
and then the field you want to extract from the JSON data, look for the API docs on the site for what you are looking for.
There is guides on the internet for how to deploy a flask application to a server, use these guides. I use apache2 with the WGSI module, I also recommend you install a firewall that checks through apache2 logs for excessive 40X errors coming from a host.
- Use prepared statements when dealing with databases, some discord users include quotes in their username.
- Something i learned the hard way, if you are using sqlite3, read this stackoverflow post.
- Use user IDs over usernames, a user ID is attached to one account and one account only, no matter how many times a user changes their name / discriminator, their ID will stay the same, so use this if you are adding records to a database.
3061LRTAGSPKJMORMRT wrote a JavaScript version of the flask app and sent it to me, all credit for the JavaScript app goes to them. The same rules apply in not deploying this app using a development server, see here for why.
If this guide helped you please star this.