Ben the dog is a silly discord bot I made for fun using discord,py. I hadn’t used python in a while, so I wanted to make something with python. The first thing that came to mind was a discord bot, so I checked out
discord.py. Turns out it’s really simple to use.
Defining the bot itself is just a single line:
bot = commands.Bot(command_prefix="?", intents=discord.Intents.all(), case_insensitive=True)
And then to define the events the bot should act on, a decorator is used on one of the possible functions. In my case, I wanted the bot to reply when a message contains the keywords
?, so I used
on_message instead of a regular bot command:
@bot.event async def on_message(message):
The bot is meant to behave like Ben from the mobile app Talking Ben, so what the bot does when triggered is pick one of the four options at random:
from random import choice options = ["Yes", "No", "Hohoho!", "Eugh!"] ben_choice = choice(options)
And for the reply to be prettier, it replies with an embed:
embed=discord.Embed(title=f"Yes", description=f"🐶") embed.set_thumbnail(url="https://example.com/image.png") await message.channel.send(embed=embed)
Here are the 4 possible replies:
This project was nothing more than a silly gimmick, but it had ran for continuously for a few months on my server before I shut it down. It was fun to use and had lead to some funny situations.
Since it wasn’t anything permanent, I ran on on a tmux instance I installed
discord.py on. If I wanted to make something more permanent, I would have made it run on a docker container, just like I did with my discord music bot. But I’ve decided to stop using discord in favor of matrix, so I don’t think I’ll be playing with discord bots again.