Type error in server.py #2

Closed
opened 2026-02-15 23:16:10 -05:00 by yindo · 1 comment
Owner

Originally created by @DivyamChadha on GitHub (Aug 31, 2021).

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())
Originally created by @DivyamChadha on GitHub (Aug 31, 2021). ## Summary [Line 35](https://github.com/Zomatree/revolt.py/blob/cdda2e6d7db1d76112df74da800c0fbc3af0960e/revolt/server.py#L35) 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 ```py 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()) ```
yindo closed this issue 2026-02-15 23:16:10 -05:00
Author
Owner

@Zomatree commented on GitHub (Aug 31, 2021):

Python 3.9 is the minimum supported version.

@Zomatree commented on GitHub (Aug 31, 2021): Python 3.9 is the minimum supported version.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: stoatchat/python-client-sdk#2