Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

语音频道退出时报错 #47

Open
huanxin996 opened this issue Dec 22, 2024 · 6 comments
Open

语音频道退出时报错 #47

huanxin996 opened this issue Dec 22, 2024 · 6 comments

Comments

@huanxin996
Copy link

12-22 20:57:39 [WARNING] Hx.bot | Discord | Unknown payload type: VOICE_CHANNEL_STATUS_UPDATE, detail: Dispatch(opcode=<Opcode.DISPATCH: 0>, data={'status': None, 'id': '1302631813478613065', 'guild_id': '1302631810332889158'}, sequence=190, type='VOICE_CHANNEL_STATUS_UPDATE')
12-22 20:57:39 [WARNING] Hx.bot | Discord | Failed to parse event Dispatch(opcode=<Opcode.DISPATCH: 0>, data={'status': None, 'id': '1302631813478613065', 'guild_id': '1302631810332889158'}, sequence=190, type='VOICE_CHANNEL_STATUS_UPDATE')
Traceback (most recent call last):

File "c:\Users\mcxia\Desktop\hx_discord\bot.py", line 34, in
nonebot.run()
│ └ <function run at 0x04D83970>
└ <module 'nonebot' from 'C:\Users\mcxia\Desktop\hx_discord\.venv\lib\site-packages\nonebot\init.py'>

File "C:\Users\mcxia\Desktop\hx_discord.venv\lib\site-packages\nonebot_init_.py", line 337, in run
get_driver().run(*args, **kwargs)
│ │ └ {}
│ └ ()
└ <function get_driver at 0x04736418>

File "C:\Users\mcxia\Desktop\hx_discord.venv\lib\site-packages\nonebot\drivers\none.py", line 61, in run
anyio.run(self._serve)
│ │ │ └ <function Driver._serve at 0x09B036A0>
│ │ └ Driver(type='none+aiohttp', adapters=1, bots=1)
│ └ <function run at 0x04736580>
└ <module 'anyio' from 'C:\Users\mcxia\Desktop\幻歆的项目\hx_discord\.venv\lib\site-packages\anyio\init.py'>

File "C:\Users\mcxia\Desktop\hx_discord.venv\lib\site-packages\anyio_core_eventloop.py", line 74, in run
return async_backend.run(func, args, {}, backend_options)
│ │ │ │ └ {}
│ │ │ └ ()
│ │ └ <bound method Driver._serve of Driver(type='none+aiohttp', adapters=1, bots=1)>
│ └ <classmethod(<function AsyncIOBackend.run at 0x0ACAD610>)>
└ <class 'anyio._backends._asyncio.AsyncIOBackend'>

File "C:\Users\mcxia\Desktop\hx_discord.venv\lib\site-packages\anyio_backends_asyncio.py", line 2284, in run
return runner.run(wrapper())
│ │ └ <function Driver._serve at 0x08876610>
│ └ <function Runner.run at 0x0AC9C388>
└ <anyio._backends._asyncio.Runner object at 0x0A4B2FE8>

File "C:\Users\mcxia\Desktop\hx_discord.venv\lib\site-packages\anyio_backends_asyncio.py", line 210, in run
return self._loop.run_until_complete(task)
│ │ │ └ <Task pending name='nonebot.drivers.none.Driver._serve' coro=<Driver._serve() running at C:\Users\mcxia\Desktop\hx_disc...
│ │ └ <function BaseEventLoop.run_until_complete at 0x041D62B0>
│ └
└ <anyio._backends._asyncio.Runner object at 0x0A4B2FE8>

File "C:\Users\mcxia\AppData\Local\Programs\Python\Python310-32\lib\asyncio\base_events.py", line 633, in run_until_complete
self.run_forever()
│ └ <function ProactorEventLoop.run_forever at 0x0421BF10>

File "C:\Users\mcxia\AppData\Local\Programs\Python\Python310-32\lib\asyncio\windows_events.py", line 321, in run_forever
super().run_forever()

File "C:\Users\mcxia\AppData\Local\Programs\Python\Python310-32\lib\asyncio\base_events.py", line 600, in run_forever
self._run_once()
│ └ <function BaseEventLoop._run_once at 0x041D7028>

File "C:\Users\mcxia\AppData\Local\Programs\Python\Python310-32\lib\asyncio\base_events.py", line 1896, in _run_once
handle._run()
│ └ <function Handle._run at 0x0418A580>
└ <Handle Task.task_wakeup()>

File "C:\Users\mcxia\AppData\Local\Programs\Python\Python310-32\lib\asyncio\events.py", line 80, in _run
self._context.run(self._callback, *self._args)
│ │ │ │ │ └ <member '_args' of 'Handle' objects>
│ │ │ │ └ <Handle Task.task_wakeup()>
│ │ │ └ <member '_callback' of 'Handle' objects>
│ │ └ <Handle Task.task_wakeup()>
│ └ <member '_context' of 'Handle' objects>
└ <Handle Task.task_wakeup()>

File "C:\Users\mcxia\Desktop\hx_discord.venv\lib\site-packages\nonebot\adapters\discord\adapter.py", line 213, in _forward_ws
await self._loop(bot, ws)
│ │ │ └ WebSocket('wss://gateway-us-east1-b.discord.gg')
│ │ └ Bot(type='Discord', self_id='1307426419504189550')
│ └ <function Adapter._loop at 0x09B28B20>
└ Adapter(name='Discord')

File "C:\Users\mcxia\Desktop\hx_discord.venv\lib\site-packages\nonebot\adapters\discord\adapter.py", line 384, in _loop
event = self.payload_to_event(payload)
│ │ └ Dispatch(opcode=<Opcode.DISPATCH: 0>, data={'status': None, 'id': '1302631813478613065', 'guild_id': '1302631810332889158'}, ...
│ └ <classmethod(<function Adapter.payload_to_event at 0x09B28BF8>)>
└ Adapter(name='Discord')

File "C:\Users\mcxia\Desktop\hx_discord.venv\lib\site-packages\nonebot\adapters\discord\adapter.py", line 445, in payload_to_event
event = type_validate_python(Event, payload.data)
│ │ │ └ {'status': None, 'id': '1302631813478613065', 'guild_id': '1302631810332889158'}
│ │ └ Dispatch(opcode=<Opcode.DISPATCH: 0>, data={'status': None, 'id': '1302631813478613065', 'guild_id': '1302631810332889158'}, ...
│ └ <class 'nonebot.adapters.discord.event.Event'>
└ <function type_validate_python at 0x047362F8>

File "C:\Users\mcxia\Desktop\hx_discord.venv\lib\site-packages\nonebot\compat.py", line 227, in type_validate_python
return TypeAdapter(type_).validate_python(data)
│ │ └ {'status': None, 'id': '1302631813478613065', 'guild_id': '1302631810332889158'}
│ └ <class 'nonebot.adapters.discord.event.Event'>
└ <class 'pydantic.type_adapter.TypeAdapter'>

File "C:\Users\mcxia\Desktop\hx_discord.venv\lib\site-packages\pydantic\type_adapter.py", line 144, in wrapped
return func(self, *args, **kwargs)
│ │ │ └ {}
│ │ └ ({'status': None, 'id': '1302631813478613065', 'guild_id': '1302631810332889158'},)
│ └ <pydantic.type_adapter.TypeAdapter object at 0x0AF32E38>
└ <function TypeAdapter.validate_python at 0x046D0730>

File "C:\Users\mcxia\Desktop\hx_discord.venv\lib\site-packages\pydantic\type_adapter.py", line 375, in validate_python
return self.validator.validate_python(object, strict=strict, from_attributes=from_attributes, context=context)
│ │ │ │ │ │ └ None
│ │ │ │ │ └ None
│ │ │ │ └ None
│ │ │ └ {'status': None, 'id': '1302631813478613065', 'guild_id': '1302631810332889158'}
│ │ └ <method 'validate_python' of 'pydantic_core._pydantic_core.SchemaValidator' objects>
│ └ SchemaValidator(title="Event", validator=Model(
│ ModelValidator {
│ revalidate: Never,
│ validator: ModelField...
└ <pydantic.type_adapter.TypeAdapter object at 0x0AF32E38>

TypeError: Can't instantiate abstract class Event with abstract method get_type

@Autuamn
Copy link
Contributor

Autuamn commented Dec 22, 2024

查了一下文档没有写这个 VOICE_CHANNEL_STATUS_UPDATE 事件呢。得等等官方文档更新。

顺便一提,仓库的主人已经消失好一会儿了。

Log

12-22 22:49:52 [TRACE] nonebot | Discord | Received payload: Dispatch(opcode=<Opcode.DISPATCH: 0>, data={'status': None, 'id': '1171294053384597618', 'guild_id': '1171294052839333910'}, sequence=7, type='VOICE_CHANNEL_STATUS_UPDATE')
12-22 22:49:52 [WARNING] nonebot | Discord | Unknown payload type: VOICE_CHANNEL_STATUS_UPDATE, detail: Dispatch(opcode=<Opcode.DISPATCH: 0>, data={'status': None, 'id': '1171294053384597618', 'guild_id': '1171294052839333910'}, sequence=7, type='VOICE_CHANNEL_STATUS_UPDATE')
12-22 22:49:52 [WARNING] nonebot | Discord | Failed to parse event Dispatch(opcode=<Opcode.DISPATCH: 0>, data={'status': None, 'id': '1171294053384597618', 'guild_id': '1171294052839333910'}, sequence=7, type='VOICE_CHANNEL_STATUS_UPDATE')
Traceback (most recent call last):
  File "D:\NoneBot\DiscordBot\bot.py", line 21, in <module>
    nonebot.run()
  File "D:\NoneBot\DiscordBot\.venv\Lib\site-packages\nonebot\__init__.py", line 335, in run
    get_driver().run(*args, **kwargs)
  File "D:\NoneBot\DiscordBot\.venv\Lib\site-packages\nonebot\drivers\fastapi.py", line 186, in run
    uvicorn.run(
  File "D:\NoneBot\DiscordBot\.venv\Lib\site-packages\uvicorn\main.py", line 577, in run
    server.run()
  File "D:\NoneBot\DiscordBot\.venv\Lib\site-packages\uvicorn\server.py", line 65, in run
    return asyncio.run(self.serve(sockets=sockets))
  File "C:\Program Files\Python312\Lib\asyncio\runners.py", line 194, in run
    return runner.run(main)
  File "C:\Program Files\Python312\Lib\asyncio\runners.py", line 118, in run
    return self._loop.run_until_complete(task)
  File "C:\Program Files\Python312\Lib\asyncio\base_events.py", line 651, in run_until_complete
    self.run_forever()
  File "C:\Program Files\Python312\Lib\asyncio\windows_events.py", line 321, in run_forever
    super().run_forever()
  File "C:\Program Files\Python312\Lib\asyncio\base_events.py", line 618, in run_forever
    self._run_once()
  File "C:\Program Files\Python312\Lib\asyncio\base_events.py", line 1951, in _run_once
    handle._run()
  File "C:\Program Files\Python312\Lib\asyncio\events.py", line 84, in _run
    self._context.run(self._callback, *self._args)
  File "D:\NoneBot\DiscordBot\.venv\Lib\site-packages\nonebot\adapters\discord\adapter.py", line 213, in _forward_ws
    await self._loop(bot, ws)
> File "D:\NoneBot\DiscordBot\.venv\Lib\site-packages\nonebot\adapters\discord\adapter.py", line 384, in _loop
    event = self.payload_to_event(payload)
  File "D:\NoneBot\DiscordBot\.venv\Lib\site-packages\nonebot\adapters\discord\adapter.py", line 445, in payload_to_event
    event = type_validate_python(Event, payload.data)
  File "D:\NoneBot\DiscordBot\.venv\Lib\site-packages\nonebot\compat.py", line 212, in type_validate_python
    return TypeAdapter(type_).validate_python(data)
  File "D:\NoneBot\DiscordBot\.venv\Lib\site-packages\pydantic\type_adapter.py", line 142, in wrapped
    return func(self, *args, **kwargs)
  File "D:\NoneBot\DiscordBot\.venv\Lib\site-packages\pydantic\type_adapter.py", line 373, in validate_python
    return self.validator.validate_python(object, strict=strict, from_attributes=from_attributes, context=context)
TypeError: Can't instantiate abstract class Event without an implementation for abstract method 'get_type'

@huanxin996
Copy link
Author

了解了,谢谢说明

@huanxin996
Copy link
Author

查了一下文档没有写这个 VOICE_CHANNEL_STATUS_UPDATE 事件呢。得等等官方文档更新。

顺便一提,仓库的主人已经消失好一会儿了。

Log

问一下大佬,网关的请求怎么发送,类似于使bot加入语音频道或者更改自身presence的方法,文档写的不是很明白

@Autuamn
Copy link
Contributor

Autuamn commented Dec 25, 2024

这个适配器好像没有实现发送 GateWay Event。

只定义了参数,没有实现发送接口。

Code

class RequestGuildMembers(BaseModel):
"""Request Guild Members Payload data
see https://discord.com/developers/docs/topics/gateway-events#request-guild-members
"""
guild_id: Snowflake
query: Missing[str] = UNSET
limit: int
presences: Missing[bool] = UNSET
user_ids: Missing[Union[Snowflake, list[Snowflake]]] = UNSET
nonce: Missing[str] = UNSET
class UpdateVoiceState(BaseModel):
"""Update Voice State Payload data
see https://discord.com/developers/docs/topics/gateway-events#update-voice-state"""
guild_id: Snowflake
channel_id: Optional[Snowflake] = Field(...)
self_mute: bool
self_deaf: bool
class UpdatePresence(BaseModel):
"""Update Presence Payload data
see https://discord.com/developers/docs/topics/gateway-events#update-presence"""
since: Optional[int] = Field(...)
activities: list["Activity"]
status: UpdatePresenceStatusType
afk: bool


@huanxin996
Copy link
Author

这个适配器好像没有实现发送 GateWay Event。

只定义了参数,没有实现发送接口。

Code

adapter-discord/nonebot/adapters/discord/api/model.py

Lines 2418 to 2451 in 5794c0b

class RequestGuildMembers(BaseModel):
"""Request Guild Members Payload data

 see https://discord.com/developers/docs/topics/gateway-events#request-guild-members 
 """ 

 guild_id: Snowflake 
 query: Missing[str] = UNSET 
 limit: int 
 presences: Missing[bool] = UNSET 
 user_ids: Missing[Union[Snowflake, list[Snowflake]]] = UNSET 
 nonce: Missing[str] = UNSET 

class UpdateVoiceState(BaseModel):
"""Update Voice State Payload data

 see https://discord.com/developers/docs/topics/gateway-events#update-voice-state""" 

 guild_id: Snowflake 
 channel_id: Optional[Snowflake] = Field(...) 
 self_mute: bool 
 self_deaf: bool 

class UpdatePresence(BaseModel):
"""Update Presence Payload data

 see https://discord.com/developers/docs/topics/gateway-events#update-presence""" 

 since: Optional[int] = Field(...) 
 activities: list["Activity"] 
 status: UpdatePresenceStatusType 
 afk: bool

应该是这样,我翻遍了这个适配器没有找到类似的方法
目前更换到discord官方的框架后已经实现这些方法(加入语音播放音频以及更改自身persence还有其他)
Image

@huanxin996
Copy link
Author

那目前好像是只能等仓库主人更新了,自己实在是看不懂网关的操作

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants