Skip to content

Instantly share code, notes, and snippets.

@comhad
comhad / mybot.service
Last active April 3, 2024 16:10
How to setup a systemctl service for running your bot on a linux system
[Unit]
Description=My discord bot service
After=network.target
[Service]
ExecStart=/usr/bin/python3 mybot.py
WorkingDirectory=/home/user/bots/mybot
StandardOutput=inherit
StandardError=inherit
Restart=always
@comhad
comhad / _webhooks.md
Last active June 19, 2021 20:50
Implementing discord bot listing webhooks using a dedicated server exposed to the internet / VPS

Flask app for webhooks

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

@comhad
comhad / _webhooks.md
Last active December 19, 2022 13:05
How to make discord bot listing webhooks without a dedicated server

Vote Webhooks

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