Esempio n. 1
0
        private async Task ReactionAdded(Cacheable <IUserMessage, ulong> message, Cacheable <IMessageChannel, ulong> channel, SocketReaction reaction)
        {
            if (channel.Value == null)
            {
                await channel.GetOrDownloadAsync();
            }

            if (channel.Value is not IGuildChannel guildChannel || guildChannel.Name != ChannelNames.ActivePickups)
            {
                return;
            }
            if (reaction.User.Value.IsBot)
            {
                return;
            }

            var queue = await _queueRepository.FindQueueByMessageId(reaction.MessageId, guildChannel.GuildId.ToString());

            if (queue == null)
            {
                return;
            }

            var pickupChannel = ((SocketGuild)guildChannel.Guild).Channels
                                .FirstOrDefault(c => c.Name.Equals(ChannelNames.Pickup)) as SocketTextChannel;

            switch (reaction.Emote.Name)
            {
            case "\u2705":
                await _subscriberCommandService.Add(queue.Name,
                                                    pickupChannel ?? (SocketTextChannel)guildChannel,
                                                    (SocketGuildUser)reaction.User);

                break;

            case "\uD83D\uDCE2":
                await _listCommandService.Promote(
                    queue,
                    pickupChannel ?? (SocketTextChannel)guildChannel,
                    (SocketGuildUser)reaction.User);

                break;
            }
        }