Skip to content

LuigiBengala/DiscordBotPython

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Discord Bot with Python

Installation

Use the package manager pip to install the following packages.

Important: Some cases you need to use pip3 instead of pip

pip install nextcord
pip install asyncio
pip install PyNaCl

Adding an image to the bot

  1. Add the image to the folder assets/images/

Note: The image must be in .jpg format, if the image is in another format, you must change the extension in the code or the extention in the image

async def sendImage(ctx, image):
    await ctx.send(file=nextcord.File(f'./assets/images/{image}.jpg'))
  1. Change the imageTest with the name you gave to the image

Note: The name of the image must be the same as the name of the command, do not include the file extension

@bot.command(name = 'imagetest')
async def image(ctx):
    await sendImage(ctx, 'imageTest')

Adding an audio to the bot

  1. Add the audio to the folder assets/audios/

Note: The audio must be in .mp3 format, if the audio is in another format, you must change the extension in the code or the extention in the audio

      source = FFmpegPCMAudio('./assets/audios/{name}.mp3')
  1. Change the audioTest with the name you gave to the audio
  2. Change 6 with the duration of the audio.

Note: The duration of the audio must be in seconds

@bot.command(name = 'audioTest')
async def sendAudio(ctx):
    await playAudio(ctx, 'audioTest', 6)

Sending text with a command

  1. Change the textMessage with the text you want to send

Note: both the @bot.command textTest is the comand the bot will use to send the text, the textMessage is the message the bot will send when the command is used

@bot.command(name = 'textTest')
async def message(ctx):
    await sendMessage(ctx, 'textMessage')

Token

  1. Change the token with the token of your bot. If you don't know how to get the token, click here
    bot.run('Your token')

About

Basic Discord Bot With Python

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages