hikari-py/hikari

When I try to run hikari, it returns this error (yesterday it worked fine, today I didn't modify the code at all and when I ran it didn't work)

IdioticLuke opened this issue · 3 comments

Steps to reproduce

  1. Install Visual Studio Code + Python
  2. Set up virtual enviorment
  3. Make python file
  4. Install hikari and hikari-lightbulb
  5. Paste
import hikari
import lightbulb

bot = lightbulb.BotApp(
    token="tokensnotheresoIdontgetmybotkilled",
    intents= hikari.Intents.all
)

@bot.listen(hikari.StartedEvent)
async def started(event):
    print("bot has started")

@bot.command
@lightbulb.command("ping","says pong")
@lightbulb.implements(lightbulb.SlashCommand)
async def ping(ctx):
    await ctx.respond("pong!")

bot.run()

Expected result

Bot should've run and be able to do a slash command

Actual result

(env) PS D:\Important Program\DiscordBot> & "d:/Important Program/DiscordBot/env/Scripts/python.exe" "d:/Important Program/DiscordBot/bot.py"

  oooo         o8o  oooo                            o8o       å…‰ 2.0.0.dev112 [a02498e1]
  `888         `"'  `888                            `"'       © 2021-present davfsa - MIT license
   888 .oo.   oooo   888  oooo   .oooo.   oooo d8b oooo       interpreter:   CPython 3.10.8
   888P"Y88b  `888   888 .8P'   `P  )88b  `888""8P `888       running on:    AMD64 Windows 10
   888   888   888   888888.     .oP"888   888      888       installed at:  D:\Important Program\DiscordBot\env\lib\site-packages\hikari
   888   888   888   888 `88b.  d8(  888   888      888       documentation: https://hikari-py.dev/hikari
  o888o o888o o888o o888o o888o `Y888""8o d888b    o888o      support:       https://discord.gg/Jx4cNGG

