PUG 创建命令没有响应



所以我需要检测一个链接,但我不确定如何检测。打印的错误是";属性错误:"str"对象没有属性"send"。

@bot.command()
async def create(ctx):
embed1 = discord.Embed()
embed1.add_field(name="To start, send your vip link.", value="**__MUST__ be a roblox football fusion link, sending any other link will result in a 48h mute, as well as a loss of your PUG Host role.**", inline=True)
url = 'http[s]?://(?:[a-zA-Z]|[0-9]|[$-_@.&+]|[!*(),]|(?:%[0-9a-fA-F][0-9a-fA-F]))+'
embed2 = discord.Embed()
embed2.add_field(name="New PUG!", value=f"{url}", inline=True)
msg_sent = await ctx.send(embed=embed1)
await url.send(embed=embed2)

顺便说一句,它意味着是一个由两部分组成的命令。

我相信,这可能就是您想要的:

@client.command()
async def create(ctx):
embed = discord.Embed (
title = 'To start, send your vip link.',
description = '__MUST__ be a roblox football fusion link, sending any other link will result in a 48h mute, as well as a loss of your PUG Host role.'
)
message = await ctx.send(embed = embed)
def check(message):
return message.author == ctx.author
# This function is used to check if the message received is a valid URL
def checkURL(url):
regex = 'http[s]?://(?:[a-zA-Z]|[0-9]|[$-_@.&+]|[!*(),]|(?:%[0-9a-fA-F][0-9a-fA-F]))+'
return re.match(regex, url) is not None
try:
url = await client.wait_for('message', check = check, timeout = 60.0)

if (checkURL(url.content)):
embed = discord.Embed (
title = 'New PUG!',
description = url.content
)
await ctx.send(embed = embed)
else:
await ctx.send('Sorry, that is not a valid roblox football fusion link.')
except:
await message.delete()

注意:记得导入re模块。

注意:对于regex部分,我只是使用了问题中的字符串。你必须对其进行更多的改进,以检查url是否与特定的域匹配。例如,您只能检查google.com链接。点击此处了解有关regex的更多信息。

最新更新