【发布时间】:2021-09-24 19:23:40
【问题描述】:
我的 discord bot 有以下代码,它基本上是一个图像处理命令,但我不知道如何用逗号分隔 2 个参数,在旧的 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
【问题讨论】:
标签: python discord discord.py