Bot library for Zyntra
Project description
zyntra.py
[!warning] This library is in beta, expect weird things to happen. API changes may also not reflect instantly.
An unofficial bot library for making bots in Zyntra, written for Python.
Usage
Download the library using pip:
pip install zyntra.py
Create a bot at the developer site, you can view this guide.
Atleast Python 3.9 or higher is required in order to use this library.
Bot Example
[!note] If you're used to discord.py, then this should be mildly similar.
from zyntra import *
from zyntra.utils.color import Color
# ID = Bot ID
# Optionally, you can set a prefix using prefix="prefix!"
client = Client(TOKEN, ID)
# If a user tries to run a command that's currently on cooldown.
@client.on_cooldown()
async def on_cooldown(command: CommandData, channel: Channel, remaining: float):
await channel.send(f"⏳ Command `{command.name}` is on cooldown!\nTry again in **{remaining:.2f}** second(s).")
# Once the client logs in.
@client.on_ready()
async def ready():
print("Client is ready!")
# Once the client's socket connects
@client.on_socket_connect()
async def connect():
print("Connected to socket!")
# When a message is created.
@client.on_message_create()
async def on_message(msg: Message):
print(msg.content)
# Registers an echo command (Order: name, description, cooldown in seconds)
@client.command("echo", "Echoes text.", 1)
async def echo(ctx: Interaction, args: list):
await ctx.reply(" ".join(args))
# A help command displaying all the commands.
@client.command("help", "Gets all commands")
async def help(ctx: Interaction, args: list):
cmds = [f"`{client.prefix}{command.name}` - {command.description}" for command in client.commands]
embed = Embed(
title=f"Commands",
description="\n".join(cmds),
color=Color.get_color("green"),
footer=f"There are currently {len(cmds)} command(s)!"
)
await ctx.reply(embed=embed)
# Starts the main bot loop
client.start()
Currently supported events:
-
on_message_create(Socket.IO name: messageCreate) - Occurs when a message is created. -
on_socket_connect(Socket.IO name: join) - Occurs when the bot connects to the socket. -
on_ready- Occurs when everything is done successfully. -
on_cooldown- Occurs when a user tries to run a command that is on cooldown.
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file zyntra_py-0.1.0.tar.gz.
File metadata
- Download URL: zyntra_py-0.1.0.tar.gz
- Upload date:
- Size: 8.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9183b0e5ff6848ec19c788ab04d082bd8258b2feb6446a577ae87f7038648435
|
|
| MD5 |
f02473907012c0dcc62843e05a98a607
|
|
| BLAKE2b-256 |
c378ec953b0e6a72f30a61cd7930b8a5dfc9f5c9a23f141218d5567f554d6d26
|
File details
Details for the file zyntra_py-0.1.0-py3-none-any.whl.
File metadata
- Download URL: zyntra_py-0.1.0-py3-none-any.whl
- Upload date:
- Size: 7.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b4bf59bb6c265b68cb2680782332d5731fa3bd6e03c0bba260e16e0de5fbe4c7
|
|
| MD5 |
64ea615b58cfcf0315bb5750c656274e
|
|
| BLAKE2b-256 |
ae12e59b0204357dd9e654cf0ef6cf4ed25d1fa1b6f06811210ff843fdf068e3
|