Discord Bot

Categories: Tech | Pubby Cash Received:  0 | Click to Award

Discord is an American proprietary freeware instant messaging and VoIP application and digital distribution platform designed for creating communities ranging from gamers to education and businesses. Discord specializes in text, image, video and audio communication between users in a chat channel. Discord lets you set up a chat room it refers to as a server, to which you can invite people. When you invite someone to the server, they get a link that lets them join it, where they can either text or voice chat with other people using that server. One of the most unique features of Discord is the ability to implement bots in the server, making it more fun for the group and easier for moderation.

These bots are AIs that can perform a number of useful automated tasks on your server, such as welcoming new members, deleting inappropriate messages, and banning misbehaving members. You can program them to add games, videos, music, and other content to your server. Discord bots totally bring more life to the server and holds the group together as a whole. Of course there are already numerous bots out there already, but it's always best to create one ourselves.

We will be using Python to build a basic Discord bot. Install the appropriate packages on your machine first. Then create an app on the Discord Developers website. Inside your app, create a bot and add that to your server. (That's the bot you will control using the Python code.) So far, you've created a bot, but it doesn't know anything yet. You can find many tutorials for a simple communication bot. Here is an example:

import discord
client = discord.Client()
async def on_message(message):
    if message.content.find("!hello") != -1:
        await message.channel.send("Hi") # If the user says !hello we will send back hi

Now that it's working great, it is time to deploy the bot. There are many options out there. You could deploy it yourself (by just running it on your computer). I like to use Heroku. Start by creating a new app on Heroku. Change the buildpack to Python in the settings panel. Now you have to make a 'requirements.txt' file with all the necessary packages for Heroku to install along with a 'Procfile', which includes the instructions to run the bot. Make sure that both of these files are in the same directory as the bot script. Now you have to upload everything to GitHub. Finally, in the Heroku app, choose run from GitHub in the Deploy tab and you're good to go!

Published from: Pennsylvania US
Liked by: H2O, Hauber 

Daily Deals