Creating custom Discord selfbots when Discord's webhooks aren't enough.
My Inspiration
Like most of the small projects I get ideas for, this one came to me when I was bored and wanted to know if I could send a friend a message on Discord or Slack using a simple device like a Raspberry Pi.
My friends often have tech troubles and since we usually communicate over Discord or Slack. I figured it would make my life a little bit easier if I can just have them run a script and it will automatically send the results back to me through our DMs to help troubleshoot their issues.
Webhooks
This is generally the go to option if you are okay with performing smaller requests and tasks. Webhooks are quite easy to set up, but hamper the amount of control you have over your bot. Methods that use the API are favored and abide by the TOS, so if you like to live safely then this is the option for you.
See the Userbots section for more info on Discords TOS.
For instructions on creating Webhooks you can find the docs below:
This method is if you want more power over what your bot can do, for example with Slack you are unable to directly mention someone when using Webhooks. However a word of warning, you can be banned for using userbots as it is explicitly against the TOS (at least for Discord).
For Discord it is likely safer to strictly use the requests module, as Discord says you will be banned for logging in with your user account (through their module/api).
Navigate to the Application Tab -> Storage -> Local Storage -> Discord.com
In the filter bar type: "token" without quotes
Press Ctrl+R (refresh Discord for the token to appear)
Finally highlight to copy and retrieve your token.
Install dependencies
pip3 install requests, unidecode
Here we define a few functions allowing our bot to wait for a command in your chat channel of choice and respond with a custom message, that can optionally include their username (unicode formatted).
Prebuilt request functions
If you prefer to use a repo that already has prebuilt functions the Zenon repo on GitHub has a decent amount of predefined function to get you started.