Exemplo n.º 1
0
            public async sealed override Task ActionOn(ActionData action, SocketReaction reaction)
            {
                if (!await ToggleOn(reaction))
                {
                    if (!((reaction.Message.IsSpecified ? reaction.Message.Value : await reaction.Channel.GetMessageAsync(reaction.MessageId)) is IUserMessage message))
                    {
                        Console.WriteLine("Can't do radio actions on non-user messages");
                        return;
                    }
                    // I should be able to do this without getting the full user object and this infuriates me.
                    await message.RemoveReactionAsync(reaction.Emote, reaction.User.IsSpecified?reaction.User.Value : await reaction.Channel.GetUserAsync(reaction.UserId));

                    return;
                }
                var radio = await action.GetRadioData(reaction.UserId);

                await action.SetRadioData(reaction.UserId, reaction.Emote.ToString()); // All IEmote can be deserialized from this format

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

                    await toggle;
                }
            }
Exemplo n.º 2
0
            public async sealed override Task ActionOff(ActionData action, SocketReaction reaction)
            {
                var radio = await action.GetRadioData(reaction.UserId);

                if (radio == null)
                {
                    Console.WriteLine("What t he  fuc k"); // Pretty sure this is an invalid state
                    return;
                }
                var emote = GetEmote(radio);

                if (emote == reaction.Emote)
                {
                    await Task.WhenAll(
                        ToggleOff(reaction.Channel, reaction.Message.Value ?? (IUserMessage)(await reaction.Channel.GetMessageAsync(reaction.MessageId)), reaction.UserId, emote),
                        action.SetRadioData(reaction.UserId, null)
                        );
                } // Otherwise, Seraphina killed the reaction.
            }