Discord Python 重写 - wait_for('reaction_add')
Discord Python Rewrite - wait_for('reaction_add')
所以,我正在尝试使用此代码做出反应帮助
@client.command()
async def test(ctx):
msg = await ctx.send("Eh idk just react")
await msg.add_reaction("⬅️")
await msg.add_reaction("➡️")
def check(reaction, user):
return user == ctx.message.author and str(reaction.emoji) in ['⬅️', '➡️']
try:
reaction, user = await client.wait_for('reaction_add', timeout=5, check=check)
if reaction == '➡️':
await ctx.send("NEEXT!")
return
elif reaction == '⬅️':
await ctx.send("RETUUURN!")
return
except asyncio.TimeoutError:
await ctx.send("Timed out")
但是当添加一个反应时,它没有做任何事情。有人能帮我吗?我需要 1 周的反应帮助。
与 unicode 表情符号比较时需要使用 reaction.emoji
。
@client.command()
async def test(ctx):
msg = await ctx.send("Eh idk just react")
await msg.add_reaction("⬅️")
await msg.add_reaction("➡️")
def check(reaction, user):
return user == ctx.message.author and str(reaction.emoji) in ['⬅️', '➡️']
try:
reaction, user = await client.wait_for('reaction_add', timeout=5, check=check)
if reaction.emoji == '➡️':
await ctx.send("NEEXT!")
return
elif reaction.emoji == '⬅️':
await ctx.send("RETUUURN!")
return
except asyncio.TimeoutError:
await ctx.send("Timed out")
所以,我正在尝试使用此代码做出反应帮助
@client.command()
async def test(ctx):
msg = await ctx.send("Eh idk just react")
await msg.add_reaction("⬅️")
await msg.add_reaction("➡️")
def check(reaction, user):
return user == ctx.message.author and str(reaction.emoji) in ['⬅️', '➡️']
try:
reaction, user = await client.wait_for('reaction_add', timeout=5, check=check)
if reaction == '➡️':
await ctx.send("NEEXT!")
return
elif reaction == '⬅️':
await ctx.send("RETUUURN!")
return
except asyncio.TimeoutError:
await ctx.send("Timed out")
但是当添加一个反应时,它没有做任何事情。有人能帮我吗?我需要 1 周的反应帮助。
与 unicode 表情符号比较时需要使用 reaction.emoji
。
@client.command()
async def test(ctx):
msg = await ctx.send("Eh idk just react")
await msg.add_reaction("⬅️")
await msg.add_reaction("➡️")
def check(reaction, user):
return user == ctx.message.author and str(reaction.emoji) in ['⬅️', '➡️']
try:
reaction, user = await client.wait_for('reaction_add', timeout=5, check=check)
if reaction.emoji == '➡️':
await ctx.send("NEEXT!")
return
elif reaction.emoji == '⬅️':
await ctx.send("RETUUURN!")
return
except asyncio.TimeoutError:
await ctx.send("Timed out")