Skip to main content

A Python wrapper for the Discord API

Project description

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


Discord server invite PyPI version info PyPI supported Python versions Documentation Status

PLEASE NOTE: This is a fork of OG discord.py by Rapptz! Since Danny no longer maintains dpy so I created this lib in order to add any upcoming feature from Discord and I’m using Maya’s slash command wrapper for application commands.

Key Features

  • Modern Pythonic API using async and await.

  • Proper rate limit handling.

  • Command extension to aid with bot creation

  • Easy to use with an object oriented design

  • 100% coverage of the supported Discord API.

  • 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 the following command:

# Linux/macOS
python3 -m pip install -U zarenacord

# Windows
py -3 -m pip install -U zarenacord

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

# Linux/macOS
python3 -m pip install -U "zarenacord[voice]"

# Windows
py -3 -m pip install -U zarenacord[voice]

To install the development version, do the following:

$ git clone https://github.com/Zarenalabs/zarenacord.git
$ cd zarenacord
$ python3 -m pip install -U .[voice]

Optional Packages

Please note that on Linux installing voice you must install 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.6-dev for Python 3.6)

Quick Example

import discord

class MyClient(discord.Client):
    async def on_ready(self):
        print('Logged in 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')

client = MyClient()
client.run('token')

Bot Example

import discord
from discord.ext import commands

bot = commands.Bot(command_prefix='!')

@bot.command()
async def ping(ctx):
    await ctx.send('pong')

bot.run('token')

Application Commands Example

zarena defines a bot subclass to automatically handle posting updated commands to discords api. This isn’t required but highly recommended to use.

class MyBot(zarena.Bot):
    def __init__(self):
        super().__init__(command_prefix="!")  # command prefix only applies to message based commands

        self.load_extension("cogs.my_cog")  # important!

if __name__ == '__main__':
    MyBot().run("token")

Sample cog:

class MyCog(zarena.ApplicationCog):

    # slash command
    @zarena.slash_command()
    async def slash(self, ctx: zarena.Context, number: int):
        await ctx.send(f"You selected #{number}!", ephemeral=True)

    #  message context menus
    @zarena.message_command(name="Quote")
    async def quote(self, ctx: zarena.Context, message: discord.Message):
        await ctx.send(f'> {message.clean_content}\n- {message.author}')

    # user context menus
    @zarena.user_command(name='Cookie')
    async def cookie(self, ctx: zarena.Context, user: discord.Member):
        await ctx.send(f'{ctx.author} gave cookie to {user} 🍪')

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

zarenacord-2.0.0.tar.gz (824.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

zarenacord-2.0.0-py3-none-any.whl (913.4 kB view details)

Uploaded Python 3

File details

Details for the file zarenacord-2.0.0.tar.gz.

File metadata

  • Download URL: zarenacord-2.0.0.tar.gz
  • Upload date:
  • Size: 824.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.6.4 pkginfo/1.8.2 requests/2.25.0 requests-toolbelt/0.9.1 tqdm/4.56.2 CPython/3.8.2

File hashes

Hashes for zarenacord-2.0.0.tar.gz
Algorithm Hash digest
SHA256 dce2f2ea14507705abf17408ba123b95a897088285b31b80600b42c4ca3d80f8
MD5 935fa967e8fb5bfbb165609694afce68
BLAKE2b-256 99fd851fdde76395f5fc5d1b82ffc173fcad9e6ff6e3065f085bfd9664b0bb81

See more details on using hashes here.

File details

Details for the file zarenacord-2.0.0-py3-none-any.whl.

File metadata

  • Download URL: zarenacord-2.0.0-py3-none-any.whl
  • Upload date:
  • Size: 913.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.6.4 pkginfo/1.8.2 requests/2.25.0 requests-toolbelt/0.9.1 tqdm/4.56.2 CPython/3.8.2

File hashes

Hashes for zarenacord-2.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 70ee3b7a0514027f5e0b7e52b8bacf86084d998c04ee65488de007504c54f3c5
MD5 a8f6208686dfa1063e35efae7f82219e
BLAKE2b-256 3d8fb7097b44a1f3cb1f415807ade82c868de68ac0397e00f9323bd231ac8478

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page