Esempio n. 1
0
        private void InitializeMessages()
        {
            var log1 = ProgramMessages.ChannelMessages();
            var log2 = ProgramMessages.ChannelMessagesCondensed();

            if ((log1 != null && log2 != null) && (log1.Count != 0 && log2.Count != 0))
            {
                Console.WriteLine("Logs loaded successfully.");
            }
            else
            {
                Console.WriteLine("Logs are null.");
            }
        }
Esempio n. 2
0
        public async Task Remember(string phrase = "", string user = "")
        {
            string message = string.Empty;
            // Don't allow command to initiate in DMs
            var guilds = Context.Guild;

            if (guilds == null)
            {
                message = "hey dumbass this command only works in a server";
            }
            else if (ProgramMessages.ChannelMessagesCondensed() == null)
            {
                message = "umm the chat logs haven't been loaded... :(";
            }
            else
            {
                IMessage        msg            = null;
                List <IMessage> serverMessages = new List <IMessage>();
                Dictionary <SocketTextChannel, int> channelMessageCount = new Dictionary <SocketTextChannel, int>();
                foreach (SocketTextChannel channel in guilds.TextChannels)
                {
                    List <IMessage> channelMessages = ProgramMessages.GetSavedChannelMessagesCondensed(channel);
                    if (channelMessages != null)
                    {
                        serverMessages.AddRange(channelMessages);
                        channelMessageCount.Add(channel, channelMessages.Count);
                    }
                }
                if (serverMessages == null)
                {
                    await ReplyAsync("hey dumbass this command only works in a server");

                    return;
                }
                string contents = string.Empty, attachments = string.Empty;
                if (msg.Attachments != null)
                {
                    foreach (var attachment in msg.Attachments)
                    {
                        attachments += attachment.Url + "\n";
                    }
                }
                if (msg.Content != null)
                {
                    contents = msg.Content;
                }

                message = $"remember when {msg.Author.Username.ToLower()} said:\n\"{attachments}\n{contents}\"";
                if (message.Length < Constants.CharacterLimit && attachments == string.Empty)
                {
                    message = $"remember when {msg.Author.Username.ToLower()} said:\n\"{contents}\"";
                }
                else if (message.Length < Constants.CharacterLimit)
                {
                }
                else if (contents == string.Empty)
                {
                    message = $"remember when {msg.Author.Username.ToLower()} uploaded:\n\"{attachments}\"";
                }
                else if (message.Length > Constants.CharacterLimit && message.Length - attachments.Length <= Constants.CharacterLimit)
                {
                    message = $"remember when {msg.Author.Username.ToLower()} said:\n\"{contents}\"";
                }
                else
                {
                    message = contents;
                }
            }
            await ReplyAsync(message);
        }