Coder Social home page Coder Social logo

discordbotpython's Introduction

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')

discordbotpython's People

Contributors

luigibengala avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.