I'm trying to make a bot that you can request to play rock paper scissors with another player. It asks the challenged player whether they want to play, if they accept, the bot then creates a message with 3 reactions that once reacted to by the relative player will delete itself and save the choice. Then it repeats for the other player. Then it says who won / drew.
public class Games : BaseCommandModule
{
[Command("rps")]
public async Task ReactionCommand(CommandContext ctx, DiscordMember member)
{
var emoji = DiscordEmoji.FromName(ctx.Client, ":scissors:");
var challenger = ctx.Member;
var opponent = member;
var message = await ctx.RespondAsync($"{opponent.Mention}, react with {emoji} if you'd like to play Rock Paper Scissors with {challenger.DisplayName}?");
await message.CreateReactionAsync(emoji);
var result = await message.WaitForReactionAsync(opponent, emoji);
if (!result.TimedOut)
{
var message2 = await ctx.RespondAsync($"{opponent.Mention}, react with your choice.");
await message2.CreateReactionAsync(DiscordEmoji.FromName(ctx.Client, ":rock:"));
await message2.CreateReactionAsync(DiscordEmoji.FromName(ctx.Client, ":scissors:"));
await message2.CreateReactionAsync(DiscordEmoji.FromName(ctx.Client, ":roll_of_paper:"));
}
}
}
It does not add the reactions to the message. I am also wondering how I would be able to tell what reaction the person did. So the whole thing works for the part where it asks to confirm whether I want to play. I react with the scissors, then it says the 'member, react with your choice' but with no reactions. Thank you.
P.S. The console has no errors.
question from:
https://stackoverflow.com/questions/66056222/dsharpplus-d-adding-reactions-to-messages-with-bot-for-game 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…