【发布时间】:2021-05-31 23:51:43
【问题描述】:
我正在制作(高级)嵌入创建命令。基本上,您键入的任何内容都将显示为嵌入。长话短说,我告诉我的朋友测试它是否有任何错误。他尝试的第一件事是在不实际使用的情况下运行完全相同的命令。我的意思是什么?好吧,他只是输入了/createembed 大约 x 次。该机器人开始响应每个呼叫,并且基本上以垃圾邮件告终:
我认为现在更容易理解我的意思了。无论如何,我知道如何通过告诉机器人用户每个用户只能使用这个确切的命令一次来阻止这种情况?
@commands.command()
async def cad(self, ctx, channel : discord.TextChannel = None):
def check(message):
return message.author == ctx.author and message.channel == ctx.channel
aPP = ctx.author.avatar_url
if not channel:
await ctx.channel.send(f"**{ctx.author}** | Waiting for an Advanced Embed Title. If you wish to cancel this action, just type `Cancel`.")
title = await self.client.wait_for("message", check=check)
if title.content.lower() == "cancel" or title.content.upper() == "Cancel":
await ctx.channel.send(f'**{ctx.author}** | Action has been canceled.')
return
else:
await ctx.send(f"**{ctx.author}** | Waiting for an Advanced Embed Description. If you wish to cancel this action, just type `Cancel`.")
desc = await self.client.wait_for('message', check=check)
if desc.content.lower() == "cancel" or desc.content.upper() == "Cancel":
await ctx.channel.send(f'**{ctx.author}** | Action has been canceled.')
return
else:
await ctx.send(f"**{ctx.author}** | Waiting for an Advanced Embed Author Text. If you wish to skip this type `Skip` otherwise if you want to cancel this action, just type `Cancel`.")
authortext = await self.client.wait_for('message', check=check)
if authortext.content.lower() == "cancel" or authortext.content.upper() == "Cancel":
await ctx.channel.send(f'**{ctx.author}** | Action has been canceled.')
return
它有 500 多行,但基本上是一样的,有更多的回报等。
【问题讨论】:
-
如果没有您的任何代码,我们应该如何帮助您?
-
我只是在问这是否可能以及如何制作类似的东西。那我上传代码。一秒钟!
-
@ŁukaszKwieciński 编辑了答案。现在怎么样?
标签: python python-3.x discord.py