首页 > 解决方案 > helpme 命令,找不到作者的语音频道 discord.py

问题描述

您可以使用 !h 和聊天机器人类型(作者姓名、需要帮助、@staff 以及需要帮助的人在哪个语音频道中)我如何找到命令作者的语音频道?这就是我尝试过的:(我现在正在on_message活动中尝试)

@client.event
async def on_message(message):
    print(f'member is in {message.author.voice_channel}')

但是当我运行它并在聊天中输入一些东西时,我收到了这个错误:

Ignoring exception in on_message
Traceback (most recent call last):
  File "C:\Users\Ido Shaked\Desktop\citybot\venv\lib\site-packages\discord\client.py", line 333, in _run_event
    await coro(*args, **kwargs)
  File "C:/Users/Ido Shaked/Desktop/citybot/citycode.py", line 18, in on_message
    print(f'member is in {message.author.voice_channel}')
AttributeError: 'Member' object has no attribute 'voice_channel'

标签: pythondiscorddiscord.py

解决方案


该错误准确地告诉您出了什么问题 - aMember没有voice_channel属性。你必须通过message.author.voice.channel


推荐阅读