带有args的Discord.py PollBot命令

2024-06-02 05:37:55 发布

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

async def poll(ctx, *, message, arg1, arg2):
    pollem = discord.Embed(title='', description=f'{message}')
    pollem.add_field(name='one {0}'.format(arg1), value='')
    pollem.add_field(name='two {0}'.format(arg2), value='')
    msg=await ctx.channel.send(embed=pollem)
    await msg.add_reaction('🏓')
    #await msg.add_reaction(emoji=':two:')

到目前为止,这是我的代码,我真的不知道如何让它正常工作 .poll“消息”arg1“arg2”arg(n)

现在我只是有一些错误

TypeError: poll() missing 2 required keyword-only arguments: 'arg1' and 'arg2'


Tags: nameaddformatfieldmessagevaluemsgawait
1条回答
网友
1楼 · 发布于 2024-06-02 05:37:55

让用户使用类似于.poll Would you rather // Use arg 1? // Use arg 2?的命令 以后你可以把它分开。 如果您愿意,可以使用任何其他方便的//

这是你能做的


async def poll(ctx, *, contents):
    message, arg1, arg2 = contents.split("//")
    pollem = discord.Embed(title='', description=f'{message}')
    pollem.add_field(name='one {0}'.format(arg1), value='')
    pollem.add_field(name='two {0}'.format(arg2), value='')
    msg=await ctx.channel.send(embed=pollem)
    await msg.add_reaction('🏓')
    #await msg.add_reaction(emoji=':two:')

相关问题 更多 >