

Now, where it says n('YOUR_TOKEN') you will need to copy and paste your discord bot's token. Next, open up your code editor, and make a new file called main.pyĬlient = commands.Bot(command_prefix= async def ping( ctx): await ctx.send( "Pong!") Leave this tab open, we will need it later. Don't worry, you can change this later.Ĭlick 'Bot', click 'Add bot' and finally, press 'Yes, do it!' Click 'New Application' in the top right of the page, and give it name. Next, you will need to create an application. Obviously, you won't have all those applications created. In this post I will tell you how to setup a discord bot, and also create a command.ĭiscord Account, Computer Creating your botįirst off, open your web browser, and head to the Discord Development Portal, and you should be greeted with this screen: It implements the entire Discord API.īasically, in dummy terms, Discord.py is a version of Python which you can use to code a discord bot. CSV is a modern, easy to use, feature-rich, and async ready API wrapper for Discord. Then we append the message’s content, time of creation, and author - which can all be accessed via the message’s attributes - to the data frame and use Pandas’ to_csv() method to save it locally as a. Once inside the loop, we can use if statements to avoid messages sent by our bot - in this case, it won’t send any messages - and the command calls we used to trigger it. The method allows us to use a for loop to iterate through n messages in the channel history, with n being a parameter of the method itself set, by default, to 100. To read the data into the data frame, we will make use of the history() method of the TextChannel class in the discord.py library, which we get access to by using the channel attribute of our message. And, to do that, we create a Data Frame containing one column for each. But, to keep it simple, we’ll only be looking at when the messages were sent, who sent them, and the content of the message itself. There are many variables we could want to track from a server’s message history.
