Hikari

raw JSON →
2.5.0 verified Mon Apr 27 auth: no python

Hikari is an asyncio-native Discord API wrapper for Python 3.10+ (Python 3.14 compatible via <3.15 constraint). As of v2.5.0, it provides both REST and gateway (WebSocket) APIs with a model-first design. The library replaces the older lightbulb command framework with first-class interaction support. Breaking changes between 2.x minor versions mainly involve gateway event handling and model attribute casing.

pip install hikari
error ImportError: cannot import name 'GatewayBot' from 'hikari'
cause Attempting to import from 'hikari' directly in an older version where the classes were in 'hikari.impl'.
fix
Ensure you have hikari>=2.0.0 installed: pip install hikari --upgrade
error TypeError: object NoneType can't be used in 'await' expression (attempting to use lambda)
cause Passing a lambda as event handler to bot.listen() in hikari>=2.5.0, which requires a coroutine function.
fix
Replace the lambda with an async function.
breaking GatewayBot.listen() no longer accepts a lambda as the event handler in v2.5. Use an async function or a callable class.
fix Use an async function or a callable class that can be awaited.
breaking Cache configuration has changed in v2.5.0: the cache is now passed via the 'cache' parameter of GatewayBot or RESTBot, not via a separate component.
fix Move cache configuration from a cache component to the GatewayBot constructor, e.g., bot = GatewayBot(token=..., cache=hikari.CacheSettings(...)).
deprecated hikari.Message.mention field is deprecated, use hikari.Message.user_mentions or hikari.Message.role_mention_ids.
fix Replace .mention with .user_mentions for user mentions or .role_mention_ids for role mentions.
gotcha RESTBot and GatewayBot require aiohttp session management; do not create multiple sessions without closing previous ones (resource leak).
fix Use the bot as a context manager (async with bot:) or call bot.close() on shutdown.
pip install hikari[server] hikari[toolbox]

Simple bot that responds to !ping with Pong! using GatewayBot.

import asyncio
import os
import hikari

bot = hikari.GatewayBot(token=os.environ.get('DISCORD_TOKEN', ''))

@bot.listen()
async def on_message(event: hikari.events.MessageCreateEvent) -> None:
    if event.content and event.content.startswith('!ping'):
        await event.message.respond('Pong!')

if __name__ == '__main__':
    bot.run()