bot#

The class to connect your application with the Discord API.

class wyvern.GatewayBot(token: str, *, api_version: int = 10, intents: SupportsInt | Intents = 3178233)[source]#

Bases: ImplementsEventDecos

The main bot class that interacts with the discord API through both REST and gateway paths.

Parameters:
  • token (str) – The bot token to use while execution.

  • api_version (int) – Discord API version in usage, defaults to 10.

  • intents (SupportsInt | Intents) – Library’s Intents builder or any object that returns the intent value when passed to int

Example

import asyncio

import wyvern

bot = wyvern.GatewayBot(
    "BOT_TOKEN_HERE",
    intents=(
        wyvern.Intents.GUILD_MEMBERS
        | wyvern.Intents.GUILDS
        | wyvern.Intents.GUILD_MESSAGES
        | wyvern.Intents.DIRECT_MESSAGES
    ),
)

asyncio.run(bot.start())
event_handler: EventHandler#

The EventHandler attached to the instance.

intents: Intents#

Intents being used by the bot.

listener(event: type[Event], *, max_trigger: int | Undefined = <wyvern.utils.consts.Undefined object>) Callable[[types.EventListenerCallbackT], EventListener][source]#

Adds a listener to the bot’s event handler

Parameters:
  • event (type[Event]) – Type of the event.

  • max_trigger (int) – Maximum number of times this event should be triggered.

Returns:

listener – The event listener that was constructed.

Return type:

EventListener

rest: RESTClientImpl#

The REST handler attached to the instance.

async start(raise_exception: bool = False) None[source]#

This function is a coroutine.

Verifies the bot token and starts listening to the gateway.

Parameters:

raise_exception (bool) – Set to true if exceptions should be be raised at this entrypoint.