예제 #1
0
        private async Task MinMaxCloseReactionsCleared(Cacheable <IUserMessage, ulong> cacheable, ISocketMessageChannel messageChannel)
        {
            var message = await cacheable.GetOrDownloadAsync();

            MinMaxCloseMessage minMaxCloseMessage = null;

            if (messages.Any(x => x.Message.Id == message.Id))
            {
                minMaxCloseMessage = messages.FirstOrDefault(x => x.Message.Id == message.Id);
            }
            else
            {
                return;
            }
            if (!(message.Reactions.ContainsKey(stop)))
            {
                await message.AddReactionAsync(stop);
            }
            if (!(message.Reactions.ContainsKey(minimize)))
            {
                await message.AddReactionAsync(minimize);
            }
            if (!(message.Reactions.ContainsKey(maximize)))
            {
                await message.AddReactionAsync(maximize);
            }
            if (!(message.Reactions.ContainsKey(info)))
            {
                await message.AddReactionAsync(info);
            }
        }
예제 #2
0
        public async Task SendMMCMessageAsync(SocketCommandContext context, IUserMessage message)
        {
            var msg = message;
            var minMaxCloseMessage = new MinMaxCloseMessage(msg, context);

            messages.Add(minMaxCloseMessage);
            await msg.AddReactionAsync(info);

            await msg.AddReactionAsync(minimize);

            await msg.AddReactionAsync(maximize);

            await msg.AddReactionAsync(stop);

            _ = Task.Run(() => DelayDeleteAsync(context, msg, 300));
        }
예제 #3
0
        private async Task MinMaxCloseReaction(Cacheable <IUserMessage, ulong> cacheable, ISocketMessageChannel messageChannel, SocketReaction reaction)
        {
            var message = await cacheable.GetOrDownloadAsync();

            if (reaction.UserId == Client.CurrentUser.Id)
            {
                return;
            }
            MinMaxCloseMessage minMaxCloseMessage = null;

            if (messages.Any(x => x.Message.Id == message.Id))
            {
                minMaxCloseMessage = messages.FirstOrDefault(x => x.Message.Id == message.Id);
            }
            else
            {
                return;
            }

            switch (reaction.Emote.Name)
            {
            case "\ud83c\uddfd":                    //delete
                if (minMaxCloseMessage.UserID != reaction.UserId)
                {
                    return;
                }
                await minMaxCloseMessage.Message.DeleteAsync();

                break;

            case "\u2B07":                    //minimize
                await message.RemoveReactionAsync(minimize, reaction.User.GetValueOrDefault());

                if (!minMaxCloseMessage.Maximized)
                {
                    return;
                }
                minMaxCloseMessage.Maximized = false;
                if (message.Content != "")
                {
                    await message.ModifyAsync(x => x.Content = minMaxCloseMessage.ShortMessage);
                }
                else
                {
                    var embed = new EmbedBuilder();
                    embed.AddField(DateTime.UtcNow.ToString() + " UTC.", minMaxCloseMessage.ShortMessage);
                    await message.ModifyAsync(x => x.Embed = embed.Build());
                }

                break;

            case "\u2195":                    //maximize
                await message.RemoveReactionAsync(maximize, reaction.User.GetValueOrDefault());

                if (minMaxCloseMessage.Maximized)
                {
                    return;
                }
                minMaxCloseMessage.Maximized = true;
                if (minMaxCloseMessage.Message.Content != "")
                {
                    await message.ModifyAsync(x => x.Content = minMaxCloseMessage.Message.Content);
                }
                else
                {
                    await message.ModifyAsync(x => x.Embed = minMaxCloseMessage.Message.Embeds.FirstOrDefault() as Embed);

                    await message.ModifyAsync(x => x.Content = "");
                }
                break;

            case "\u2139":                    //info
                if (minMaxCloseMessage.InfoCalled)
                {
                    return;
                }
                minMaxCloseMessage.InfoCalled = true;
                await message.RemoveReactionAsync(info, reaction.User.GetValueOrDefault());

                var msg = await message.Channel.SendMessageAsync("Use :regional_indicator_x: to delete the message, can only be done by the user that called the command, :arrow_up_down: to maximize the message,:arrow_down: to minimize the message.");

                _ = Task.Run(() => DelayDeleteAsync(message: msg as IMessage));
                break;
            }
        }