【发布时间】:2019-01-15 04:17:32
【问题描述】:
我需要实现一些功能,其中一个功能是实现民意调查类型功能。由于某些政策,不能使用公共不和谐机器人,所以我们必须自己实施一些东西。昨天做了一些研究,能够使用 python3 和来自discord.ext 的commands api 制作基本机器人。现在我需要弄清楚的是:
- 阅读用户对消息添加的反应?
- 创建带有反应的消息(例如创建反应民意调查的机器人?)
- 置顶消息?
- 我相信从
ctx我可以得到usertags(管理员等)。有更好的方法吗?
在Commands reference page 上找不到任何有用的信息,或者我可能正在查看错误的文档。任何帮助将不胜感激。
谢谢
更新:谢谢大家。现在我被困在如何添加表情符号上,这是我的代码
poll_emojis = {0: ':zero:', 1: ':one:', 2: ':two:', 3: ':three:', 4: ':four:'}
@client.event
async def on_message(message):
if message.author == client.user:
return
if message.content.startswith('$create_poll'):
poll_content = message.content.split('"')
poll_text = poll_content[1]
poll_options = []
poll_option_text = ''
count = 0
for poll_option in poll_content[2:]:
if poll_option.strip() != '':
poll_options.append(poll_option)
poll_option_text += '{0}: {1}\t'.format(poll_emojis[count], poll_option)
count += 1
posted_message = await message.channel.send('**{0}**\n{1}'.format(poll_text, poll_option_text))
count = 0
for poll_option in poll_options:
await posted_message.add_reaction(Emoji(poll_emojis[count]))
count += 1
【问题讨论】:
-
“
usertags”是什么意思?
标签: python python-3.x discord discord.py