Discord Bot Intro
Discord Bot Intro
in
By
I hereby declare that this project has been done by me under the supervision of Dr. Hari
Singh, Assistant Professor (SG), Computer Science & Engineering and Information
Technology, Jaypee University of Information Technology. I also declare that neither this
project nor any part of this project has been submitted elsewhere for the award of any
degree or diploma.
Supervised by:
Submitted by:
Harshit Gautam
(181426)
Advait Agnihotri
(181282)
I
ACKNOWLEDGEMENT
Firstly, I express my heartiest thanks and gratefulness to Almighty God for His divine
I am really grateful and wish my profound indebtedness to Supervisor Dr. Hari Singh,
Assistant Professor (SG), Department of CSE, Jaypee University of Information
Technology, Waknaghat. Deep Knowledge & keen interest of my supervisor in the field of
“Task-Oriented Bots” to carry out this project. Her endless patience, scholarly guidance,
continual encouragement, constant and energetic supervision, constructive criticism,
valuable advice, and reading many inferior drafts and correcting them at all stages have
made it possible to complete this project.
I would like to express my heartiest gratitude to Dr. Hari Singh, Assistant Professor
(SG), Department of CSE, for his kind help to finish my project.
I would also generously welcome each one of those individuals who have helped me
straightforwardly or in a roundabout way in making this project a win. In this unique
situation, I might want to thank the various staff individuals, both educating and
non-instructing, which have developed their convenient help and facilitated my
undertaking.
Finally, I must acknowledge with due respect the constant support and patience of my
parents.
Harshit Gautam
(181426)
Advait Agnihotri
(181282)
II
TABLE OF CONTENT
CONTENTS PAGE NO.
List of Figures
Abstract
Chapter 01: INTRODUCTION 1-19
References
IV
LIST OF FIGURES
V
F.18 DFD diagram for the project
VI
F.39 Output Screenshot 3
VII
ABSTRACT
The main highlight of this app is its ability to compete and exceed top streaming platforms
which is handy. The structure of discord i.e. division in terms of server, channels, and
voice channel makes it very user-friendly. Top esports organization streamers, gamers, and
top influencers are making their servers to make their engagement more strong.
Bots are an integral part of discord which provide users to enhance and maintain their
servers and perform various tasks assigned by the admins. Bots are created with the help
of registering for the bot at the discord developer portal and developing the bot
accordingly for their specific use.
The Discord API is based on two separate APIs which are WebSocket API and Rest API.
The Websocket API is used to receive events from the discord in real-time. The bot uses
this API to request a connection, manage voice connections and perform fundamental
tasks, whereas the Rest API is responsible to perform actions in discord.
It acts as a query for information and is responsible to perform various actions like sending
messages, kicking/banning the users, and updating user information. Our bot (HAM) is a
discord bot that comes with multiple functions in terms of moderation, chat messaging,
music playing, etc. It can perform multiple tasks in the discord server.
Along with that, it recognizes when a user enters the server and authenticates via user info
whether the user is another bot or human. HAM is currently equipped with multiple
functions like getting sentiment analysis on users’ messages to playing songs from
Youtube, all directly from within the discord. These all commands are based on various
python libraries including youtube_dl, urllib, etc.
VIII
CHAPTER 01 : INTRODUCTION
1.1 Introduction
“A complete Voice and text chat for gamers that's free, secure, and works on both
desktop and phone at ultra-low latency rate. Save ur bucks on TeamSpeak servers and
hassling with Skype. Simplify your life.”
“Almost every top influencer around the globe now has their own discord servers and
channels for their engagement and endorsement .”
1
Discord is a chat app?
Yes, it is but it's more convenient than any chat application and well structured.
Discord is becoming more and more popular. That way automation prohibition of
inappropriate users responding to user demands is essential for the community to prosper
and grow. Appearance and acts like a user react automatically to events, discord
commands are called bot users. discord for bot users (or bots only), there are almost
endless possibilities of applications. For example, let's say you manage a new Discord
Guild and Users Join for the first time. Excited, you can contact it personally to welcome
them to users and your community. You can also talk to them or ask them about your
channel image. Users feel welcome and Enjoy the discussions taking place in the guild and
they in turn invite their friends. Over time, your community has grown so large that it is no
longer feasible to personally approach each new member other than you, still want to send
something to recognize them as a new guild member. In the case of bots, It is possible to
automatically respond to new members joining the guild. You can customize it to control
contextual behavior and how it works and Interact with each new user. Users can now
copy or paste other image Videos, but have no ability to fetch them automatically.
The one on the text channel has been implemented yet. Discord provides a connection
with Spotify, YouTube, Steam, etc., but not Reddit. is not A program to help you find all
the news, votes, and facts,
2
is active everywhere on Discord, but all Discord bots are made for you
Play music only for specific reasons, such as Generate YouTube, Spotify, tokens, or
RPGs, or text game. In a world where communication is important For many, it's
important for the platform
Of the community. Discord is divided into servers Unique members, themes, rules,
and channels. Discord also allows users to talk and Not only video chat, but also live
stream games, etc. A program from their computer. Basically, Discord is set up to allow
members to do this. Message to each other. Each community If you are familiar with
"server." Slack, you can think of it as follows: Of it is a less formal version of this app.
The server is Full of text channels (you can type and speak To others) and audio channels
(where you can) Voice chat with others). You can also share videos, photos, internet links,
music, etc. Any server There are usually several channels, each of which is Dedicated to
another topic or has different rules. For example, there may be a channel to talk to About
another for games and general chat The other is a picture of a cat. The possibility is
infinite. It's free to start your own server and free to join Other servers. There are
thousands of different discord servers, each one dedicated to a different topic. If you have
an interest in something, there's a good chance you can find a Discord server for it. This is
especially true for video games, which make up the bulk of Discord's most popular servers
Discord is a chat app for gamers with features such as text, images, video, and audio
communication.
The more formal definition of Discord is a freeware internet telephony application and
digital distribution platform for the video gaming community with the features mentioned
above.
3
Today, Discord bots are one of Discord's best features, allowing you to create automated
users to perform all sorts of functions in Discord. This is another unique feature that sets
Discord apart from other chat apps. The bot helps Discord get specific data, deliver
notifications, schedule events, and play music for users on the server.
*A channel is where you can chat and communicate with the other members. You can
drop your messages in a channel like a normal chat app. In addition to that, there are voice
channels where you can
3. You can use voice channel overlay in any application at ultra-low latency.
A discord bot is an automated program coded in order to perform various functions around
the discord servers. It provides you with more functionality than a normal user can along
with that it helps to reduce the workload from human moderators and perform repetitive
tasks.
4
A discord bot can be a:
1. Chat Bot (a bot that chats & tries to behave like a human)
2. Moderation Bot ( it will moderate your server; kick, mute or ban members, if someone
tries to create spam or anything similar likewise)
3. Music Bot (It plays music from the youtube or any other media platform)
2. Control the levels of spam in the servers using sentiment analysis on users’
messages.
Discord bots are one of the most useful features of communication platforms. These are
AIs that marketers and business owners can use to perform various automated tasks on
their servers.
Building a community is never easy, but doing it on Discord is a great way to give people
a sense of exclusivity. If you already have an audience, you can benefit from this strategy.
In a secure and closed community environment, you can provide tips, record videos, host
your life, and teach others everything you know. When people feel they're getting
something they can't get anywhere else, they're more likely to share it with others and pay
more for information in return.
Discord bots make it easy to build an avid community. You can use them to welcome new
members to the server, relax communication between members, and ban people who
5
refuse to follow the rules.
You can use them to add memes, games, music, and other fun content to your server to
make it more fun for your members.
A Discord bot is something that will assist you with making getting things done in your
organization more straightforward.
It gives different capacities going from playing music to sending youtube links and playing
fun games like tictactoe.
It can likewise help you in administrating your disagreement society when you're away.
You can either utilize an outsider bot or make yourself one by coding it with any
programming dialects, for example, Java, Python, C++, and so forth.
Discord has its own vocabulary. You may hear teens and students use these words when
speaking on Discord.
They are created by a specific community or group of friends. Most of the servers are
small and invitation-only. Some large servers are open to the public.
All users can start a new server for free and invite their friends.
6
F.2 Discord server example image
Channels: Discord servers are organized into text and audio channels. These are usually
specific to a particular topic and can have different rules.
Text channels: allow users to post messages, upload files, and share images for others to
see at any time.
Voice channels allow users to connect via real-time voice or video calls and share their
screens with friends. This is called GoLive. DM and GDM.
7
F.3 Discord voice channels example image
8
Users can send private messages to other users as direct messages (DM), and initiate voice
and video calls.
Most DMs are one-to-one, but users have the option of inviting up to 9 people to a
conversation and creating a private group DM of up to 10 people.
Group DM is not open to the public and requires an invitation from someone in the group
to join.
Get up and running: Users can share their screens with anyone on the server or in the DM.
9
Nitro: Nitro is Discord's premium subscription service. Nitro offers subscribers the
following special benefits: This includes options to customize Discord tags, the ability to
use custom emotes on each server, higher file upload limits, and discounted server boosts.
10
Server Boost: If your teen is a big fan of the community, they may want to boost the
community's (or their own) servers. Like Nitro, Server Boost provides servers with special
benefits such as more custom emotes, better video and audio quality, and the ability to set
custom invitation links. Server Boost can be purchased with Nitro or individually.
Student Hubs: Student Discord Hubs allow students to verify their Discord account using
their official student email address and unlock access to their school's student-only hubs.
Within the hub, you can connect with other validated students, find servers for research
groups and classes, and share your server with other students.
11
Hub does not partner with or manage the school or school staff. The servers in the hub are
run by students, but may also include non-student servers.
12
It's important to know which Discord bot you want to add. Some bots can improve the
server and provide a better community so that users are with you and want to interact with
you. The wrong ones could turn people away or create a poor environment.
13
1.3 Objective of the Major Project
Discord bot is the most salient feature of discord where you can create and develop your
own bot according to your need to perform various functions.
This is also another unique feature that outclasses Discord with the other chatting apps out
there. Bots are useful for representing certain data in a Discord server, delivering the
notifications, scheduling an event, playing music for users on a server, etc.
The important thing is that when any server is holding a community of more than 100’s
members then the discord structure and bots make it very easy for admins to manage the
users in their server in a very structured manner and make it very easy for them to perform
moderation tasks.
We are users of discord for more than 5 years and we have experienced the needs and
uses of discord bots firsthand. Discord bots offer services that make handling large-scale
as well as small discord servers quite easy.
Discord is not a small app anymore and many companies are investing in it or connecting
their services to Discord. e.g. Patreon has already waded its way into it. Discord bots are
also sold at discord bot shops to the users to help them maintain or improve their server.
These days, every content creator , from a youtube streamer to a company like Gameloop
has their personal discord servers to interact with their friends, customers, and users.
14
F.9 Discord news screenshot
1.5 Organization:
Our discord bot is an interconnected python script that can be run on Visual
studio code, python idle, atom, Jupiter notebook, and all the other tools used for
running a python program.
As soon as the script runs on the shell, the bot comes online in the Discord server
wherever it is added as a bot along with all its functionalities. The bot can then
be used within the server for all the functions provided in it.
For organizing those functionalities we have used certain modern world pythons
grouping methods such as the usage of cogs and events:-
1. Cogs:
Cogs are used to organize a set of commands, listeners, and states in one class.
15
F.10 Cogs in our project
2. Events:
Events are like actions happening in the server that takes place, for instance when
someone joins or leaves the server.
An event is something exact that happens (in our most memorable model code, the
event is "a message is made").
16
F.11 Discord Welcome channel screenshot
The language used in this project is Python, Version 3.9.5. Python strives for
readable codes and hence it is easier to read and write.
17
F.12 Python libraries screenshot from our project
The main requirement for this project is Bot Token, which discord provides for
submitting applications. Without a bot token, the bot cannot be run in discord.
18
1.8 Deliverables of the Major Project
A discord bot is a bot that runs only on discord; it provides with you more
functionality than a normal user has .
Our deliverables include :
● Audio Player ( Connects to your voice channel and play music directly
from youtube within discord )
● View information about any user in the discord server.
● Search for a video from youtube within discord .
● Automated greetings to the new user joining the server and farewell to the
users leaving the server.
● Sentiment analysis on users’ messages.
● Play fun games like tictactoe with other users .
19
CHAPTER 02: MAJOR PROJECT SDLC
20
2.1 Feasibility Study on Major Project
Discord is a fast-growing app and discord bots are the backbone of discord servers.
Discord bots offer many features to keep the server smooth and alive. So, having your own
discord bot is very handy and safe.
The bots can help you detect spammers and fraud users. Out there, there are many discord
bots for many purposes, but they are either paid or have subscription basis services . Every
server must be maintained by discord bot to keep it clean and cozy . If the bot is good , it
can gain enough charm and users will add the bot to mass servers .
The bot can also hold donation platforms or offer paid upgradeable services to farm
revenue.Our discord bot is currently active in a few small servers and the user experience
was quite seamless.
The bot can be easily created in a modern OS device in a code editor using various,
programming languages and tools.
21
The bot token is like a password for the bot to use Discord API.
Our bot is written in Visual Studio Code software on a windows (x64) pc. The output was
live observed on the discord app installed on the same pc. Apart from libraries ( mentioned
later ), we used the basic structure of cog around various discord events to create various
commands ( bot services ).
22
F.16 References to various cogs in the bot directory
● Users should not be allowed to use the bot in multiple voice channels on the same
23
server
24
In the middle is the official Discord server and API, which is maintained and run by
discord itself.
On the right top is our discord code which is connected to the discord API .
Discord bot code detects the commands ,events and responds with the function commands
created in the code in our discord server.
Under our discord code is our server where all users and bots interact with each other.
Discord server is customizable by admin users according to their wishes and the server
permissions can be set by the admin as per their choices.
25
F.18 DFD diagram for the project
Our discord bot is a pre programmed bot . It detects the command and takes certain actions
for an entered command.
26
2.5 State Transition Diagram of the Major Project
● Music Command
13
27
● Youtube search command
28
● Tictactoe game command
Our bot can start a game of tictactoe in between two users . Although the game has to be
commanded by any user , however the arbiter of the game is the discord bot which
oversees for any fouls or misturn during the game and declares the winner after the game
ends.
29
CHAPTER 03: IMPLEMENTATION OF THE MAJOR PROJECT
In order to use the python library and discord API, we created a Discord bot account. First,
log in to the discord developer portal web page ( ) and navigate to the application page.
There, create a “New Application”. Fill in the required details and submit the application.
The discord dev will survey your application form and a token is granted on acceptance for
the bot.
The Token is like a password for the bot. Once granted, the token can be regenerated if
lost. The next step was to add a bot to your discord server.
We created a new discord server for this project and added the bot from the developer
portal to our discord server.
30
3.2 Discord bot Code
We used the discord.py library to write the code for our bot.We also used other small py to
create various services in discord for our server. Discord bot code mainly uses two
components :
(a) Cogs
This helps in keeping one type of command together from the other. With
commands, different cogs can be loaded and unloaded to maximize efficiency.
When cogs are created, they are needed to be registered with the main bot to be
used. We have created separate cogs for entertainment commands, moderation,
commands and chatbot commands.
31
(b) Events
Events are like actions happening in the server which take place for instance when
someone joins or leaves the server, some user sends a message or joins/leaves a
voice channel.
These actions are called events. These events are used in discord bot code for the
detection of commands to the bot and the action to be performed on giving a
command.
Creating a Discord music bot is not easy as discord itself does not offer music services .
We used the youtube_dl python library to fetch videos from youtube within discord in our
bot.
Then we converted the video into mp3 format using FFmpeg python library so the bot can
play the mp3 file in a discord voice channel.
The bot first needs to connect to the same voice channel as the user and then download the
video from youtube, convert it to mp3 format and play it on the voice channel.
If the user is not connected to any voice channel , the bot refuses to connect to a voice
channel and play any music .
32
F.25 Music command problem statement diagram
on the left is the discord server and on the right is the discord bot
33
F.26 Flow graph of the problem
Discord users interact with each other via sending messages in text channels or talking in
voice channels .
Commands to the bot can be sent via text in text channels on which the bot takes specified
actions.
The bot interacts with Discord through discord API and when commands are triggered ,
the bot reacts in a pre-programmed way.
The Discord REST API is used by bots to perform most action such as sending messages,
updating user info etc.
34
F.27 Workflow diagram
Our recent project development includes the tictactoe game and shifting of our project
from windows 10 to a windows 11 pc .
Shifting from one version of the operating system to another required updation of python
libraries in our project which we performed in the last stages of our project.
Below are the screenshots from our code of our project , which we coded in
Microsoft visual studio code .
35
F.28 Code Screenshot 1
36
F.30 Code Screenshot 3
● Cogs
37
This is a sample screenshot from a cog “ Utils” which has some utility commands in it.
● Music Commands
This is a screenshot from the music cog, showing the play function.
Music cog has variety of codes ranging from vode for searching music keyword to
connecting to a voice channel. Above figure is just a peek at the huge code of
music cog.
38
F.33 Code Screenshot 6
Here, you can see the function to analyze the message entered by the user.
Our bot uses emoticons to create the board panel for playing tictactoe game
and lets two users to enjoy the game .
39
F.34 Code Screenshot 7
In above figure , we have crated the game board with white large square emoticons for
default state of game and then replac them with cross emoticons or circle emoticons as per
the choice of player’s move .
The bot sends the updates board in the chat after a user has played one turn .
This continues until the game has reached deadlock state or a player has won.
40
F.35 Code Screenshot 8
Utility commands provide help to the admin to access the information regarding
the discord users, servers, etc.
41
F.36 Code Screenshot 9
In the above screenshot , we have created utility based command function userinfo for
accessing public information of any discord account added in the bot’s server .
This helps the admins to detect fraud accounts and prevent spam in the server.
42
CHAPTER 04: RESULTS
We created all the necessary commands and were able to achieve the following results:
When a user enters the server , the event of server entry is created in the discord API ,
and the bot is pre-programmed to push notification in a given channel on detecting such
an event .
43
F.38 Output Screenshot 2
When a user leaves the server, the event of server leave is created in the discord API,
and the bot is pre-programmed to push notifications in a given channel on detecting such
an event.
3. HAM is able to understand emotions and is able to recognize that as created in its
file.
44
F.40 Output Screenshot 4
4 . HAM is able to identify the user and present necessary details about it in the form of
embeds .
45
4. HAM is able to play music on the server.
The bot plays music using the play command from youtube and also has commands like a
queue, and stop for further control.
46
F.44 Output Screenshot 8
You just send a message and the bot will provide sentiment analysis on the message.
This helps the user to check his internet strength and speed.
47
7. HAM is able to initiate TicTacToe, a fun game between two users.
When the game ends, the bot announces the winner of the game and ends the game
session.
48
F.47 Output Screenshot 11
In the above figure , the bot can be seen to end the game and declare the player
winner with the ‘X” emoticon mark.
49
4.2 Application of the Major Project
The application of the project is to perform all the necessary functions on the discord
server and perform specific tasks assigned to it. Provide help to admin as well as users in
the server for their work and make their work more hassle-free.
The aim of a discord bot is to perform repetitive tasks that can be tedious for the admin as
well as the user and having a bot on the server makes it very easy.
● HAM is currently available on small servers where participants are less than 100.
● HAM’s features are limited right now and don't have voice commands.
● HAM isn't available 24X7 as it is hosted on our pc, not on a cloud server.
● Provide HAM with more moderation commands for better user experience
50
REFERENCES
● Discord App.
https://discord.com/download
https://code.visualstudio.com/download
● Python
https://www.python.org/downloads/
● Libraries :
discord : https://pypi.org/project/discord.py/
urllib : https://pypi.org/project/urllib3/
re : https://pypi.org/project/regex/
youtube_dl : https://pypi.org/project/youtube_dl/
shutil : https://pypi.org/project/pytest-shutil/
random : https://pypi.org/project/random2/
ffmpeg : https://pypi.org/project/ffmpeg-python/
vaderSentiment : https://pypi.org/project/vaderSentiment/