
A Discord bot that only SENDS messages is all well and good, but really we want our bots to interact. We need to make them listen and respond. Let’s do that now.
Previously:
Linux Automation Tip: Send Messages to Your Discord Server Using Python
Event Driven Computing
If you have done any visual or object-oriented programming you will be aware of what is called listening for or raising an “event”.
Essentially your program keeps quietly processing until something happens, then it jumps into action.
So with this in mind, we need to tell our bot what to look for and how to respond!
Code
You will need the Discord code library before you can run any of these commands so grab it like so:
python3 -m pip install discord
(Copy and paste the code from this Gist here)

Running the Bot
First, you need to create your bott app, and associate a new bot with it:

Then you need to go to the permissions URL to authorize your bot to do its thing:
https://discordapp.com/oauth2/authorize?&client_id=YOUR_CLIENT_ID&scope=bot&permissions=0

When your script is running and the bot is authorized you should get notified in your server thusly: