A command handler that complements Hikari.
Project description
Yami
A command handler that complements Hikari. <3
Disclaimer
Still in early development. See the TODO list.
Documentation
Getting started with Yami
Stable release
pip install yami
Development
pip install git+https://github.com/Jonxslays/Yami.git
Creating a Bot
import asyncio
import datetime
import functools
import os
import typing
import hikari
import yami
bot = yami.Bot(os.environ["TOKEN"], prefix="$")
# Can only be run in guilds.
@yami.is_in_guild()
@bot.command("add", "Adds 2 numbers", aliases=["sum"])
async def add_cmd(ctx: yami.MessageContext, num1: int, num2: int) -> None:
# Basic builtin python types are converted for you using their type
# hints (int, float, bool, complex, bytes). More types coming soon™.
await ctx.respond(f"The sum is {num1 + num2}")
# Can only be run by members with one of these roles.
@yami.has_any_role("Admin", "Fibonacci")
@bot.command("fibonacci", aliases=("fib",))
async def fibonacci(ctx: yami.MessageContext, num: int) -> None:
"""Calculates the num'th term in the fibonacci sequence."""
calc: typing.Callable[[int], int] = functools.lru_cache(
lambda n: n if n < 2 else calc(n - 1) + calc(n - 2)
)
# Though we cache the function call, let's simulate thinking.
async with ctx.trigger_typing():
await asyncio.sleep(0.75)
# Make a pretty embed.
await ctx.respond(
hikari.Embed(
title=f"Fibonacci calculator",
description=f"```{calc(num)}```",
color=hikari.Color(0x8AFF8A),
timestamp=datetime.datetime.now(tz=datetime.timezone.utc),
)
.set_footer(f"Term {num}")
.set_author(
name=(author := ctx.author).username,
icon=author.avatar_url or author.default_avatar_url,
)
)
if __name__ == "__main__":
bot.run()
TODO
:heavy_check_mark: Complete
- CI
- Testing (WIP)
- Fully typed
- Bot
- Message Commands
- Message Subcommands
- Message Context
- Modules
- Exceptions (WIP)
- Checks (WIP)
- Basic arg parsing (builtin types)
- Docs
- Events (Mostly)
:x: Incomplete
- Module listeners
- Hooks?
- Slash Commands
- Slash Context
- Converters (WIP)
- Utils (WIP)
- Full blown arg parsing (hikari types)
- QOL methods (WIP)
- Logging (WIP)
Contributing
Yami is open to contributions. To get started check out the contributing guide.
License
Yami is licensed under the GPLV3 license.
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
Yami-0.4.0.tar.gz
(37.2 kB
view hashes)
Built Distribution
Yami-0.4.0-py3-none-any.whl
(46.0 kB
view hashes)