Creating and adding a bot to Discord

Bot deletion confirmation

Corporate messenger Discord is very popular all over the world. But in its pure form, its capabilities are significantly limited. The demand for the program is based on the possibility of using bots – add-ons that extend the functionality of the application. The number of chats for Discord is in the thousands, and their focus is very diverse. There are bots that specialize in playing music, and there are those that allow you to use the radio. Extensions for posting photos and pictures are popular, and many bots offer mini-games. There are also those that are installed directly on the chat functions, allowing you to moderate it. In a word, the possibilities for expanding the capabilities of the messenger are enormous. Today we will try to figure out how to add a bot to Discord, how to configure it, remove it, and even create your own version.

Discord bots

Contents

How to add a finished bot to Discord

If you have programming skills, creating your own bot can be quite fun. But since most users are very far from programming, this path is not for them. Moreover, it hardly makes sense to create what is already available in finished form, and in excess.

The main condition for adding a bot to the Discord server is to find a site with a good collection of bots. There are many of them today, as an example, a fairly popular resource can be cited – https://top.gg/

The installation procedure itself is not very complicated:

  • go to the specified site;
  • if we are looking for a specific bot, enter its name in the search console;
    Finding a Discord Bot
  • you can follow the second path using the navigation menu, in which all bots are divided into categories: the most popular, music trends, recently added, sorted by tags;
    Choosing a Discord bot
  • if the choice has already been made, you can go directly to the installation. To do this, right on the site, click on the “Invite” button;
  • but you can go to the bot page – there will be more information about its capabilities and functionality, and click on the same button there;
    Discord Invite button
  • to install the bot on Discord, in the configuration window that opens, you need to select the server on which the chat is installed, and set the rights that you delegate to it when it is installed on the server and starts working;
    Selecting a server to add a bot
  • after entering and setting the basic settings of the bot you like, you can proceed to the final stage – click the “Authorize” button;
    Discord bot authorization
  • after that, it remains to pass the standard check for a robot. Don’t smile, what if the bot intends to use another bot? In the latter case, it smells like a war of cars.
    User verification on Discord

As you can see, connecting a bot is a simple matter. No more difficult than installing software. Finally, we note that the most popular category today is considered to be add-ons that allow you to play music. We recommend installing the Rhythm music bot, which has a well-deserved reputation in the Discord community as one of the best. Among the advantages of the chat add-on is the streaming of audio tracks, and from different sources. Soundcloud, Twitch services are supported, you can listen to music directly from YouTube.

Downloading the Rhythm bot

The feature of the Rhythm bot is the unique ability to extract individual tracks from playlists and automatically generate a new list as soon as the old one is empty. Songs are added in different ways. For example, by providing a direct link to the reproduction source. Or you can use the search, and then you will need to select the desired song from the list, made up of the most fully correlated with your request.

Using the Rhythm bot

The list of commands for working with the bot is small, and their syntax is simple, so you are unlikely to experience difficulties when using these directives even at the initial stage of bot operation.

Rhythm bot playlist

Another “feature” of Rhythm is the ability to show the user the lyrics of the currently playing song, which will be appreciated by fans of singing along. If you wish, you can try to find the lyrics of any song, as long as you know the full correct title and artist.

Lyrics of Song in Rhythm

Finally, we note that the bot offers server administrators an extensive list of settings that optimize its work. All of them are available on the modular panel. You can find a list of the main commands for controlling the application on the official Rhythm website.

Rhythm bot options

ADVICE. The bot was designed to work primarily in voice channels. If you need to have an extension with the same functionality for a text feed, you need to look for another bot.

How to set up and use a bot on Discord

Installing the bot, described in the previous section, is already a sufficient procedure to start using it right there, immediately. That is, you do not need to turn it on or activate it in some way. However, knowledge of the commands required to take full advantage of the extensibility is essential. You will also need to perform the initial settings.

As for the configuration, after installing it on the Discord server, a correctly written bot should send a message, which will contain detailed instructions on how to configure the settings and how to control the bot using commands. More often than not, the message simply provides the syntax of the command, by entering which you will receive a list of all other available commands.

The instructions are also duplicated on the discordbots.org website if you installed the bot from there.

ATTENTION. The overwhelming majority of bots have an English-language interface, bots in Russian are still a rare phenomenon. So you should improve your English, believe me, it will come in handy in other life situations as well. As a last resort, you will have to use a translator.

How to make your own music bot on Discord

The Discord chat API has a fairly advanced tool that allows you to create bots. Of course, you need to be a programmer for this. But if you wish, you can find ready-made and even documented bots on the network that can be used depending on the conditions provided by the developer.

Having chosen this path, we still need to know how to install it on the server so that it can be used.

Let’s consider an example of a music bot, written in js and having basic capabilities (playing with support for a queue, play, stop, skip tracks).

Here is the text of the finished script:

