This is a fun little project built for my group of friends and I to pull up each other’s player stats on Discord. All it does is collect data from a target website and parses the values in standard output, in this case channel messages.
The bot has been written in Python and many of the guides found on the internet were quickly out-of-date with the current discord library.
Here are some changes that I came across while building the service.
Updating the Bot’s Presence in the Discord Channel
... client = discord.Client() @client.event async def on_ready(): await client.change_presence(game=discord.Game(name="This is a bot.")) ...
... client = discord.Client() @client.event async def on_ready(): activity = discord.Game(name="This is a bot.") await client.change_presence(status=discord.Status.online, activity=activity) ...
Updating the Bot’s Channel Messages
... @client.event async def on_message(message): if message.content == "Hello": await client.send_message(message.channel, "World") ...
... @client.event async def on_message(message): if message.content == "Hello": await message.channel.send("World") ...
In the end, the bot runs reliability on most low-end hardware since the only thing it does intensively is parse contents from a webpage.
Note: It is assumed that you have OAuth2 already setup on Discord’s developer portal.