【发布时间】:2020-09-26 14:35:47
【问题描述】:
DISCORD.PY
我尝试为投票系统创建命令并遇到问题。命令如下:
@commands.command(pass_context = True)
async def poll(self, ctx, question, *options: str):
author = ctx.message.author
server = ctx.message.server
if not author.server_permissions.manage_messages: return await self.bot.say(DISCORD_SERVER_ERROR_MSG)
if len(options) <= 1:
await self.bot.say("```Error! A poll must have more than one option.```")
return
if len(options) > 2:
await self.bot.say("```Error! Poll can have no more than two options.```")
return
if len(options) == 2 and options[0] == "yes" and options[1] == "no":
reactions = ['????', '????']
else:
reactions = ['????', '????']
description = []
for x, option in enumerate(options):
description += '\n {} {}'.format(reactions[x], option)
embed = discord.Embed(title = question, color = 3553599, description = ''.join(description))
react_message = await self.bot.say(embed = embed)
for reaction in reactions[:len(options)]:
await self.bot.add_reaction(react_message, reaction)
embed.set_footer(text='Poll ID: {}'.format(react_message.id))
await self.bot.edit_message(react_message, embed=embed)
我的问题是:我怎样才能使我使用命令提出的问题有更多的单词。如果我现在使用更多单词,我会将它们作为选项阅读并得到错误。
Ex 1:/poll You are human yes no(只将“you”读作问题,其余为选项。)
Ex 2:/poll 你是人类是的,不是(这就是我想要的)
谢谢!
【问题讨论】:
标签: python discord discord.py