Discord.py: Trying to do an action depending on user reaction

不问归期 提交于 2021-01-28 05:21:48

问题


This is the code:

import asyncio
import discord
from discord.ext import commands

client = commands.Bot(command_prefix = ".")
Token=""

@client.command()
async def react(ctx):
    message = await ctx.send("Test")
    await message.add_reaction("<💯>")
    await message.add_reaction("<👍>")
    user=ctx.message.author
    def check(reaction, user):
        user == ctx.message.author and str(message.emoji) == '💯'
        try:
            reaction, user = await client.wait_for('reaction_add', timeout=60.0, check=check)
        except asyncio.TimeoutError:
            await channel.send('💯')
        else:
            await channel.send('👍')

client.run(Token)

The problem is that I always get an error "'await' outside async function", and the a of "reaction, user = a" get highlighted. Thank you for any help.

来源:https://stackoverflow.com/questions/60382718/discord-py-trying-to-do-an-action-depending-on-user-reaction

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!