Giter Club home page Giter Club logo

revolt.py's Introduction

Revolt.py

An async library to interact with the https://revolt.chat API.

You can join the support server here and find the library's documentation here.

Installing

You can use pip to install revolt.py. It differs slightly depending on what OS/Distro you use.

On Windows

py -m pip install -U revolt.py # -U to update

On macOS and Linux

python3 -m pip install -U revolt.py

Example

More examples can be found in the examples folder.

import revolt
import asyncio

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 revolt.utils.client_session() as session:
        client = Client(session, "BOT TOKEN HERE")
        await client.start()

asyncio.run(main())

revolt.py's People

Contributors

achxy avatar byemc avatar cominatyou avatar divyamchadha avatar drokeye avatar higherorderlogic avatar iamtomahawkx avatar lightsage avatar meizuflux avatar mysticmia avatar nixonjoshua98 avatar null8626 avatar ombucha avatar rexogamer avatar sniff122 avatar thebobbobs avatar zomatree avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

revolt.py's Issues

Message.edit() does not let you use None to clear a message's content

Describe the bug
Unlike member.edit() where you can reset someone's username by passing None, you can't clear a message's content by editing it using None.

To Reproduce

await message.edit(content=None, embeds=embed)

Expected behavior
Expected message content to clear. This did not happen, however.

Library version
0.1.11

Additional context
This is likely caused by the following code:

def edit_message(self, channel: str, message: str, content: Optional[str], embeds: Optional[list[SendableEmbedPayload]] = None) -> Request[None]:
    json = {}

    if content is not None:
        json["content"] = content

Instead of setting the default to and checking for revolt.utils.Missing, it sets/checks it None. This means you can't un-set something by passing the None argument because it'll be filtered out as 'default' argument.

feature request: New example for Cogs

Something along the lines of this, perhaps?

import revolt
from revolt.ext import commands

class TestCog(commands.Cog):
    @commands.command()
    async def ping(self, ctx: commands.Context):
        await ctx.send("pong")

class Client(commands.CommandsClient):
    async def get_prefix(self, message: revolt.Message):
        return "!"
    
async def main():
    async with revolt.utils.client_session() as session:
        client = Client(session, "BOT TOKEN HERE")
        client.add_cog(TestCog()) # initialize your custom cog
        await client.start()

asyncio.run(main())

Type error in types\role.py

Summary

Line 5 in types/role.py raises Type Error

Traceback

Traceback (most recent call last):
  File "c:/Users/Divyam/Desktop/Revlot/revolt.py/test.py", line 1, in <module>
    import revolt
  File "c:\Users\Divyam\Desktop\Revlot\revolt.py\revolt\__init__.py", line 3, in <module>
    from .client import Client
  File "c:\Users\Divyam\Desktop\Revlot\revolt.py\revolt\client.py", line 10, in <module>
    from .websocket import WebsocketHandler
  File "c:\Users\Divyam\Desktop\Revlot\revolt.py\revolt\websocket.py", line 7, in <module>
    from .types import Message as MessagePayload
  File "c:\Users\Divyam\Desktop\Revlot\revolt.py\revolt\types\__init__.py", line 8, in <module>
    from .role import *
  File "c:\Users\Divyam\Desktop\Revlot\revolt.py\revolt\types\role.py", line 5, in <module>
    Permission = tuple[int, int]
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())

`commands.IntConverter` Gives an Error

Describe the bug
When you try to use IntConverter() you get the following error.
TypeError: int() argument must be a string, a bytes-like object or a real number, not 'Context'

To Reproduce

@commands.command(name='randomnum')
    async def randomnum(ctx, num1, num2):

        randomcalc = randint(commands.IntConverter(num1), commands.IntConverter(num2))
        await ctx.message.channel.send(str(randomcalc))

Expected behavior
Instead of an error, the function should return an int value.

Library version

Name: revolt.py
Version: 0.1.8
Summary: Python wrapper for the revolt.chat API
Home-page: https://github.com/revoltchat/revolt.py
Author: Zomatee
Author-email: [email protected]
License: MIT
Location: c:\users\lee\appdata\local\programs\python\python310\lib\site-packages
Requires: aenum, aiohttp, typing-extensions, ulid-py

Role cache not populated properly for roles created during the lifetime of the client.

Describe the bug

When creating a role whilst the client is running, the internal cache does not populate.

To Reproduce

# MRC
import revolt, asyncio, aiohttp, logging

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


asyncio.run(main())
  1. Run the script.
  2. Create a role.
  3. Add the role to a user.
  4. Delete the role.

Expected behaviour

Role cache gets populated correctly with the newly created role.

Actual behaviour

The role does not seem to be in the cache. Actions involving this role will raise a KeyError:

When adding this newly-created role to the user

ERROR:asyncio:Task exception was never retrieved
future: <Task finished name='Task-13' coro=<WebsocketHandler.handle_event() done, defined at <...>\site-packages\revolt\websocket.py:89> exception=KeyError('01GWEX938P16Z2JM5MGYGXN841')>
Traceback (most recent call last):
  File "<...>\site-packages\revolt\websocket.py", line 101, in handle_event
    await func(payload)
  File "<...>\site-packages\revolt\websocket.py", line 289, in handle_servermemberupdate
    member._update(**payload["data"])
  File "<...>\site-packages\revolt\member.py", line 85, in _update
    member_roles = [self.server.get_role(role_id) for role_id in roles]
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<...>\site-packages\revolt\member.py", line 85, in <listcomp>
    member_roles = [self.server.get_role(role_id) for role_id in roles]
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<...>\site-packages\revolt\server.py", line 192, in get_role
    return self._roles[role_id]
           ~~~~~~~~~~~^^^^^^^^^
KeyError: '01GWEX938P16Z2JM5MGYGXN841'

When deleting the role

ERROR:asyncio:Task exception was never retrieved
future: <Task finished name='Task-15' coro=<WebsocketHandler.handle_event() done, defined at <...>\site-packages\revolt\websocket.py:89> exception=KeyError('01GWEX938P16Z2JM5MGYGXN841')>
Traceback (most recent call last):
  File "<...>\site-packages\revolt\websocket.py", line 101, in handle_event
    await func(payload)
  File "<...>\site-packages\revolt\websocket.py", line 331, in handle_serverroledelete
    role = server._roles.pop(payload["role_id"])
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
KeyError: '01GWEX938P16Z2JM5MGYGXN841'

Library version

0.1.10

Can also be reproduced when installing directly from the repository.

User._update() does not update display_name changes (crash)

Describe the bug
I believe this error comes from a client event of someone hanging their username, and the bot trying to edit data in its cache.

Traceback (most recent call last):
  File "/home/container/.local/lib/python3.11/site-packages/revolt/websocket.py", line 113, in handle_event
    await func(payload)
  File "/home/container/.local/lib/python3.11/site-packages/revolt/websocket.py", line 378, in handle_userupdate
    user._update(**payload["data"])
TypeError: User._update() got an unexpected keyword argument 'display_name'

To Reproduce
Probably happens on any client..

Expected behavior
Expected no error (and the cache to be updated accordingly)

Library version
0.1.11

AttributeError: module 'ulid' has no attribute 'new'

Traceback (most recent call last):
  File "/home/lain/.local/lib/python3.10/site-packages/revolt/ext/commands/command.py", line 73, in invoke
    return await self.callback(self.cog or context.client, context, *args, **kwargs)
  File "/mnt/c/Users/Lain/Desktop/Developer/revocat/cogs/test.py", line 9, in test
    await ctx.send("test")
  File "/home/lain/.local/lib/python3.10/site-packages/revolt/messageable.py", line 62, in send
    message = await self.state.http.send_message(await self._get_channel_id(), content, embed_payload, attachments, reply_payload, masquerade_payload)
  File "/home/lain/.local/lib/python3.10/site-packages/revolt/http.py", line 140, in send_message
    return await self.request("POST", f"/channels/{channel}/messages", json=json)
  File "/home/lain/.local/lib/python3.10/site-packages/revolt/http.py", line 68, in request
    json["nonce"] = ulid.new().str # type: ignore
AttributeError: module 'ulid' has no attribute 'new'

trying to use a command gives me this error

Example Bot is not working

Describe the bug
The default Bot example does not work. I installed everything like it has to be

To Reproduce

  • create a virtualenv
  • install revolt.py
  • paste in the example Bot
  • Start the bot

Expected behavior
!hello should force the bot to respond with "hi how are you"

Screenshots
image

Error:

python.exe c:/Users/MB/Documents/PythonBots/revoltchat/test/main.py
Task exception was never retrieved
future: <Task finished name='Task-15' coro=<Client.on_message() done, defined at c:\Users\MB\Documents\PythonBots\revoltchat\test\main.py:6> exception=TypeError("object str can't be used in 'await' expression")>
Traceback (most recent call last):
  File "c:\Users\MB\Documents\PythonBots\revoltchat\test\main.py", line 8, in on_message
    await message.channel.send("hi how are you")
  File "C:\Users\MB\Documents\PythonBots\revoltchat\test\env\lib\site-packages\revolt\messageable.py", line 60, in send   
    message = await self.state.http.send_message(await self._get_channel_id(), content, embed_payload, attachments, reply_payload, masquerade_payload)
TypeError: object str can't be used in 'await' expression

Library version
Access this info via pip show revolt.py
0.1.6

Additional context
Add any other context about the problem here.

Server.members cache not properly populated for users who join during client lifetime

Describe the bug

When a member joins a server whilst the client is running, the internal cache does not populate.

To Reproduce

Pre-requisites: 1 friend.

  1. Run the client with logging enabled.
  2. Ask a friend to join your server.

Expected behaviour

Server.members cache gets populated correctly with the new member.

Actual behaviour

The role does not seem to be in the cache. Actions involving this role will raise a LookupError:

2023-03-27 01:03:06 ERROR    asyncio Task exception was never retrieved
future: <Task finished name='Task-10' coro=<WebsocketHandler.handle_event() done, defined at ...\site-packages\revolt\websocket.py:92> exception=LookupError()>
Traceback (most recent call last):
  File "...\site-packages\revolt\websocket.py", line 103, in handle_event
    await func(payload)
  File "...\site-packages\revolt\websocket.py", line 296, in handle_servermemberjoin
    member = self.state.add_member(payload["id"], MemberPayload(_id=MemberIDPayload(server=payload["id"], user=payload["user"]), joined_at=int(time.time())))  # revolt doesnt give us the joined at time
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "...\site-packages\revolt\state.py", line 68, in add_member  
    member = Member(payload, server, self)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "...\site-packages\revolt\member.py", line 38, in __init__   
    user = state.get_user(data["_id"]["user"])
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "...\site-packages\revolt\state.py", line 43, in get_user    
    raise LookupError from None
LookupError

Library version

df9893a

Error while starting

When i try to start my bot with the code from the git I'm getting this error.
image

message.remove_reaction does not remove reactions

Describe the bug
Using message.remove_reaction(...) does not remove the reaction as expected.

To Reproduce
await ctx.message.remove_reaction(emoji_id, user)

No code output.

Expected behavior
Expected it to remove the reaction of the given user (me, in this case). It instead didn't remove any reaction, not even the bot's own one.

Library version
0.1.11

Potential fix
I noticed a couple issues in the message.state.http.remove_reaction function.

  1. The function does not use the user_id and remove_all parameters
  2. The request does not give any params arguments, while it could put the user_id and remove_all parameters in here.
  3. The function uses a PUT request instead of DELETE

I managed to find a workaround / fix for this issue by calling my own request:

m = ctx.message
await m.state.http.request("DELETE", f"/channels/{m.channel.id}/messages/{m.id}/reactions/{emoji_id}", params={"user_id":user.id})

Bot returns error when command is ran in new server

Describe the bug
While a bot is online, if it joins a server and someone tries to run a command the bot returns an error.

To Reproduce

  1. Run your Revolt bot.
  2. Add it to a server
  3. Try to run a command
Task exception was never retrieved
future: <Task finished name='Task-11' coro=<WebsocketHandler.handle_event() done, defined at %USERPROFILE%\AppData\Local\Programs\Python\Python310\lib\site-packages\revolt\websocket.py:82> exception=KeyError('01G66YXP70EPXFFF0Q8RP9RBSW')>
Traceback (most recent call last):
  File "%USERPROFILE%\AppData\Local\Programs\Python\Python310\lib\site-packages\revolt\websocket.py", line 94, in handle_event
    await func(payload)
  File "%USERPROFILE%\AppData\Local\Programs\Python\Python310\lib\site-packages\revolt\websocket.py", line 185, in handle_channelstarttyping       
    channel = self.state.get_channel(payload["id"])
  File "%USERPROFILE%\AppData\Local\Programs\Python\Python310\lib\site-packages\revolt\state.py", line 45, in get_channel
    return self.channels[id]
KeyError: '01G66YXP70EPXFFF0Q8RP9RBSW'
Task exception was never retrieved
future: <Task finished name='Task-12' coro=<WebsocketHandler.handle_event() done, defined at %USERPROFILE%\AppData\Local\Programs\Python\Python310\lib\site-packages\revolt\websocket.py:82> exception=KeyError('01G66YXP70EPXFFF0Q8RP9RBSW')>
Traceback (most recent call last):
  File "%USERPROFILE%\AppData\Local\Programs\Python\Python310\lib\site-packages\revolt\websocket.py", line 94, in handle_event
    await func(payload)
  File "%USERPROFILE%\AppData\Local\Programs\Python\Python310\lib\site-packages\revolt\websocket.py", line 191, in handle_channelstoptyping        
    channel = self.state.get_channel(payload["id"])
  File "%USERPROFILE%\AppData\Local\Programs\Python\Python310\lib\site-packages\revolt\state.py", line 45, in get_channel
    return self.channels[id]
KeyError: '01G66YXP70EPXFFF0Q8RP9RBSW'
Task exception was never retrieved
future: <Task finished name='Task-13' coro=<WebsocketHandler.handle_event() done, defined at %USERPROFILE%\AppData\Local\Programs\Python\Python310\lib\site-packages\revolt\websocket.py:82> exception=KeyError('01G66YXP70EPXFFF0Q8RP9RBSW')>
Traceback (most recent call last):
  File "%USERPROFILE%\AppData\Local\Programs\Python\Python310\lib\site-packages\revolt\websocket.py", line 94, in handle_event
    await func(payload)
  File "%USERPROFILE%\AppData\Local\Programs\Python\Python310\lib\site-packages\revolt\websocket.py", line 185, in handle_channelstarttyping       
    channel = self.state.get_channel(payload["id"])
  File "%USERPROFILE%\AppData\Local\Programs\Python\Python310\lib\site-packages\revolt\state.py", line 45, in get_channel
    return self.channels[id]
KeyError: '01G66YXP70EPXFFF0Q8RP9RBSW'
Task exception was never retrieved
future: <Task finished name='Task-14' coro=<WebsocketHandler.handle_event() done, defined at %USERPROFILE%\AppData\Local\Programs\Python\Python310\lib\site-packages\revolt\websocket.py:82> exception=KeyError('01G66YXP70EPXFFF0Q8RP9RBSW')>
Traceback (most recent call last):
  File "%USERPROFILE%\AppData\Local\Programs\Python\Python310\lib\site-packages\revolt\websocket.py", line 94, in handle_event
    await func(payload)
  File "%USERPROFILE%\AppData\Local\Programs\Python\Python310\lib\site-packages\revolt\websocket.py", line 191, in handle_channelstoptyping        
    channel = self.state.get_channel(payload["id"])
  File "%USERPROFILE%\AppData\Local\Programs\Python\Python310\lib\site-packages\revolt\state.py", line 45, in get_channel
    return self.channels[id]
KeyError: '01G66YXP70EPXFFF0Q8RP9RBSW'
Task exception was never retrieved
future: <Task finished name='Task-15' coro=<WebsocketHandler.handle_event() done, defined at %USERPROFILE%\AppData\Local\Programs\Python\Python310\lib\site-packages\revolt\websocket.py:82> exception=KeyError('01G66YXP70EPXFFF0Q8RP9RBSW')>
Traceback (most recent call last):
  File "%USERPROFILE%\AppData\Local\Programs\Python\Python310\lib\site-packages\revolt\websocket.py", line 94, in handle_event
    await func(payload)
  File "%USERPROFILE%\AppData\Local\Programs\Python\Python310\lib\site-packages\revolt\websocket.py", line 185, in handle_channelstarttyping       
    channel = self.state.get_channel(payload["id"])
  File "%USERPROFILE%\AppData\Local\Programs\Python\Python310\lib\site-packages\revolt\state.py", line 45, in get_channel
    return self.channels[id]
KeyError: '01G66YXP70EPXFFF0Q8RP9RBSW'
Task exception was never retrieved
future: <Task finished name='Task-16' coro=<WebsocketHandler.handle_event() done, defined at %USERPROFILE%\AppData\Local\Programs\Python\Python310\lib\site-packages\revolt\websocket.py:82> exception=KeyError('01FHGJ3NPP7XANQQH8C2BE44ZY')>
Traceback (most recent call last):
  File "%USERPROFILE%\AppData\Local\Programs\Python\Python310\lib\site-packages\revolt\websocket.py", line 94, in handle_event
    await func(payload)
  File "%USERPROFILE%\AppData\Local\Programs\Python\Python310\lib\site-packages\revolt\websocket.py", line 267, in handle_userupdate
    user = self.state.get_user(payload["id"])
  File "%USERPROFILE%\AppData\Local\Programs\Python\Python310\lib\site-packages\revolt\state.py", line 38, in get_user
    return self.users[id]
