在discord.py rewrite中有多个用逗号分隔的参数?

2024-10-03 21:30:24 发布

您现在位置:Python中文网/ 问答频道 /正文

我的discord机器人有以下代码,它基本上是一个图像处理命令,但我不知道如何使用逗号分隔两个参数,在旧的discord.py中,我只会使用“message.content.split(“,””),但在discord.py重写中它似乎不再起作用,有什么建议或想法吗? 代码:

async def topone(ctx, *, frstInput = "Tartarus", scndInput = "riot"):
    for attachment in ctx.message.attachments:

        await attachment.save("toponeimg.png")
        back_im = Image.open("toponetemplate.png")
        imre = Image.open("toponeimg.png")
        imre_resize = imre.resize((207, 116))
        back_im.paste((imre_resize), (38, 29))
        draw = ImageDraw.Draw(back_im)
        imgFont = ImageFont.truetype("C:/Users/Flippy/AppData/Local/Microsoft/Windows/Fonts/Montserrat-Semibold.ttf", 34)
        imgFont2 = ImageFont.truetype("C:/Users/Flippy/AppData/Local/Microsoft/Windows/Fonts/Montserrat-Semibold.ttf", 24,)


        draw.text((318, 74), frstInput, (0, 0, 0), font=imgFont, anchor="ls")
        # 'scndInput' is the argument I want to specify after a command, like "!topone Arg1, Arg2"
        draw.text((262, 112), scndInput, (74, 74, 74), font=imgFont2, anchor="ls")


        back_im.save("follow_hourly_bbc_on_twitter.png", quality=68)
        await ctx.send(file = discord.File("follow_hourly_bbc_on_twitter.png"))
        return

Tags: 代码pymessageattachmentpngbackctxdraw