Discord 当我用';是';什么都没发生?
这是我目前的代码:Discord 当我用';是';什么都没发生?,discord,discord.py,warnings,Discord,Discord.py,Warnings,这是我目前的代码: @commands.command() async def destroy(self, ctx): def check(m): em = discord.Embed() return em.author == ctx.author and m.channel == ctx.channl await ctx.message.delete() em = discord
@commands.command()
async def destroy(self, ctx):
def check(m):
em = discord.Embed()
return em.author == ctx.author and m.channel == ctx.channl
await ctx.message.delete()
em = discord.Embed(color=15859772, title = ":rotating_light: WARNING WARNING :rotating_light:", description=f"{ctx.author.mention} Are you sure you want to run this command? yes/no")
await ctx.send(embed=em)
# for user input
response = await self.client.wait_for('message', check=check)
if response.content.lower() == 'yes':
await ctx.send("Done")
else:
await ctx.send("Canceled")
不知道出了什么问题。但是如果我回答“是”,则不会发送任何内容,也不会收到任何错误?您的
检查对我来说毫无意义。你为什么要在里面放一个嵌入式设备
试试这个:
def检查(m):
返回m.author==ctx.author和m.channel==ctx.message.channel
这将检查命令的作者是否在正确的通道中响应
如评论中所述,以下代码对我来说很好:
@client.command()#使用client.wait#等待
异步def销毁(ctx):
def检查(m):
返回m.author==ctx.author和m.channel==ctx.message.channel
等待ctx.message.delete()
em=discord.Embed(color=15859772,title=“:旋转_灯:警告:旋转_灯:”,
description=f“{ctx.author.antify}确实要运行此命令吗?是/否”)
等待ctx.send(嵌入=em)
#供用户输入
响应=等待客户端。等待('消息',检查=检查)
如果response.content.lower()
等待ctx发送(“完成”)
其他:
等待ctx发送(“取消”)
如果您仍然有错误,我假设您使用的是命令。command
方式错误/定义错误。您的检查对我来说毫无意义。你为什么要在里面放一个嵌入式设备
试试这个:
def检查(m):
返回m.author==ctx.author和m.channel==ctx.message.channel
这将检查命令的作者是否在正确的通道中响应
如评论中所述,以下代码对我来说很好:
@client.command()#使用client.wait#等待
异步def销毁(ctx):
def检查(m):
返回m.author==ctx.author和m.channel==ctx.message.channel
等待ctx.message.delete()
em=discord.Embed(color=15859772,title=“:旋转_灯:警告:旋转_灯:”,
description=f“{ctx.author.antify}确实要运行此命令吗?是/否”)
等待ctx.send(嵌入=em)
#供用户输入
响应=等待客户端。等待('消息',检查=检查)
如果response.content.lower()
等待ctx发送(“完成”)
其他:
等待ctx发送(“取消”)
如果您仍然有错误,我假设您使用的是命令。command
方式错误/定义错误。什么是ctx.channl
?什么是ctx.channl
?我已经尝试过了,但仍然存在相同的问题。没有self.client。请等待。试一下client.wait
。我还是用client.command
,所以我猜你定义错了。不起作用了
=?我已经试过了,但还是一样的问题。没有self.client.wait
。试试client。等一下。我还是用client.command,所以我猜你定义错了。不行吗?