KeyError: '01FHGJ3NPP7XANQQH8C2BE44ZY'
Task exception was never retrieved
future: <Task finished name='Task-17' coro=<WebsocketHandler.handle_event() done, defined at %USERPROFILE%\AppData\Local\Programs\Python\Python310\lib\site-packages\revolt\websocket.py:82> exception=KeyError('01G66YXP70EPXFFF0Q8RP9RBSW')>
Traceback (most recent call last):
  File "%USERPROFILE%\AppData\Local\Programs\Python\Python310\lib\site-packages\revolt\websocket.py", line 94, in handle_event
    await func(payload)
  File "%USERPROFILE%\AppData\Local\Programs\Python\Python310\lib\site-packages\revolt\websocket.py", line 185, in handle_channelstarttyping       
    channel = self.state.get_channel(payload["id"])
  File "%USERPROFILE%\AppData\Local\Programs\Python\Python310\lib\site-packages\revolt\state.py", line 45, in get_channel
    return self.channels[id]
KeyError: '01G66YXP70EPXFFF0Q8RP9RBSW'
Task exception was never retrieved
future: <Task finished name='Task-18' coro=<WebsocketHandler.handle_event() done, defined at %USERPROFILE%\AppData\Local\Programs\Python\Python310\lib\site-packages\revolt\websocket.py:82> exception=KeyError('01G66YXP70EPXFFF0Q8RP9RBSW')>
Traceback (most recent call last):
  File "%USERPROFILE%\AppData\Local\Programs\Python\Python310\lib\site-packages\revolt\websocket.py", line 94, in handle_event
    await func(payload)
  File "%USERPROFILE%\AppData\Local\Programs\Python\Python310\lib\site-packages\revolt\websocket.py", line 191, in handle_channelstoptyping        
    channel = self.state.get_channel(payload["id"])
  File "%USERPROFILE%\AppData\Local\Programs\Python\Python310\lib\site-packages\revolt\state.py", line 45, in get_channel
    return self.channels[id]
KeyError: '01G66YXP70EPXFFF0Q8RP9RBSW'
Task exception was never retrieved
future: <Task finished name='Task-19' coro=<WebsocketHandler.handle_event() done, defined at %USERPROFILE%\AppData\Local\Programs\Python\Python310\lib\site-packages\revolt\websocket.py:82> exception=KeyError('01G66YXP70EPXFFF0Q8RP9RBSW')>
Traceback (most recent call last):
  File "%USERPROFILE%\AppData\Local\Programs\Python\Python310\lib\site-packages\revolt\websocket.py", line 94, in handle_event
    await func(payload)
  File "%USERPROFILE%\AppData\Local\Programs\Python\Python310\lib\site-packages\revolt\websocket.py", line 185, in handle_channelstarttyping       
    channel = self.state.get_channel(payload["id"])
  File "%USERPROFILE%\AppData\Local\Programs\Python\Python310\lib\site-packages\revolt\state.py", line 45, in get_channel
    return self.channels[id]
KeyError: '01G66YXP70EPXFFF0Q8RP9RBSW'
Task exception was never retrieved
future: <Task finished name='Task-20' coro=<WebsocketHandler.handle_event() done, defined at %USERPROFILE%\AppData\Local\Programs\Python\Python310\lib\site-packages\revolt\websocket.py:82> exception=KeyError('01G66YXP70EPXFFF0Q8RP9RBSW')>
Traceback (most recent call last):
  File "%USERPROFILE%\AppData\Local\Programs\Python\Python310\lib\site-packages\revolt\websocket.py", line 94, in handle_event
    await func(payload)
  File "%USERPROFILE%\AppData\Local\Programs\Python\Python310\lib\site-packages\revolt\websocket.py", line 185, in handle_channelstarttyping       
    channel = self.state.get_channel(payload["id"])
  File "%USERPROFILE%\AppData\Local\Programs\Python\Python310\lib\site-packages\revolt\state.py", line 45, in get_channel
    return self.channels[id]
KeyError: '01G66YXP70EPXFFF0Q8RP9RBSW'
Task exception was never retrieved
future: <Task finished name='Task-21' coro=<WebsocketHandler.handle_event() done, defined at %USERPROFILE%\AppData\Local\Programs\Python\Python310\lib\site-packages\revolt\websocket.py:82> exception=KeyError('01G66YXP70EPXFFF0Q8RP9RBSW')>
Traceback (most recent call last):
  File "%USERPROFILE%\AppData\Local\Programs\Python\Python310\lib\site-packages\revolt\websocket.py", line 94, in handle_event
    await func(payload)
  File "%USERPROFILE%\AppData\Local\Programs\Python\Python310\lib\site-packages\revolt\websocket.py", line 191, in handle_channelstoptyping        
    channel = self.state.get_channel(payload["id"])
  File "%USERPROFILE%\AppData\Local\Programs\Python\Python310\lib\site-packages\revolt\state.py", line 45, in get_channel
    return self.channels[id]
KeyError: '01G66YXP70EPXFFF0Q8RP9RBSW'
Task exception was never retrieved
future: <Task finished name='Task-22' coro=<WebsocketHandler.handle_event() done, defined at %USERPROFILE%\AppData\Local\Programs\Python\Python310\lib\site-packages\revolt\websocket.py:82> exception=KeyError('01G66YXP70EPXFFF0Q8RP9RBSW')>
Traceback (most recent call last):
  File "%USERPROFILE%\AppData\Local\Programs\Python\Python310\lib\site-packages\revolt\websocket.py", line 94, in handle_event
    await func(payload)
  File "%USERPROFILE%\AppData\Local\Programs\Python\Python310\lib\site-packages\revolt\websocket.py", line 185, in handle_channelstarttyping       
    channel = self.state.get_channel(payload["id"])
  File "%USERPROFILE%\AppData\Local\Programs\Python\Python310\lib\site-packages\revolt\state.py", line 45, in get_channel
    return self.channels[id]