const Discord = require (‘discord.js’);
const {
prefix,
token,
} = require (‘./ config.json’);
const ytdl = require (‘ytdl-core’);
const client = new Discord.Client ();
const queue = new Map ();
client.once (‘ready’, () => {
console.log (‘Ready!’);
});
client.once (‘reconnecting’, () => {
console.log (‘Reconnecting!’);
});
client.once (‘disconnect’, () => {
console.log (‘Disconnect!’);
});
client.on (‘message’, async message => {
if (message.author.bot) return;
if (! message.content.startsWith (prefix)) return;
const serverQueue = queue.get (message.guild.id) ;
if (message.content.startsWith (`$ {prefix} play`)) {
execute (message, serverQueue);
return;
} else if (message.content.startsWith (`$ {prefix} skip`)) {
skip (message, serverQueue);
return;
} else if (message.content.startsWith (`$ {prefix} stop`)) {
stop (message, serverQueue);
return;
} else {
message.channel.send (‘You need to enter a valid command!’)
}
});
async function execute (message, serverQueue) {
const args = message.content.split (”);
const voiceChannel = message.member.voiceChannel;
if (! voiceChannel) return message.channel.send (‘You need to be in a voice channel to play music!’);
const permissions = voiceChannel.permissionsFor (message.client.user);
if (! permissions.has (‘CONNECT’) ||! permissions.has (‘SPEAK’)) {
return message.channel.send (‘I need the permissions to join and speak in your voice channel!’);
}
const songInfo = await ytdl.getInfo (args [1]);
const song = {
title: songInfo.title,
url: songInfo.video_url,
};
if (! serverQueue) {
const queueContruct = {
textChannel: message.channel,
voiceChannel: voiceChannel,
connection: null,
songs: [],
volume: 5,
playing: true,
};
queue.set (message.guild.id, queueContruct);
queueContruct.songs.push (song);
try {
var connection = await voiceChannel.join ();
queueContruct.connection = connection;
play (message.guild, queueContruct.songs [0]);
} catch (err) {
console.log (err);
queue.delete (message.guild.id);
return message.channel.send (err);
}
} else {
serverQueue.songs.push (song);
console.log (serverQueue.songs);
return message.channel.send (`$ {song.title} has been added to the queue!`);
}
}
function skip (message, serverQueue) {
if (! message.member.voiceChannel) return message.channel.send (‘You have to be in a voice channel to stop the music!’);
if (! serverQueue) return message.channel.send (‘There is no song that I could skip!’);
serverQueue.connection.dispatcher.end ();
}
function stop (message, serverQueue) {
if (! message.member.voiceChannel) return message.channel.send (‘You have to be in a voice channel to stop the music!’);
serverQueue.songs = [];
serverQueue.connection.dispatcher.end ();
}
function play (guild, song) {
const serverQueue = queue.get (guild.id);
if (! song) {
serverQueue.voiceChannel.leave ();
queue.delete (guild.id);
return;
}
const dispatcher = serverQueue.connection.playStream (ytdl (song.url))
.on (‘end’, () => {
console.log (‘Music ended!’);
serverQueue.songs.shift ();
play ( guild, serverQueue.songs [0]);
})
.on (‘error’, error => {
console.error (error);
});
dispatcher.setVolumeLogarithmic (serverQueue.volume / 5);
}
client.login (token);

Now let’s see how to install this bot:

  • go to the Discord portal in the developers section, click the “New application” button;
    Discord Developers Section
  • enter the name of your bot, press “Create”;
    The name of the bot to create
  • click on the “Bot” tab and press the “Add bot” button;
    Add Bot button Confirmation of adding a bot
  • now it needs to be added to the server. To do this, go to the OAuth2 section and load our script in the scope panel;
  • mark the permissions required for the bot to work;
    Required permissions for the bot to work
  • as a result, a URL will be generated that needs to be inserted into the browser;
    URL to insert into the browser
  • it remains to select the server on which our URL will be added, and then click “Authorize”.
    New bot authorization

However, the same can be done without a program and your own server (the launch will be made from an external server dynobot.net). Sequencing:

  • go to dynobot.net, click the “Login with Discord” button, and then – “Authorize”;
    Login with Discord Button
  • in the window that opens, select the server on which the bot will run;
  • proceed to the bot setup procedure. In the top menu, click on the item “Bot Settings”. You can specify Prefix (the initial character for all commands used to control the bot) or leave the default (exclamation mark). Here you need to give the bot a name in the Nickname field;
  • proceed to the stage of directly creating a music bot for your channel. To do this, in the left menu, select and click on the item “Music”, select the channel on which our bot will operate, indicate the role – you can set a new one or choose from the proposed list of existing roles;
    Music Tab Options
  • go to the Discord server, open the channel that we specified in the previous paragraph of the list. Here you will need to register the help command with the prefix that we have set for our bot (the default is an exclamation mark, that is, the command will look like! Help). The bot will immediately send you a message with a list of available commands;
  • to start playing the pension, you need to enter the command! play <track name>, to stop playing, use the command! stop, to skip the current song -! skip.

As you can see, installing the bot will require maximum concentration from you, but there is nothing extremely difficult about it.

Removing a bot on Discord

If for some reason you no longer need the installed bot (tired, you found a new one with better functionality), you can remove it from the Discord server at any time. To do this, open the list of channel members, right-click on the bot and select the “Delete” option in the context menu that appears.

Removing a bot on Discord

You can also return it at any time, but you will have to perform the installation procedure again.

Removing the bot itself will not lead to the disappearance of all materials published by the add-on. If it becomes necessary to get rid of them, you will have to do it manually or use a special bot that specializes in chat cleaning.

Bot deletion confirmation

The procedure for moving a bot to another server can be implemented in a simple but inconvenient way, by deleting it on the first server and installing it from scratch on the second.

Now you know how to create your own bot on Discord, how to configure it for the first time. If you have any questions, ask them in the comments, they usually do not go unanswered.

Leave a Reply

Your email address will not be published. Required fields are marked *