Giter VIP home page Giter VIP logo

yami's Introduction

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

✔️ 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)
❌ 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.

yami's People

Contributors

dependabot[bot] avatar jonxslays avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

yami's Issues

Loading a single module fails

Describe the bug
A clear and concise description of what the bug is.

yami.exceptions.ModuleLoadException: Cannot load '<property object at 0x7ff945ccc860>' - it is already loaded

Somethings up here.

To Reproduce
Steps to reproduce the behavior:
A minimal reproduction script that can reproduce the bug.

bot.load_module("Jaxtar", "bot_tests/mods/my_mod.py")

Expected behavior
A clear and concise description of what you expected to happen.

The module should load.

System Information:
Yami v0.3.0 @ /home/jonx/projects/Yami/yami
CPython 3.10.0 GCC 11.1.0
Linux love 5.10.85-1-lts #1 SMP Tue, 14 Dec 2021 18:50:52 +0000 x86_64

Additional context
Add any other context about the problem here.

What to do?

I want to help to yami project, but I dont know what i should actually do. May be someone has features or todos, that need to be done. If you have smething for dummies(for me) it will be perfect!

MissingArgs raised when TypeError raised during command invocation

Describe the bug
yami.exceptions.MissingArgs was raised when a TypeError was raised during a command invocation

error

To Reproduce
Raise TypeError in a command (although I had an actual mistake in this case)

Expected behavior
Not really sure 😅

System Information:

Yami v0.3.0.post0 [HEAD]
@ some_stuff\.venv\lib\site-packages\yami
CPython 3.10.1 MSC v.1929 64 bit (AMD64)
Windows DESKTOP-6HI8J39 10 AMD64
10.0.22000

Additional context
None

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.