KeyError: '01G66YXP70EPXFFF0Q8RP9RBSW'
Task exception was never retrieved
future: <Task finished name='Task-23' coro=<WebsocketHandler.handle_event() done, defined at %USERPROFILE%\AppData\Local\Programs\Python\Python310\lib\site-packages\revolt\websocket.py:82> exception=KeyError('01G66YXP70EPXFFF0Q8RP9RBSW')>
Traceback (most recent call last):
  File "%USERPROFILE%\AppData\Local\Programs\Python\Python310\lib\site-packages\revolt\websocket.py", line 94, in handle_event
    await func(payload)
  File "%USERPROFILE%\AppData\Local\Programs\Python\Python310\lib\site-packages\revolt\websocket.py", line 191, in handle_channelstoptyping        
    channel = self.state.get_channel(payload["id"])
  File "%USERPROFILE%\AppData\Local\Programs\Python\Python310\lib\site-packages\revolt\state.py", line 45, in get_channel
    return self.channels[id]
KeyError: '01G66YXP70EPXFFF0Q8RP9RBSW'
Task exception was never retrieved
future: <Task finished name='Task-24' coro=<WebsocketHandler.handle_event() done, defined at %USERPROFILE%\AppData\Local\Programs\Python\Python310\lib\site-packages\revolt\websocket.py:82> exception=KeyError('01G66YXP70EPXFFF0Q8RP9RBSW')>
Traceback (most recent call last):
  File "%USERPROFILE%\AppData\Local\Programs\Python\Python310\lib\site-packages\revolt\websocket.py", line 94, in handle_event
    await func(payload)
  File "%USERPROFILE%\AppData\Local\Programs\Python\Python310\lib\site-packages\revolt\websocket.py", line 122, in handle_message
    message = self.state.add_message(cast(MessagePayload, payload))
  File "%USERPROFILE%\AppData\Local\Programs\Python\Python310\lib\site-packages\revolt\state.py", line 73, in add_message
    message = Message(payload, self)
  File "%USERPROFILE%\AppData\Local\Programs\Python\Python310\lib\site-packages\revolt\message.py", line 62, in __init__
    channel = state.get_channel(data["channel"])
  File "%USERPROFILE%\AppData\Local\Programs\Python\Python310\lib\site-packages\revolt\state.py", line 45, in get_channel
    return self.channels[id]
KeyError: '01G66YXP70EPXFFF0Q8RP9RBSW'

Expected behavior
The bot should execute the command as usual.

Library version

Name: revolt.py
Version: 0.1.8
Summary: Python wrapper for the revolt.chat API
Home-page: https://github.com/revoltchat/revolt.py
Author: Zomatee
Author-email: [email protected]
License: MIT
Location: c:\users\lee\appdata\local\programs\python\python310\lib\site-packages
Requires: aenum, aiohttp, typing-extensions, ulid-py
Required-by:

why i cant turn on bot?

Describe the bug
A clear and concise description of what the bug is.

i cant turn on bot with screenshot's msg

To Reproduce
A small code snippet showing the error

import asyncio
import aiohttp
from bot import TOKEN, commandInt

import revolt


class Client(revolt.Client):
    async def on_message(self, message: revolt.Message):
        msg = None
        if message.content[0] == commandInt:
            msg = message.content[1:]
        if msg == "hello":
            await message.channel.send("wow")

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

asyncio.run(main())

Expected behavior
A clear and concise description of what you expected to happen.

Screenshots
If applicable, add screenshots to help explain your problem.

แ„‰แ…ณแ„แ…ณแ„…แ…ตแ†ซแ„‰แ…ฃแ†บ 2021-09-03 แ„‹แ…ฉแ„’แ…ฎ 2 03 49

Library version
Access this info via pip show revolt.py

latest(download from github)

Additional context
Add any other context about the problem here.

Whenever a channel is created while the bot is on, you get an error

Describe the bug
Whenever the bot is running, if somebody makes a text channel you get an error.

To Reproduce

  1. Run your bot
  2. Create a text channel in a Revolt server with your bot in it
Task exception was never retrieved
future: <Task finished name='Task-12' coro=<WebsocketHandler.handle_event() done, defined at C:\Users\%USERNAME%\AppData\Local\Programs\Python\Python310\lib\site-packages\revolt\websocket.py:82> exception=TypeError("Server._update() got an unexpected keyword argument 'channels'")>
Traceback (most recent call last):
  File "C:\Users\l%USERNAME%\AppData\Local\Programs\Python\Python310\lib\site-packages\revolt\websocket.py", line 94, in handle_event
    await func(payload)
  File "C:\Users\l%USERNAME%\AppData\Local\Programs\Python\Python310\lib\site-packages\revolt\websocket.py", line 201, in handle_serverupdate
    server._update(**payload["data"])
TypeError: Server._update() got an unexpected keyword argument 'channels'

Expected behavior
The bot shouldn't send an error message just because somebody created a text channel.

Library version

Name: revolt.py
Version: 0.1.8
Summary: Python wrapper for the revolt.chat API
Home-page: https://github.com/revoltchat/revolt.py
Author: Zomatee
Author-email: [email protected]
License: MIT
Location: c:\users\lee\appdata\local\programs\python\python310\lib\site-packages
Requires: aenum, aiohttp, typing-extensions, ulid-py
Required-by:

`TextChannel.last_message` always gives `LookupError`

Describe the bug
When attempting to use TextChannel.last_message you always get LookupError

To Reproduce

  1. Create a Command
  2. Inside of that command add await ctx.send(TextChannel.last_message.content)

Expected behavior
It should just return the last message in a channel as long there is one.

Library version

Name: revolt.py
Version: 0.1.8
Summary: Python wrapper for the revolt.chat API
Home-page: https://github.com/revoltchat/revolt.py
Author: Zomatee
Author-email: [email protected]
License: MIT
Location: c:\users\lee\appdata\local\programs\python\python310\lib\site-packages
Requires: aenum, aiohttp, typing-extensions, ulid-py
Required-by:

Channel.server raises IndexError

Describe the bug
Using the on_message event for direct messages raises IndexError because in a direct message is no server/server_id available

To Reproduce
Create a command or trigger in the on_message event that response sth in chat.

Expected behavior
Bot should respond in direct message

Screenshots

Library version

Name: revolt.py
Version: 0.1.10
Summary: Python wrapper for the revolt.chat API
Home-page: 
Author: 
Author-email: Zomatree <[email protected]>
License: 
Location: c:\users\ma\documents\pythonbots\revolt\delivery\env\lib\site-packages
Requires: aenum, aiohttp, typing-extensions, ulid-py
Required-by:

Additional context

  • I will fix this

Message Update called twice

Describe the bug
If both message update listeners are written. on_raw_message_update gets also called when on_message_update "could" handle it

To Reproduce

async def on_message_update(self, message: revolt.Message):

async def on_raw_message_update(self, payload: MessageUpdateEventPayload):

Expected behavior
Only on_message_update should be called

Library version
0.1.11

Not work lb

image

import revolt
import asyncio

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

async def main():
    async with revolt.utils.client_session() as session:
        client = Client(session, "MY TOKEN HIDDEN")
        await client.start()

asyncio.run(main())

library not work

Message fails to construct when sent from a group channel

Describe the bug
__init__ of class Message fails when the message is sent from a group channel. The message attempts to get the server from the state but since the group channel does not belong to a server it fails with a KeyError.

To Reproduce

import asyncio
import aiohttp
import revolt

class Client(revolt.Client):

    async def on_message(self, message: revolt.Message):
        ...

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

asyncio.run(main())

Traceback

Task exception was never retrieved
future: <Task finished name='Task-15' coro=<WebsocketHandler.handle_event() done, defined at /Users/divyamchadha/Documents/Projects/Revolt/revolt/websocket.py:70> exception=KeyError('')>
Traceback (most recent call last):
  File "/Users/divyamchadha/Documents/Projects/Revolt/revolt/websocket.py", line 79, in handle_event
    await func(payload)
  File "/Users/divyamchadha/Documents/Projects/Revolt/revolt/websocket.py", line 103, in handle_message
    message = self.state.add_message(cast(MessagePayload, payload))
  File "/Users/divyamchadha/Documents/Projects/Revolt/revolt/state.py", line 73, in add_message
    message = Message(payload, self)
  File "/Users/divyamchadha/Documents/Projects/Revolt/revolt/message.py", line 59, in __init__
    self.server = self.channel and self.channel.server
  File "/Users/divyamchadha/Documents/Projects/Revolt/revolt/channel.py", line 46, in server
    return self.state.get_server(self.server_id)
  File "/Users/divyamchadha/Documents/Projects/Revolt/revolt/state.py", line 48, in get_server
    return self.servers[id]
KeyError: ''

Library version
Commit 77fa908

Mentioning an out-of-server user gives a crash in revolt.websocket.handle_message

Describe the bug
If a member mentions a user that isn't in cache (the crash happens in DMs too, apparently), it crashes. This is especially an issue if the bot sends a message mentioning a user that isn't in the cache, specifically an out-of-serverm user, because then this crash causes the current function to stop.

To Reproduce

@commands.command()
async def ban(ctx, member_id):
    # assuming the given member_id is a member that isn't in the bot's cache- not being in any of the user's servers.
    # <@01234567890123456789012345> works/crashes too
    print("First print statement")
    await ctx.send(f"<\@{ctx.author.id}> _banned_ <@{member_id}>")
    print("Second print statement")

Expected behavior
I expected to see "Second print statement" being printed in console, but this didn't happen due to it crashing.

Traceback

