The Creation of a Discord Bot
Discord is a pretty popular piece of software nowadays. It's an easy to use VOIP solution for gamers. Hell it's even crossing over into some other areas too! Bots are at an all time high and can range from monitoring and helping with administration of servers to mini games.
Discord has some big headway they have made this year. They just got integrated with Xbox allowing people playing on their Xbox to have their status updated inside of Discord. It's safe to say Discord is going to be here for a while.
If you're just starting into Python it might be a bit too hard for you. However, if you work at it you'll be able to get it down in no time. It was one of my first projects that I worked on and It's currently running inside of Google's Cloud! Don't forget if you need help their Discord is super helpful. Don't forget to check them out.
So for the base I used discord.py you can find their Github here. They are currently updating it. If you are going to make this a long term project and want to keep it up to date and are alright with bugs hop into their discord and read about the rewrite. Stuff breaks you'll need to fix it. Syntax changes and the next version might break everything you did. Test and help them out!
So I need to find a niche that I could build my bot for. At the time my friends and I were heavily into Fortnite. It's a pretty popular game, and we always wanted ti compare stats. There are websites out there that will show a players stats etc, but going out to the website was such a pain. I wanted to show my score off right in discord. With a simple !Fortnite Snoozey command my bot would reach out to the website and use their API and pull in the information for my account. Then post it in whichever channel I wanted.
So lets start off by a link to my Github profile for this project.. You're going to need a Discord API Key, a Fortnite Tracker Key , and some sanity. The code is far from optimized. It was my first ever attempt at making a bot let alone a discord bot. Don't just plop in the code. Work on it yourself and use mine as a guide.
So lets start off with the code below. It's simple and easy
#Enter Channel Name you want
channelName = 123
So 123 is just something to have there. You should enable developer mode inside of discord and then find the channel ID you want to use for your bot. For this example it doesn't matter too much as you can also make the bot respond to whatever channel you want it to. Just for practice try and make that part work.
For this portion you will need your Fortnite Tracker API Key. Just enter in your key and off to the races!
# Enter your fortnite key below
fortniteTrackerAPI = "key here"
Now for way down at the bottom here
#Enter your discord code below.
bot.run('discordcode')
Simply put in your Discord API key. You can find plenty of tutorials on the interhighway for that portion.
So essentially what you'll do with this code is reach out to Fortnite tracker. Give them your API key in the headers of your request. They will then send you the information you requested back. You need to strip out the garbage you don't want an format it correctly.
I highly recommend that you build your own and don't use my code. Just use it as an example. It should give you a nice starting basis to work on.
If you have any questions reach out to me on twitter or just ask in the comments below!