Skip to content

Zarenalabs/zarenacord

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

zarenacord

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

Documentation | Support Server | Discord API