Traceback (most recent call last):
  File "C:\Users\Mia\AppData\Local\Programs\Python\Lib\site-packages\revolt\ext\commands\command.py", line 80, in invoke
    return await self.callback(self.cog or context.client, context, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Mia\Documents\GitHub\uncute-rina-revolt\cmd_moderation.py", line 43, in ban
    await log_channel.send(f":hammer: <\@{ctx.author.id}> _banned_ out-of-server user [`{member_id}`, <@{member_id}>]" +
  File "C:\Users\Mia\AppData\Local\Programs\Python\Lib\site-packages\revolt\messageable.py", line 68, in send
    return self.state.add_message(message)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Mia\AppData\Local\Programs\Python\Lib\site-packages\revolt\state.py", line 92, in add_message
    message = Message(payload, self)
              ^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Mia\AppData\Local\Programs\Python\Lib\site-packages\revolt\message.py", line 88, in __init__
    self.mentions = [self.server.get_member(member_id) for member_id in data.get("mentions", [])]
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Mia\AppData\Local\Programs\Python\Lib\site-packages\revolt\message.py", line 88, in <listcomp>
    self.mentions = [self.server.get_member(member_id) for member_id in data.get("mentions", [])]
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Mia\AppData\Local\Programs\Python\Lib\site-packages\revolt\server.py", line 243, in get_member
    raise LookupError from None
LookupError

Task exception was never retrieved
future: <Task finished name='Task-40' coro=<WebsocketHandler.handle_event() done, defined at C:\Users\Mia\AppData\Local\Programs\Python\Lib\site-packages\revolt\websocket.py:103> exception=LookupError()>
Traceback (most recent call last):
  File "C:\Users\Mia\AppData\Local\Programs\Python\Lib\site-packages\revolt\websocket.py", line 115, in handle_event
    await func(payload)
  File "C:\Users\Mia\AppData\Local\Programs\Python\Lib\site-packages\revolt\websocket.py", line 152, in handle_message
    message = self.state.add_message(cast(MessagePayload, payload))
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Mia\AppData\Local\Programs\Python\Lib\site-packages\revolt\state.py", line 92, in add_message
    message = Message(payload, self)
              ^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Mia\AppData\Local\Programs\Python\Lib\site-packages\revolt\message.py", line 88, in __init__
    self.mentions = [self.server.get_member(member_id) for member_id in data.get("mentions", [])]
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Mia\AppData\Local\Programs\Python\Lib\site-packages\revolt\message.py", line 88, in <listcomp>
    self.mentions = [self.server.get_member(member_id) for member_id in data.get("mentions", [])]
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Mia\AppData\Local\Programs\Python\Lib\site-packages\revolt\server.py", line 243, in get_member
    raise LookupError from None
LookupError

Note how there are 2 crashes: 1 for my bot's function sending a message with an out-of-server member that tries to return the sent message, and one for the handle_message event that tries to add the message to cache. Both have the same error source though.

Library version
Version 0.1.11 commit 5ee3c60 (most recent GitHub version)

Additional context
The crash resulting in the discontinuation of your function can be caught by catching the LookupError, but you will still get a crash for the handle_event()

A command framework?

I was wondering if you'll include a command framework extension with the library in the future (simillar to discord.py's ext.commands) or you plan to leave that upto the end user to implement.

When using exit(), you get an error

Describe the bug
When using the exit() function you get an error. (Note that the function still works, it just gives you an error)

To Reproduce

  1. Create a Command
  2. In the function for the command, add exit()
  3. Use the command in Revolt
Task exception was never retrieved
future: <Task finished name='Task-14' coro=<Client.on_message() done, defined at c:\Users\%USERNAME%\Desktop\Coding\Python\LeeBot\%USERNAME%bot.py:9> exception=SystemExit(None)>
Traceback (most recent call last):
  File "C:\Users\%USERNAME%\AppData\Local\Programs\Python\Python310\lib\asyncio\runners.py", line 44, in run
    return loop.run_until_complete(main)
  File "C:\Users\%USERNAME%\AppData\Local\Programs\Python\Python310\lib\asyncio\base_events.py", line 633, in run_until_complete
    self.run_forever()
  File "C:\Users\%USERNAME%\AppData\Local\Programs\Python\Python310\lib\asyncio\windows_events.py", line 321, in run_forever
    super().run_forever()
  File "C:\Users\%USERNAME%\AppData\Local\Programs\Python\Python310\lib\asyncio\base_events.py", line 600, in run_forever
    self._run_once()
  File "C:\Users\%USERNAME%\AppData\Local\Programs\Python\Python310\lib\asyncio\base_events.py", line 1896, in _run_once
    handle._run()
  File "C:\Users\%USERNAME%\AppData\Local\Programs\Python\Python310\lib\asyncio\events.py", line 80, in _run
    self._context.run(self._callback, *self._args)
  File "c:\Users\%USERNAME%\Desktop\Coding\Python\LeeBot\%USERNAME%bot.py", line 12, in on_message
    await Client.process_commands(self, message=message)
  File "C:\Users\%USERNAME%\AppData\Local\Programs\Python\Python310\lib\site-packages\revolt\ext\commands\client.py", line 226, in process_commands
    output = await context.invoke()
  File "C:\Users\%USERNAME%\AppData\Local\Programs\Python\Python310\lib\site-packages\revolt\ext\commands\context.py", line 88, in invoke
    return await command.invoke(self, *self.args, **self.kwargs)
  File "C:\Users\%USERNAME%\AppData\Local\Programs\Python\Python310\lib\site-packages\revolt\ext\commands\command.py", line 73, in invoke
    return await self.callback(self.cog or context.client, context, *args, **kwargs)
  File "c:\Users\%USERNAME%\Desktop\Coding\Python\LeeBot\%USERNAME%bot.py", line 95, in shutdown
    exit()
  File "C:\Users\%USERNAME%\AppData\Local\Programs\Python\Python310\lib\_sitebuiltins.py", line 26, in __call__
    raise SystemExit(code)
SystemExit: None
Exception ignored in: <function _ProactorBasePipeTransport.__del__ at 0x0000020B07CFCB80>
Traceback (most recent call last):
  File "C:\Users\%USERNAME%\AppData\Local\Programs\Python\Python310\lib\asyncio\proactor_events.py", line 116, in __del__
    self.close()
  File "C:\Users\%USERNAME%\AppData\Local\Programs\Python\Python310\lib\asyncio\proactor_events.py", line 108, in close
    self._loop.call_soon(self._call_connection_lost, None)
  File "C:\Users\%USERNAME%\AppData\Local\Programs\Python\Python310\lib\asyncio\base_events.py", line 750, in call_soon
    self._check_closed()
  File "C:\Users\%USERNAME%\AppData\Local\Programs\Python\Python310\lib\asyncio\base_events.py", line 515, in _check_closed
    raise RuntimeError('Event loop is closed')
RuntimeError: Event loop is closed
Exception ignored in: <function _ProactorBasePipeTransport.__del__ at 0x0000020B07CFCB80>
Traceback (most recent call last):
  File "C:\Users\%USERNAME%\AppData\Local\Programs\Python\Python310\lib\asyncio\proactor_events.py", line 116, in __del__
    self.close()
  File "C:\Users\%USERNAME%\AppData\Local\Programs\Python\Python310\lib\asyncio\proactor_events.py", line 108, in close
    self._loop.call_soon(self._call_connection_lost, None)
  File "C:\Users\%USERNAME%\AppData\Local\Programs\Python\Python310\lib\asyncio\base_events.py", line 750, in call_soon
    self._check_closed()
  File "C:\Users\%USERNAME%\AppData\Local\Programs\Python\Python310\lib\asyncio\base_events.py", line 515, in _check_closed
    raise RuntimeError('Event loop is closed')
RuntimeError: Event loop is closed

Expected behavior
The python script should stop.

Library version

Name: revolt.py
Version: 0.1.8
Summary: Python wrapper for the revolt.chat API
Home-page: https://github.com/revoltchat/revolt.py
Author: Zomatee
Author-email: [email protected]
License: MIT
Location: c:\users\lee\appdata\local\programs\python\python310\lib\site-packages
Requires: aenum, aiohttp, typing-extensions, ulid-py
Required-by:

Additional context
For anybody that doesn't know, the exit() function force stops your python script.

Wont run on python 3.12.2

Describe the bug
A clear and concise description of what the bug is.

revolt.py refuses to install when using python 3.12.2 for some odd reason, as aiohttp and yarn both decide to not want to build themselves

To Reproduce
A small code snippet showing the error

import revolt, json
import asyncio

with open("json/config.json") as f:
    config = json.load(f)

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 revolt.utils.client_session() as session:
        client = Client(session, config['TOKEN'])
        await client.start()

asyncio.run(main())

Expected behavior
A clear and concise description of what you expected to happen.

Meant to install revolt.py

Screenshots
If applicable, add screenshots to help explain your problem.
image

Library version
Access this info via pip show revolt.py
latest

Additional context
Add any other context about the problem here.

๐Ÿ› Import error due to http import

../../../miniconda3/envs/dev311/lib/python3.11/site-packages/revolt/init.py:5: in
from .client import *
../../../miniconda3/envs/dev311/lib/python3.11/site-packages/revolt/client.py:11: in
from .http import HttpClient


from __future__ import annotations

from typing import (TYPE_CHECKING, Any, Coroutine, Literal, Optional, TypeVar,
                    Union, overload)

import aiohttp
import ulid

from .errors import Forbidden, HTTPError, ServerError
E ImportError: cannot import name 'Forbidden' from 'revolt.errors' (/Users/eridu/miniconda3/envs/dev311/lib/python3.11/site-packages/revolt/errors/init.py)

../../../miniconda3/envs/dev311/lib/python3.11/site-packages/revolt/http.py:9: ImportError

http.py seems to not be importing the RevoltError which might be the issue.

await server.fetch_member() gives crash

Describe the bug

Relevant info:

if TYPE_CHECKING:
    from .member import Member

class Server(Ulid):
    ...
    async def fetch_member(self, member_id: str) -> Member:
        ...
        return Member(payload, self, self.state)

NameError: name 'Member' is not defined
It's trying to create a Member but it can't because it's only defined when type checking, and not for actual .. actions I guess
It's the same issue as was a problem for client.fetch_emojis and users and servers etc.

To Reproduce

@commands.command()
async def command(self, ctx: commands.Context, member_id: str):
    await ctx.server.fetch_member(member_id)

Expected behavior
Expected to get a member returned
Actually got a NameError crash instead.

Library version
version 0.1.11 commit 2749822 (latest github commit)

Occasional Errors thrown for some reason?

Describe the bug
Lookup errors thrown on events I am not aware of using.

ie: User Updates when a user updates their displayname in settings.
image

To Reproduce:

Traceback (most recent call last):
  File "revolt\websocket.py", line 113, in handle_event
  File "revolt\websocket.py", line 378, in handle_userupdate
TypeError: User._update() got an unexpected keyword argument 'display_name'
Task exception was never retrieved
future: <Task finished name='Task-13845' coro=<WebsocketHandler.handle_event() done, defin
ed at revolt\websocket.py:102> exception=LookupError()>
Traceback (most recent call last):
  File "revolt\websocket.py", line 113, in handle_event
  File "revolt\websocket.py", line 147, in handle_message
  File "revolt\state.py", line 92, in add_message
  File "revolt\message.py", line 88, in __init__
  File "revolt\state.py", line 49, in get_member
  File "revolt\server.py", line 213, in get_member
LookupError
Task exception was never retrieved
future: <Task finished name='Task-14899' coro=<WebsocketHandler.handle_event() done, defin
ed at revolt\websocket.py:102> exception=TypeError("User._update() got an unexpected keywo
rd argument 'username'")>
Traceback (most recent call last):
  File "revolt\websocket.py", line 113, in handle_event
  File "revolt\websocket.py", line 378, in handle_userupdate
TypeError: User._update() got an unexpected keyword argument 'username'
Task exception was never retrieved
future: <Task finished name='Task-15658' coro=<WebsocketHandler.handle_event() done, defin
ed at revolt\websocket.py:102> exception=TypeError("User._update() got an unexpected keywo
rd argument 'username'")>

Expected behavior
A clear and concise description of what you expected to happen.

Screenshots
If applicable, add screenshots to help explain your problem.
image

Library version
Access this info via pip show revolt.py
image

Additional context
Add any other context about the problem here.
Source Code:

https://github.com/Akrasio/Ahni-Revolt/blob/revolt.py/index.py

how to join to voice channel

im trying to create music bot on python and i have issue
how to connect to voice channel, or how to get voicechannel object
in discord.py i can just do this: ctx.author.voice

Type error in server.py

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())

revolt.Server.fetch_bans() has docstring for server invites

Describe the bug

 async def fetch_bans(self) -> list[ServerBan]:
        """Fetches all invites in the server

        Returns
        --------
        list[:class:`Invite`]
        """
        payload = await self.state.http.fetch_bans(self.id)

        return [ServerBan(ban, self.state) for ban in payload["bans"]]

has "Fetches all invites" for "fetch_bans"

Library version
0.1.11 (latest from GitHub)

revolt.py not working on python 3.12 because dependency aiohttp==3.8.* does not support python 3.12

Describe the bug
When trying to pip install revolt.py on a machine with Python 3.12.*, we eventually see the following error:

Failed to build aiohttp
ERROR: Could not build wheels for aiohttp, which is required to install pyproject.toml-based projects

Looking around, I found aiohttp's issue #7739, which describes the same problem. However, according to this comment on that same issue, this has been fixed in aiohttp=3.9.*

Looking at revolt.py's pyproject.toml file, one of the project's dependencies is aiohttp==3.8.*, which means that revolt.py will never build in python 3.12.

To Reproduce

  1. Use Python 3.12 as your interpreter.
  2. Try to install revolt.py via pip install revolt.py

Expected behavior
Revolt.py successfully installs

Library version
n/a

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.