Skip to main content

A flexible and easy to use Discord API wrapper for python 🚀.

Project description

wyvern

A flexible and easy to use Discord API wrapper for python 🚀.

Why use wyvern?

  • Feature rich API.
  • Full control over the library's functionality.
  • Built-in extensions for prefix commands.
  • Interaction commands handling.

Installation

# from pypi 
$python -m pip install wyvern
# from source stable branch
$python -m pip install git+https://github.com/sarthhh/wyvern@main
# from source development branch 
$pythonn -m pip install git+https://github.com/sarthhh/wyvern

Example Code:

  • Basic GatewayClient with listener.
import wyvern

# creating a GatewayClient instance and storing it into the client variable.
# this acts as the interface between your bot and the code.

client = wyvern.GatewayClient("TOKEN", intents=wyvern.Intents.UNPRIVILEGED | wyvern.Intents.MESSAGE_CONTENT)

# creating an EventListener object and adding it to the client's event handler using the
# @client.listen decorator. You can set the maximum amount of time this listener will get triggered using
# the `max_trigger kwarg in the listener decorator.`


@client.listener(wyvern.Event.MESSAGE_CREATE)
async def message_create(message: wyvern.Message) -> None:
    """This coroutine is triggerd whenever the MESSAGE_CREATE event gets dispatched."""
    if message.content and message.content.lower() == "!ping":
        await message.respond("pong!")


# runs the bot.

client.run()
  • GatewayClient with custom event handler.
import wyvern

# subclassing to create a new EventHandler class.
# events listeners can be added using the @wyvern.listener decorator.
# the client can be accessed using client attribute inside the listener.


class MyHandler(wyvern.EventHandler):
    @wyvern.listener(wyvern.Event.MESSAGE_CREATE)
    async def message_create(self, message: wyvern.Message) -> None:
        print(f"Message sent by {message.author.username}")


# the subclass' type ( !not instance ) is provided for the event_handler kwarg inside
# the client class. which uses this custom EventHandler instead of a default one.

client = wyvern.GatewayClient("TOKEN", event_handler=MyHandler)

# runs the bot.

client.run()

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

wyvern-0.0.2a0.tar.gz (22.1 kB view hashes)

Uploaded source

Built Distribution

wyvern-0.0.2a0-py3-none-any.whl (44.7 kB view hashes)

Uploaded py3

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page