PUG 创建命令没有响应

PUG create command doesn't respond

所以我需要检测 link,但我不确定如何检测。打印的错误是“属性错误:'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 here.