问题描述
基准是,我正在编写一个在服务器中打开帮助通知单的机器人,其中有一个包含消息和响应的通道,如果您单击该消息的响应,则会将一条消息发送到员工的通道以通知他们有人需要帮助,我希望机器人在消息中提及用户,但是我不知道如何获得用户名,这是代码
import discord
from discord.ext import commands
# Dictionary
client = commands.Bot(command_prefix= '.')
# Command line bot status #
@client.event
async def on_ready():
print('Bot is ready')
# Ticket opening #
@client.event
async def on_raw_reaction_add(reaction):
message_id = 'message with reaction'
if reaction.message_id == message_id:
if reaction.emoji.name == ('?️'):
channel = client.get_channel('staff channel id')
await channel.send('Someone Needs Help! @here')
client.run('my token')
# member = discord.utils.find(lambda m : m.id == payload.user_id,guild.members) # ```
解决方法
更改`
async def on_raw_reaction_add(reaction):
到
async def on_reaction_add(reaction,user):
您可以在之后作为用户