Ejemplo n.º 1
0
            public async sealed override Task ActionOn(ActionData action, SocketReaction reaction)
            {
                var tally = (await action.GetTallyData(reaction.UserId)).Select(x => GetEmote(x)).ToArray();

                if (!await ToggleOn(tally, reaction))
                {
                    if (!((reaction.Message.IsSpecified ? reaction.Message.Value : await reaction.Channel.GetMessageAsync(reaction.MessageId)) is IUserMessage message))
                    {
                        Console.WriteLine("Can't do toggle actions on non-user messages");
                        return;
                    }
                    await message.RemoveReactionAsync(reaction.Emote, reaction.User.IsSpecified?reaction.User.Value : await reaction.Channel.GetUserAsync(reaction.UserId));

                    return;
                }
                await action.AddTally(reaction.UserId, reaction.Emote.ToString() ?? throw new ArgumentNullException("Reaction emote has null name somehow. Asshole emote."));
            }