[英]PUG create command doesn't respond
所以我需要检测一个链接,但我不确定如何。 打印的错误是“属性错误:'str' object 没有属性'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
的更多信息。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.