Ejemplo n.º 1
0
        public async Task Snipe(IUser user, int lastIndex = 1)
        {
            List <MessageData> msgList = MessageWatcher.MessageList.FindAll(m => m.Message.Author == user);

            if (!msgList.Any())
            {
                await Context.Channel.SendMessageAsync($"<@{Context.User.Id}> There's nothing to snipe!");

                return;
            }

            MessageData msg = msgList[msgList.Count - lastIndex];


            EmbedBuilder eb = new EmbedBuilder()
                              .WithColor(new Color(0x90, 0x10, 0x10))
                              .WithAuthor(msg.Message.Author)
                              .WithDescription(msg.Message.Content)
                              .WithTimestamp(msg.Time);

            Embed embed = eb.Build();

            try
            {
                await Context.Channel.SendMessageAsync(
                    $"<@{Context.User.Id}> Sniped! ({(msg.IsEdit ? "Edited" : "Deleted")})", embed : embed);
            }
            catch
            {
                Logging.Log($"(!snipe index) I'm muted ;_;");
                MessageWatcher.SaveMessageList();
            }
        }
Ejemplo n.º 2
0
        public async Task SnipeChannelList([Remainder] IChannel channel = null)
        {
            if (channel == null)
            {
                channel = Context.Channel;
            }

            List <MessageData> msgList = MessageWatcher.MessageList.FindAll(m => m.Message.Channel == channel);

            if (!msgList.Any())
            {
                await Context.Channel.SendMessageAsync($"<@{Context.User.Id}> There's nothing to snipe!");

                return;
            }

            EmbedBuilder eb = new EmbedBuilder()
                              .WithColor(new Color(0x90, 0x10, 0x10))
                              .WithAuthor(channel.Name, Context.Guild.IconUrl);

            StringBuilder sb = new StringBuilder();

            for (int i = 0; i < msgList.Count && i < 10; i++)
            {
                var    msg    = msgList[msgList.Count - i - 1];
                string msgStr = msg.Message.Content;
                sb.AppendLine($"{i + 1}> {msg.Message.Author}:" +
                              $" {(msgStr.Length > 19 ? $"{msgStr.Substring(0, 18)}..." : msgStr != "" ? msgStr : "-No Message-")}" +
                              $" ({(msg.IsEdit ? "E" : "D")})" +
                              $" @ {msg.Time.TimeOfDay.ToString(@"hh\:mm\:ss")}");
            }

            eb.WithDescription(sb.ToString());

            try
            {
                await Context.Channel.SendMessageAsync($"<@{Context.User.Id}> List: ", embed : eb.Build());
            }
            catch
            {
                Logging.Log($"(!snipe channellist) I'm muted ;_;");
                MessageWatcher.SaveMessageList();
            }
        }
Ejemplo n.º 3
0
        public async Task SnipeList([Remainder] IUser user)
        {
            List <MessageData> msgList = MessageWatcher.MessageList.FindAll(m => m.Message.Author == user);

            if (!msgList.Any())
            {
                await Context.Channel.SendMessageAsync($"<@{Context.User.Id}> There's nothing to snipe!");

                return;
            }

            EmbedBuilder eb = new EmbedBuilder()
                              .WithColor(new Color(0x90, 0x10, 0x10))
                              .WithAuthor(user);

            StringBuilder sb = new StringBuilder();

            for (int i = 0; i < msgList.Count && i < 10; i++)
            {
                var    msg    = msgList[msgList.Count - i - 1];
                string msgStr = msg.Message.Content;
                sb.AppendLine($"{i + 1}>" +
                              $" {(msgStr.Length > 26 ? $"{msgStr.Substring(0, 25)}..." : msgStr != "" ? msgStr : "-No Message-")}" +
                              $" ({(msg.IsEdit ? "E" : "D")})" +
                              $" @ {msg.Time.TimeOfDay.ToString(@"hh\:mm\:ss")}");
            }

            eb.WithDescription(sb.ToString());

            try
            {
                await Context.Channel.SendMessageAsync($"<@{Context.User.Id}>" +
                                                       $" List: ({Config.Instance.PrefixString}snipe index to expand)", embed : eb.Build());
            }
            catch
            {
                Logging.Log($"(!snipe list) I'm muted ;_;");
                MessageWatcher.SaveMessageList();
            }
        }