Thank you for using lightbulb!
I 2022-11-15 20:30:03,725 hikari.bot: you can start 1000 sessions before the next window which starts at 2022-11-15 20:30:03.725538-05:00; planning to start 1 session... 
E 2022-11-15 20:30:03,876 hikari.gateway.0: encountered some unhandled error
Traceback (most recent call last):
  File "D:\Important Program\DiscordBot\env\lib\site-packages\hikari\impl\shard.py", line 874, in _keep_alive
    lifetime_tasks = await self._connect()
  File "D:\Important Program\DiscordBot\env\lib\site-packages\hikari\impl\shard.py", line 824, in _connect
    await self._send_json(
  File "D:\Important Program\DiscordBot\env\lib\site-packages\hikari\impl\shard.py", line 567, in _send_json
    await self._ws.send_json(data)
  File "D:\Important Program\DiscordBot\env\lib\site-packages\hikari\impl\shard.py", line 196, in send_json
    pl = data_binding.dump_json(data)
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.2288.0_x64__qbz5n2kfra8p0\lib\json\__init__.py", line 231, in dumps
    return _default_encoder.encode(obj)
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.2288.0_x64__qbz5n2kfra8p0\lib\json\encoder.py", line 199, in encode
    chunks = self.iterencode(o, _one_shot=True)
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.2288.0_x64__qbz5n2kfra8p0\lib\json\encoder.py", line 257, in iterencode
    return _iterencode(o, 0)
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.2288.0_x64__qbz5n2kfra8p0\lib\json\encoder.py", line 179, in default
    raise TypeError(f'Object of type {o.__class__.__name__} '
TypeError: Object of type function is not JSON serializable
I 2022-11-15 20:30:04,177 hikari.bot: bot requested to shut down
I 2022-11-15 20:30:04,178 hikari.bot: bot shut down successfully
I 2022-11-15 20:30:04,179 hikari.bot: successfully terminated
Traceback (most recent call last):
  File "d:\Important Program\DiscordBot\bot.py", line 19, in <module>
    bot.run()
  File "D:\Important Program\DiscordBot\env\lib\site-packages\hikari\impl\bot.py", line 783, in run
    loop.run_until_complete(
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.2288.0_x64__qbz5n2kfra8p0\lib\asyncio\base_events.py", line 649, in run_until_complete
    return future.result()
  File "D:\Important Program\DiscordBot\env\lib\site-packages\hikari\impl\bot.py", line 968, in start
    await aio.first_completed(self._closing_event.wait(), gather)
  File "D:\Important Program\DiscordBot\env\lib\site-packages\hikari\internal\aio.py", line 137, in first_completed
    await next(iterator)
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.2288.0_x64__qbz5n2kfra8p0\lib\asyncio\tasks.py", line 571, in _wait_for_one
    return f.result()  # May raise f.exception().
  File "D:\Important Program\DiscordBot\env\lib\site-packages\hikari\impl\bot.py", line 1257, in _start_one_shard
    await new_shard.start()
  File "D:\Important Program\DiscordBot\env\lib\site-packages\hikari\impl\shard.py", line 624, in start
    await aio.first_completed(self._handshake_event.wait(), asyncio.shield(keep_alive_task))
  File "D:\Important Program\DiscordBot\env\lib\site-packages\hikari\internal\aio.py", line 137, in first_completed
    await next(iterator)
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.2288.0_x64__qbz5n2kfra8p0\lib\asyncio\tasks.py", line 571, in _wait_for_one
    return f.result()  # May raise f.exception().
  File "D:\Important Program\DiscordBot\env\lib\site-packages\hikari\impl\shard.py", line 874, in _keep_alive
    lifetime_tasks = await self._connect()
  File "D:\Important Program\DiscordBot\env\lib\site-packages\hikari\impl\shard.py", line 824, in _connect
    await self._send_json(
  File "D:\Important Program\DiscordBot\env\lib\site-packages\hikari\impl\shard.py", line 567, in _send_json
    await self._ws.send_json(data)
  File "D:\Important Program\DiscordBot\env\lib\site-packages\hikari\impl\shard.py", line 196, in send_json
    pl = data_binding.dump_json(data)
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.2288.0_x64__qbz5n2kfra8p0\lib\json\__init__.py", line 231, in dumps
    return _default_encoder.encode(obj)
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.2288.0_x64__qbz5n2kfra8p0\lib\json\encoder.py", line 199, in encode
    chunks = self.iterencode(o, _one_shot=True)
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.2288.0_x64__qbz5n2kfra8p0\lib\json\encoder.py", line 257, in iterencode
    return _iterencode(o, 0)
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.2288.0_x64__qbz5n2kfra8p0\lib\json\encoder.py", line 179, in default
    raise TypeError(f'Object of type {o.__class__.__name__} '
TypeError: Object of type function is not JSON serializable
E 2022-11-15 20:30:04,223 asyncio: Task exception was never retrieved
future: <Task finished name='heartbeat (shard 0)' coro=<GatewayShardImpl._heartbeat() done, defined at D:\Important Program\DiscordBot\env\lib\site-packages\hikari\impl\shard.py:675> exception=AssertionError()>
Traceback (most recent call last):
  File "D:\Important Program\DiscordBot\env\lib\site-packages\hikari\impl\shard.py", line 690, in _heartbeat
    await self._send_heartbeat()
  File "D:\Important Program\DiscordBot\env\lib\site-packages\hikari\impl\shard.py", line 672, in _send_heartbeat
    await self._send_json({_OP: _HEARTBEAT, _D: self._seq}, priority=True)
  File "D:\Important Program\DiscordBot\env\lib\site-packages\hikari\impl\shard.py", line 566, in _send_json
    assert self._ws is not None
AssertionError
E 2022-11-15 20:30:04,225 asyncio: Task exception was never retrieved
future: <Task finished name='poll events (shard 0)' coro=<GatewayShardImpl._poll_events() done, defined at D:\Important Program\DiscordBot\env\lib\site-packages\hikari\impl\shard.py:694> exception=AssertionError()>
Traceback (most recent call last):
  File "D:\Important Program\DiscordBot\env\lib\site-packages\hikari\impl\shard.py", line 695, in _poll_events
    assert self._ws is not

System info

hikari (2.0.0.dev112) [a02498e1]
located at D:\Important Program\DiscordBot\env\lib\site-packages\hikari
CPython 3.10.8 MSC v.1933 64 bit (AMD64)
Windows DESKTOP-CGUU963 10 10.0.19044 AMD64 Intel64 Family 6 Model 158 Stepping 10, GenuineIntel

Further info

No response

Checklist

  • I have made sure to remove ANY sensitive information (bot token, passwords, credentials, personal details, etc.).
  • I have searched the issue tracker and have made sure it's not a duplicate. If it is a follow up of another issue, I have specified it.

Can confirm this bug ^

NVM it's a typo in your code, nothing to do with hikari.

The specific part is hikari.Intents.all should be hikari.Intents.ALL

This is just a typo leading to a nasty error because you ended up passing a function as the intents. Will close as NAB