Making a Discord bot in Python

2021-07-12
2 min read

Using discord.py to make a bot to validate PayPal purchases.

I have written a few popular Minecraft server mods for which I run a discord community server to support and interact with everyone who has downloaded them. Some of the mods are “premium” and cost money and I wanted an automated way to allow users to verify their purchase and be granted a higher level of access in the server. This ended up as a weekend project exploring the very interesting world of chat room bots. After combing through some documentation on what it would require, I settled on Python for the language and wrote a bot that verifys a PayPal purchase from a user submitted email.

Using the new discord slash commands, it allows a user to enter their email as a parameter to the command (while presenting a nice UI for their options) and searches the last three years of PayPal transaction history for a matching email. If the configured resource id (the unique ID of the Minecraft mod) matches the ID found in that PayPal transaction, it sends a successful response back to the Discord user and assigns them the higher role in the discord server.


I have seen many other similar servers resort to using a manual approval process involving moderators validating screenshots from users that they purchased the resource. This caused multiple day queues for end users and a lot of unnessary work for server administrators. I open sourced this bot so now anyone else can utilize this resource to help automate the verification process on their own server too! It also gave me a chance to finally setup the headless raspberry pi I’ve had laying around so now I have a discord bot running out of my closet.

I always like learning something new and this was a fun little weekend project that will hopefully benefit some other server owners looking to automate a verification flow.

Avatar
Tanner Embry Software Engineer · Sales Engineer · Artist
Previous Murals