【发布时间】:2021-08-08 00:35:30
【问题描述】:
我制作了一个机器人,在不和谐上 ping @everyone 时会踢人,但问题是我收到了这个错误
NameError: name 'kick' is not defined
代码如下:
import discord
client = discord.Client()
@client.event
async def on_ready():
print('We have logged in as {0.user}'.format(client))
@client.event
async def on_message(message):
if message.author == client.user:
return
if message.content.startswith('@everyone'):
await kick(message.author,reason = "spam")
client.run('censored for obvious reasons')
【问题讨论】:
-
这能回答你的问题吗? How to kick users on command
-
不应该包含在discord库中吗?
-
我不确定为什么它会在全局命名空间中,因为您试图在此处引用它。你读过the documentation吗?
kick是Guild对象上可用的方法 - 这是您要使用的方法吗? -
哦,谢谢,我是新手
-
@JohnDoe 请检查下面的答案。这是最好的解释。