oooo o8o oooo o8o © 2020 Nekokatt, licensed under MIT
`888 `"' `888 `"' Installed at: /home/nekokatt/code/hikari/hikari
888 .oo. oooo 888 oooo .oooo. oooo d8b oooo Support: https://discord.gg/Jx4cNGG
888P"Y88b `888 888 .8P' `P )88b `888""8P `888 Documentation: https://nekokatt.gitlab.io/hikari
888 888 888 888888. .oP"888 888 888
888 888 888 888 `88b. d8( 888 888 888 CPython 3.8.5
o888o o888o o888o o888o o888o `Y888""8o d888b o888o compiled with GCC 10.1.0 (default May 17 2020 18:15:42)
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔ glibc 2.31 on Linux 64bit ELF
v2.0.0
I 2020-07-15 16:45:11,476 hikari: single-sharded configuration -- you have started 29/1000 sessions prior to connecting (resets at 16/07/20 11:38:05 BST)
I 2020-07-15 16:45:11,779 hikari.gateway.0: received HELLO, heartbeat interval is 41.25s
I 2020-07-15 16:45:11,958 hikari.gateway.0: shard is ready [session:1aa5f3fde733687ae7b41b1b55b29792, user_id:572144340277919754, tag:hikari#5863]
^C
Terminated 13897
[nekokatt@pc ~/hikari ] $ cat bot.py
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import asyncio
import functools
import os
import hikari
bot = hikari.Bot(token=os.environ["BOT_TOKEN"])
def command(name):
def decorator(fn):
@functools.wraps(fn)
async def wrapper(event):
if not event.message.author.is_bot and event.message.content.startswith(name):
await fn(event)
return wrapper
return decorator
@bot.listen()
@command("hk.ping")
async def ping(event: hikari.MessageCreateEvent) -> None:
await event.message.reply("Pong!")
@bot.listen()
@command("hk.add")
async def add_numbers(event: hikari.MessageCreateEvent) -> None:
def is_number_check(e):
return (
event.message.author == e.message.author
and event.message.channel_id == e.message.channel_id
and e.message.content.isdigit()
)
try:
await event.message.reply("Please enter the first number")
e1 = await bot.wait_for(hikari.MessageCreateEvent, predicate=is_number_check, timeout=30)
await event.message.reply("Please enter the second number")
e2 = await bot.wait_for(hikari.MessageCreateEvent, predicate=is_number_check, timeout=30)
except asyncio.TimeoutError:
await event.message.reply("You took too long...")
else:
val1 = int(e1.message.content)
val2 = int(e2.message.content)
embed = hikari.Embed(title="Result!", description=f"{val1} + {val2} = {val1 + val2}", color="#3f3")
await event.message.reply(embed=embed)
bot.run()
pip install --pre
hikari
A new, powerful, static-typed Python API for writing Discord bots.
This API is still in a alpha state, and is a work in progress! Features may change
or undergo improvements before the design is finalized. Until then, why not join our Discord? Feel free
to drop in to ask questions, get updates on progress, and be able to provide valuable contributions and
feedback.
Tutorials, tips, and additional resources will come soon!
Slide into our server