![]() ![]() All we have to do is write our program to respond to message events (named bot.py here) and connect it to the Discord backend by using their API.ĪPI (Application Programming Interface) is just a fancy terminology to define how one program talks to another program. Then, the Discord backend servers will broadcast an event to any program listening that a new message has been posted. Each user interacts with the Discord backend to write and read messages. ![]() Today, we're focused on getting our bot to read and write messages, so let's see how that works.įrom the crude drawing above (I'm an engineer, not an artist), we can see how users and bots connect to the Discord backend. A Discord server with "Manager Server" permissions.įirst, let's zoom out a bit and think about this question: "What does it mean to code a Discord Bot?" Simply put, a bot is nothing more than a computer program that performs some useful actions.īecause Discord wants bots to be able to do useful things, they have allowed developers to access parts of its system in their code, such as automatically responding to messages or helping with the server's admin functions (e.g.The Discord bot that we are going to build will listen for the keyword $meme and responds with a random meme from Reddit.īefore we get started, you will need a few things if you don't have them already: We'll also provide a breakdown of each line of code for those who want to get a deeper understanding of how it all works. In this tutorial, we'll learn how to set up your Python programming environment, create and register a bot using Discord Developer Portal, and write a few lines of Python code to respond to users' messages in Discord. ![]()
0 Comments
Leave a Reply. |