The functions and lightbulb extensions every Libre Bot shares: configuration, the hub connection, translations, guild reporting, languages, privacy, command mentions and application emojis. It is a toolbox, not a framework. A bot calls it from its own start-up code, and nothing in it runs unless the bot names it.
pip install librebots-kitA bot's own emojis are PNG or GIF files in one folder of its package, such as src/starboard/assets/emojis/, each
named with 2 to 23 of a-z, 0-9 and _, such as star.png. ApplicationEmojis finds an emoji by that file stem,
so the bot never names an id, which differs between the test bot and the real one.
The set-up step makes the application's emojis match the folder. It creates new and changed ones and then deletes every other application emoji, including any added by hand in the developer portal:
EMOJIS = Path(__file__).parent / "assets" / "emojis"
await ApplicationEmojis(rest).sync(await rest.fetch_application(), EMOJIS)The running bot registers it for lightbulb's dependency injection and loads the emojis once at start, before the
shards connect. Given the folder, load logs a warning naming each file the application has no emoji for:
emojis = ApplicationEmojis(bot.rest)
registry.register_value(ApplicationEmojis, emojis)
async def load_emojis(_: hikari.StartingEvent) -> None:
await emojis.load(await bot.rest.fetch_application(), EMOJIS)
bot.subscribe(hikari.StartingEvent, load_emojis)emojis.markup("star") gives the emoji for message text and emojis.emoji("star") the hikari.KnownCustomEmoji for
buttons and select options. Without such an emoji they give "" and None, so a reply still goes out.
You need mise.
mise installmake lint: ruff, pyright andactionlintmake test: the tests
A maintainer runs release in the Actions tab on main and chooses patch, minor or major, optionally as a
release candidate. The run publishes the package to PyPI.