Skip to content

fardieov/Tutorial-Discord-Bot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Tutorial to Create a Discord Bot Using the Disnake Library 💙 #1

To make it easier for you, I have broken everything down into stages.

1. Beginning 🫡

Python installation

  1. Click here and you download python 3.12.4
  2. Be sure to check the box next to Add Python 3.12.4 in PATH and proceed with further installation

Also: After installing Python, you can also install Visual Studio Code to edit bot files using this link

2. Creating a bot 🤖

Create a new bot on the website Discord Developers Portal

  1. Go to site
  2. Click on the button New Application

image

  1. Name the robot and click Create

image

  1. Select a tab Bot

image

  1. Click Reset Token and save it somewhere (After reloading the page, the token will disappear and will have to be recreated if lost)

image

Intents

In the Bot tab, enable the following checkboxes

  1. Public Bot - Means the bot is public and can be added by other people to their Discord servers.
  2. Presence Intent - Allows the bot to track users' presence, including their real-time status (e.g. online, away, busy) and activity (e.g. playing a game).
  3. Server Members Intent - Allows the bot to obtain information about server members, such as names, nicknames, roles, etc.
  4. Message Content Intent - Allows the bot to receive information about the content of messages, including text and attachments.

Installing dependency

We write this command in cmd pip install disnake

Root file bot.py

Customizing the bot for yourself

Statuses
Online
status=disnake.Status.online

Offline
status=disnake.Status.offline

Do not disturb
status=disnake.Status.dnd

Not active
status=disnake.Status.idle
Activities
 Playing
 activity=disnake.Game(name="game")
 
 Looks
 activity=disnake.Activity(type=disnake.ActivityType.watching, name="youtube")
 
 Listens
 activity=disnake.Activity(type=disnake.ActivityType.listening, name="music")
 
 Streaming
 activity=disnake.Streaming(name="game", url="https://www.twitch.tv/nickname") #if you remove the url argument, the button simply won’t appear, but everything will work
 
 Competes in
 activity=disnake.Activity(type=disnake.ActivityType.competing, name="creating a bot")
Test Guilds

This parameter means adding a test server on which slash commands will be updated immediately. If you add a large number of identifiers, the bot will start slowly, we recommend adding no more than 3

To add your server there, write this:

test_guilds=[id]

To add several servers write like this

test_guilds=[id, id]

Important - If your server ID is not there, the slash command will appear/update only 10-15 minutes after it is added/changed

Terms

Cog - bot module where commands are stored, you can create as many cogs as you like (Cleaning, Entertainment, etc.)

Token - an encrypted Discord key with which the bot is authorized

Import is a mandatory thing that adds a lot of useful things to the code, example below

import disnake
from disnake.ext import commands

Event - a trigger that is activated by some action, for example on_ready - the bot is turned on (ready)

further look at the files, there I will post examples!

upd 2024 29.06 & upd 31.06 upd. 01.06

About

Discord Tutorial Bot

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages