python - 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'
解决方案
该错误准确地告诉您出了什么问题 - aMember
没有voice_channel
属性。你必须通过message.author.voice.channel
推荐阅读
- visual-studio-code - VSCode 调试控制台不断跳到顶部
- python - 如何在基类中使用子类的函数属性?
- php - PHP多维数组按值排序
- ruby-on-rails - 获取关系计数的活动记录查询
- c# - SqlException:INSERT 语句与 FOREIGN KEY 约束“FK_Users_Companies_CompanyId”冲突
- sql - 如何根据psql中的一条记录的值排除具有相同ID的所有行?
- javascript - Zapier 自定义响应对象
- express - 无法使用 passport-jwt 访问受保护的路线
- tensorflow - 如何在 TensorFlow 中计算次梯度?
- scala - 为什么 Scala 强制使用 Await 而不是 Awaitable?