因此,我想执行一个temp-mute命令,当我执行temp-mute命令时,它应该显示一个嵌入的信息,例如昵称,用户ID,原因和该用户将被静音的时间。 / p>
现在的事情是,当我给命令一个原因并包含一个URL时,然后我尝试设置时间,而当我发送命令时,它会在“时间”字段中显示URL。这是一个截图,可以更好地说明 Image
这是命令:
import pynput, pyperclip, re, time
mouse = pynput.mouse.Controller()
keyboard = pynput.keyboard.Controller()
def on_activate_h():
mouse.position = (500, 500)
mouse.click(pynput.mouse.Button.left, 1)
time.sleep(1)
mouse.position = (600, 600)
mouse.click(pynput.mouse.Button.left, 1)
time.sleep(1)
mouse.position = (800, 800)
mouse.click(pynput.mouse.Button.left, 1)
print('<ctrl>+<alt>+h pressed')
def on_activate_i():
mouse.position = (300, 300)
mouse.click(pynput.mouse.Button.left, 1)
with keyboard.pressed(pynput.keyboard.Key.ctrl):
keyboard.press('a')
keyboard.release('a')
with keyboard.pressed(pynput.keyboard.Key.ctrl):
keyboard.press('c')
keyboard.release('c')
sourceStr = pyperclip.paste()
sourceStr = re.sub(r'a', r'A', sourceStr)
pyperclip.copy(sourceStr)
with keyboard.pressed(pynput.keyboard.Key.ctrl):
keyboard.press('v')
keyboard.release('v')
print('<ctrl>+<alt>+i pressed')
with pynput.keyboard.GlobalHotKeys({
'<ctrl>+<alt>+h': on_activate_h,
'<ctrl>+<alt>+i': on_activate_i}) as h:
h.join()
答案 0 :(得分:2)
添加原因时,建议您键入命令,或者在原因附近加上引号:
t!mute Simplezes "Reason#1 https://i.imgur.com/1IeETJ5.png" 10
或者您重写参数的顺序:
@client.command()
@has_permissions(manage_roles=True)
async def mute(ctx, member: discord.Member, time:int=2, *, reason=""): # declaring that time is an int
# default value ^
embedMute = discord.Embed(colour=member.color,timestamp=ctx.message.created_at)
embedMute.set_author(name=f"Mute")
embedMute.set_thumbnail(url=member.avatar_url)
embedMute.add_field(name="User:", value=member, inline=False)
embedMute.add_field(name="ID:", value=member.id, inline=False)
embedMute.add_field(name="Reason:", value=reason, inline=False)
embedMute.add_field(name="Time:", value=time+" hour/s", inline=False)
embedMute.add_field(name="Logged on:", value=datetime.datetime.now().strftime("%m/%d/%Y at %H:%M"), inline=False)
embedMute.set_footer(text=f"logged by: {ctx.author}", icon_url=ctx.author.avatar_url)
await ctx.send(embed=embedMute)
这样,您就可以编写如下命令:
t!mute Simplezes 10 Reason#1 https://i.imgur.com/1IeETJ5.png
星号使原因充当单个参数,使您可以在句子中留空格。