View discord.py on Snyk Open Source Advisor (2024)

View discord.py on Snyk Open Source Advisor (1)

View discord.py on Snyk Open Source Advisor (2)

View discord.py on Snyk Open Source Advisor (3)

A modern, easy to use, feature-rich, and async ready API wrapper forDiscord written in Python.

Key Features

  • Modern Pythonic API using async and await.
  • Proper rate limit handling.
  • Optimised in both speed and memory.

Installing

Python 3.8 or higher is required

To install the library without full voice support, you can just run thefollowing command:

# Linux/macOSpython3 -m pip install -U discord.py# Windowspy -3 -m pip install -U discord.py

Otherwise to get voice support you should run the following command:

# Linux/macOSpython3 -m pip install -U "discord.py[voice]"# Windowspy -3 -m pip install -U discord.py[voice]

To install the development version, do the following:

$ git clone https://github.com/Rapptz/discord.py$ cd discord.py$ python3 -m pip install -U .[voice]

Optional Packages

Please note that when installing voice support on Linux, you mustinstall the following packages via your favourite package manager (e.g.apt, dnf, etc) before running the above commands:

  • libffi-dev (or libffi-devel on some systems)
  • python-dev (e.g. python3.8-dev for Python 3.8)

Quick Example

import discordclass MyClient(discord.Client): async def on_ready(self): print('Logged on as', self.user) async def on_message(self, message): # don't respond to ourselves if message.author == self.user: return if message.content == 'ping': await message.channel.send('pong')intents = discord.Intents.default()intents.message_content = Trueclient = MyClient(intents=intents)client.run('token')

Bot Example

import discordfrom discord.ext import commandsintents = discord.Intents.default()intents.message_content = Truebot = commands.Bot(command_prefix='>', intents=intents)@bot.command()async def ping(ctx): await ctx.send('pong')bot.run('token')

You can find more examples in the examples directory.

Links

View discord.py on Snyk Open Source Advisor (2024)

FAQs

How do you make a Discord bot respond to another bot? ›

In order to get your Discord bot to reply to another bot, you'll need to use the Discord API to listen for incoming messages and then send a response when the bot receives a message from another bot.

How do you make a Discord bot reply to a specific message? ›

You can send the message ID to the bot and the bot saves the message ID as a variable, then replies to the correct message using its message ID.

Is Discord API free? ›

Are there examples of free Discord APIs? DiscordBot offers all of its endpoints for free, but the price for other APIs in the Discord collection can vary. While most of the big games represented on the list have free APIs, others are paid or freemium.

Does Discord have a public API? ›

Discord's API is based around two core layers, a HTTPS/REST API for general operations, and persistent secure WebSocket based connection for sending and subscribing to real-time events.

Does Discord have an open API? ›

Discord OpenAPI Specification. This repository contains the public preview of the OpenAPI 3.1 specification for Discord's API. Currently, the spec is only available for the most recent Discord API version (v10).

Can Discord bots react to messages? ›

The bot can respond to a message or user by selecting randomly from a set of emoji, and can also respond to a random interval of message as well as fixed.

How do I send a Discord message in Python? ›

To send a message to Discord we need to send a web request to this Webhook URL, and to do that we're going to use the Python requests library. Discord expects the request to include a JSON object as the payload, but we can use a Python Dictionary and the requests library will translate that into JSON for us.

Can Discord bots reply? ›

You can do that, your bot needs to differentiate users and have a logic to respond accordingly. You first identify the user (you can capture the ID of the user) and group the users in a group (like group 1 will get the answer X and group2 will get the answer Y).

Top Articles
Latest Posts
Article information

Author: Maia Crooks Jr

Last Updated:

Views: 5576

Rating: 4.2 / 5 (63 voted)

Reviews: 94% of readers found this page helpful

Author information

Name: Maia Crooks Jr

Birthday: 1997-09-21

Address: 93119 Joseph Street, Peggyfurt, NC 11582

Phone: +2983088926881

Job: Principal Design Liaison

Hobby: Web surfing, Skiing, role-playing games, Sketching, Polo, Sewing, Genealogy

Introduction: My name is Maia Crooks Jr, I am a homely, joyous, shiny, successful, hilarious, thoughtful, joyous person who loves writing and wants to share my knowledge and understanding with you.