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.
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
PyNaCl (for voice support)
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} 🍪')
Links
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for zarenacord-2.0.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 70ee3b7a0514027f5e0b7e52b8bacf86084d998c04ee65488de007504c54f3c5 |
|
MD5 | a8f6208686dfa1063e35efae7f82219e |
|
BLAKE2b-256 | 3d8fb7097b44a1f3cb1f415807ade82c868de68ac0397e00f9323bd231ac8478 |