Skip to content

Type error in server.py #2

@DivyamChadha

Description

@DivyamChadha

Summary

Line 35 of server.py raises Type Error

Note: This is visible after applying fix for #1

Traceback

Task exception was never retrieved
future: <Task finished name='Task-8' coro=<WebsocketHandler.handle_event() done, defined at c:\Users\Divyam\Desktop\Revlot\revolt.py\revolt\websocket.py:57> exception=TypeError("'type' object is not subscriptable")>
Traceback (most recent call last):
  File "c:\Users\Divyam\Desktop\Revlot\revolt.py\revolt\websocket.py", line 66, in handle_event
    await func(payload)
  File "c:\Users\Divyam\Desktop\Revlot\revolt.py\revolt\websocket.py", line 76, in handle_ready
    self.state.add_server(server)
  File "c:\Users\Divyam\Desktop\Revlot\revolt.py\revolt\state.py", line 66, in add_server
    server = Server(payload, self)
  File "c:\Users\Divyam\Desktop\Revlot\revolt.py\revolt\server.py", line 35, in __init__
    channels = cast(list[Channel], list(filter(bool, [state.get_channel(channel_id) for channel_id in data["channels"]])))
TypeError: 'type' object is not subscriptable

Minimum reproducible code

import revolt
import asyncio
import aiohttp

class Client(revolt.Client):
    async def on_message(self, message: revolt.Message):
        if message.content == "hello":
            await message.channel.send("hi how are you")

async def main():
    async with aiohttp.ClientSession() as session:
        client = Client(session, "TOKEN")
        await client.start()

asyncio.run(main())

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions