【发布时间】:2020-06-09 19:21:17
【问题描述】:
@client.command()
async def quickpoll( ctx, question, *options: str):
if len(options) <= 1:
await ctx.send('You need more than one option to make a poll!')
return
if len(options) > 10:
await ctx.send('You cannot make a poll for more than 10 things!')
return
if len(options) == 2 and options[0] == 'yes' and options[1] == 'no':
reactions = ['✅', '❌']
else:
reactions = ['1⃣', '2⃣', '3⃣', '4⃣', '5⃣', '6⃣', '7⃣', '8⃣', '9⃣', '????']
description = []
for x, option in enumerate(options):
description += '\n {} {}'.format(reactions[x], option)
embed = discord.Embed(title=question, description=''.join(description))
react_message = await ctx.send(embed=embed)
for reaction in reactions[:len(options)]:
await react_message.edit(react_message, reaction)
embed.set_footer(text='Poll ID: {}'.format(react_message.id))
await react_message.edit(embed=embed)
我有这段代码可以让我的 discord.py 机器人创建一个投票。当我触发命令时,它什么也不做。没有错误,没有消息,什么都没有。我在想我的代码的某些部分可能已经过时了。不,代码不在一个类下。
【问题讨论】:
-
你能做出一个完全有效的命令吗?如果是这样,请尝试逐步添加内容以处理所需的 poll 命令,直到找到导致问题的部分。
标签: python discord.py