Discord Bot for The Division 2

Reading time ~1 minute

*Usage of any "The Division" name, logos and/or images are registered trademarks of Ubisoft.

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

Old:

...
client = discord.Client()

@client.event
async def on_ready():
    await client.change_presence(game=discord.Game(name="This is a bot."))
...

New:

...
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

Old:

...
@client.event
async def on_message(message):
    if message.content == "Hello":
        await client.send_message(message.channel, "World")
...

New:

...
@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.

Download Project (.zip)

The Nostalgic MacOS Startup Chime

Sample post with a background image CSS override. Continue reading

Happy Hacking Keyboard (HHKB) - An Overview

Published on February 08, 2020

Less is More

Published on January 03, 2020