Skip to main content

A command handler that complements Hikari.

Project description

Yami

A command handler that complements Hikari. <3

Downloads Python versions

License Stable version

Last Commit Last Commit

Last Commit Last Commit


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


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.1.tar.gz (37.2 kB view details)

Uploaded Source

Built Distribution

Yami-0.4.1-py3-none-any.whl (46.1 kB view details)

Uploaded Python 3

File details

Details for the file Yami-0.4.1.tar.gz.

File metadata

  • Download URL: Yami-0.4.1.tar.gz
  • Upload date:
  • Size: 37.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.13 CPython/3.8.2 Linux/5.13.0-1022-azure

File hashes

Hashes for Yami-0.4.1.tar.gz
Algorithm Hash digest
SHA256 2c60be969a9df406b1eea0b0dbd37dd5bc5312a04a4f185e88685b9701e9e25e
MD5 e5a42348caf1c8dcea6dc49e30874806
BLAKE2b-256 96bad16f73ee2426ddb58bcf07743ae43db46b5c834e5980e447f73fa450f65e

See more details on using hashes here.

File details

Details for the file Yami-0.4.1-py3-none-any.whl.

File metadata

  • Download URL: Yami-0.4.1-py3-none-any.whl
  • Upload date:
  • Size: 46.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.13 CPython/3.8.2 Linux/5.13.0-1022-azure

File hashes

Hashes for Yami-0.4.1-py3-none-any.whl
Algorithm Hash digest
SHA256 6bf9848b6fde0fbdcdfe0b81a03bd69dad92899573ff66fe5288939bb04adf13
MD5 a5739c5404ee54793fc7b9be8f7e3647
BLAKE2b-256 f47b125ea930f0690d869cd379f342fb1b6db3cfeb0b7931090df14d938d1c19

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page