python - 使用 python 断开用户(不和谐机器人)
问题描述
我试图发出一个断开用户连接的命令,但不明白为什么它会给我这个错误:'Client' object has no attribute 'command'(这只是机器人代码的一部分)
@client.command
async def leave(ctx, member : discord.Member):
await discord.Member.disconnect()
if msg.startswith("$kick."):
users = message.guild.members
count = 6
name = ""
while count < len(message.content):
name = name + str(message.content[count])
count = count + 1
#till here we just got the name
x = 0
while x > id.member_count:
if name == users[x]:
leave('was kicked',user[x])
break
解决方案
你忘了()
后面@client.command
。将其更改为@client.command()
推荐阅读
- mongodb - 从数组聚合中删除元素
- java - ANTL4 语法编译 Nullpointer 异常
- ios - 在一台设备上绘图以在另一台设备上可见
- java - 如何使用 Spring Data ReactiveElasticsearch 进行源过滤?
- javascript - 为什么A按钮有效而B无效?
- google-bigquery - LEFT JOIN 丢弃结果中的左行?
- javascript - Angular Pagination:显示一组 A4 大小的页面
- ionic-framework - 当我尝试使用 adnroid studio 构建项目时,清单合并失败
- mule - 在 Anypoint Studio 7 中,在调试模式下运行的应用程序不会在切换断点处停止
- ios - 使用 CocoaPods 和 SwiftPM 复制符号