Esempio n. 1
0
 private async Task MemeStoreCount()
 {
     using (var db = new Memestorage())
     {
         try
         {
             var memestoreCount = db.Memestore.AsQueryable().Where(x => x.Content != null).Count();
             await Context.Channel.SendMessageAsync($"there are currently {memestoreCount} active memes in the database.");
         }
         catch (Exception ex)
         {
             await ExceptionHandler.HandleExceptionQuietly(GetType().FullName, ExceptionHandler.GetAsyncMethodName(), ex);
         }
     }
 }
Esempio n. 2
0
        private async Task MyMemeStore()
        {
            using (var db = new Memestorage())
            {
                try
                {
                    var memestoreArray = db.Memestore.AsQueryable().Where(x => x.AuthorID == Context.Message.Author.Id).ToArray();


                    var listOfMemes = new List <string>();
                    foreach (var item in memestoreArray)
                    {
                        listOfMemes.Add(item.Title);
                    }
                    var outputList    = String.Join(", ", listOfMemes.ToArray());
                    var outputMessage = $"{Context.Message.Author.Username} is the owner of the memes: {outputList}";

                    if (outputMessage.Length >= 1999)
                    {
                        await Context.Channel.SendMessageAsync("well u made too many memes so im not gonna tell u, sry ");

                        return;
                    }

                    await Context.Channel.SendMessageAsync(outputMessage);
                }
                catch (Exception ex)
                {
                    await ExceptionHandler.HandleExceptionQuietly(GetType().FullName, ExceptionHandler.GetAsyncMethodName(), ex);
                }
            }
        }
Esempio n. 3
0
        private async Task MemeStoreMostPopular()
        {
            using (var db = new Memestorage())
            {
                try
                {
                    var           collectionTopMemes = db.Memestore.AsQueryable().OrderByDescending(x => x.MemeUses).Take(10);
                    List <string> topMemeAuthors     = new List <string>();
                    topMemeAuthors.AddRange(collectionTopMemes.Select(x => x.Author));

                    List <string> topMemetitles = new List <string>();
                    topMemetitles.AddRange(collectionTopMemes.Select(x => x.MemeId + "#" + x.Title.Substring(0, 15)));

                    List <ulong> topMemeUses = new List <ulong>();
                    topMemeUses.AddRange(collectionTopMemes.Select(x => x.MemeUses));

                    var embed = new EmbedBuilder();
                    embed.WithTitle($"Top memes in Melee Slasher");
                    embed.AddField("Number and Name: ", string.Join("\n", topMemetitles), true);
                    embed.AddField("Author: ", string.Join("\n", topMemeAuthors), true);
                    embed.AddField("Uses: ", string.Join("\n", topMemeUses), true);
                    await Context.Channel.SendMessageAsync("", false, embed.Build());
                }
                catch (Exception ex)
                {
                    await ExceptionHandler.HandleExceptionQuietly(GetType().FullName, ExceptionHandler.GetAsyncMethodName(), ex);
                }
            }
        }
Esempio n. 4
0
        private async Task MemeCreatedDetails(int id)
        {
            using (var db = new Memestorage())
            {
                try
                {
                    var meme = db.Memestore.AsQueryable().Where(x => x.MemeId == id).FirstOrDefault();

                    if (meme != null)
                    {
                        await Context.Channel.SendMessageAsync($"{meme.Title} was created by {meme.Author} on {meme.Date} at {meme.Time}. MemeID = {meme.MemeId}");
                    }
                }
                catch (Exception ex)
                {
                    await ExceptionHandler.HandleExceptionQuietly(GetType().FullName, ExceptionHandler.GetAsyncMethodName(), ex);
                }
            }
        }
Esempio n. 5
0
        private async Task MemeCreatedDetails(string title)
        {
            using (var db = new Memestorage())
            {
                try
                {
                    var meme = db.Memestore.AsQueryable().Where(x => x.Title.ToLower() == title.ToLower()).FirstOrDefault();

                    var embed = new EmbedBuilder();
                    embed.WithTitle($"{title}#{meme.MemeId}");
                    embed.AddField("Creator: ", meme.Author, true);
                    embed.AddField("On: ", meme.Date + " " + meme.Time, true);
                    embed.AddField("Uses: ", meme.MemeUses.ToString(), true);
                    embed.WithFooter($"{meme.Content}");
                    embed.WithColor(new Color(104, 66, 244));
                    await Context.Channel.SendMessageAsync("", false, embed.Build());
                }
                catch (Exception ex)
                {
                    await ExceptionHandler.HandleExceptionQuietly(GetType().FullName, ExceptionHandler.GetAsyncMethodName(), ex);
                }
            }
        }
Esempio n. 6
0
        private async Task RandomCallMeme()
        {
            bool success = false;
            var  insult  = await Insults.GetInsult();

            var rnd = new Random();

            using (var db = new Memestorage())
            {
                try
                {
                    while (success == false)
                    {
                        var maxID = db.Memestore.Max(x => x.MemeId);
                        var meme  = db.Memestore.AsQueryable().Where(x => x.MemeId == rnd.Next(0, maxID)).FirstOrDefault();

                        if (meme != null && !string.IsNullOrEmpty(meme.Content))
                        {
                            await Context.Channel.SendMessageAsync($"Meme#{meme.MemeId}: {meme.Content}");

                            success = true;
                        }
                    }
                }
                catch (Exception ex)
                {
                    await ExceptionHandler.HandleExceptionQuietly(GetType().FullName, ExceptionHandler.GetAsyncMethodName(), ex);
                }
            }
        }
Esempio n. 7
0
        private async Task StoreMeme([Remainder] string input)
        {
            try
            {
                var inputAsArray     = input.Split(" ");
                var title            = inputAsArray[0].ToString(); title = Regex.Replace(title, @"\t|\n|\r", "");
                var contentOfMessage = String.Join(" ", inputAsArray.Skip(1));
                var insult           = await Insults.GetInsult();

                if (contentOfMessage.Length < 2)
                {
                    await Context.Channel.SendMessageAsync($"what the f**k are you actually doing you f*****g {insult}, why are you trying to make an empty meme ? r u legit f*****g autist or what, fuckign dumb {insult} c**t");

                    return;
                }
                if (title.Where(x => Char.IsDigit(x)).Any())
                {
                    await Context.Channel.SendMessageAsync($"the meme title can't contain numbers or weird shit, sry bitch");

                    return;
                }


                if (await WordFilter.CheckForNaughtyWords(contentOfMessage) || await WordFilter.CheckForNaughtyWords(title))
                {
                    await Context.Channel.SendMessageAsync($"dont put nasty language in the memestore {insult}");

                    return;
                }

                using (var db = new Memestorage())
                {
                    if (db.Memestore.AsQueryable().Where(x => x.AuthorID == Context.Message.Author.Id).Count() >= 25)
                    {
                        await Context.Channel.SendMessageAsync($"f*****g greedy f**k {insult} bastard u cannot make over 25 memes");

                        return;
                    }

                    if (db.Memestore.AsQueryable().Where(x => x.Title.ToLower() == title.ToLower()).Any())
                    {
                        await Context.Channel.SendMessageAsync($"that alrdy exists u {insult}");

                        return;
                    }

                    await db.Memestore.AddAsync(new MemeStoreModel
                    {
                        Author   = Context.Message.Author.Username,
                        AuthorID = Context.Message.Author.Id,
                        Content  = contentOfMessage,
                        Title    = title,
                        Date     = DateTime.Now.ToShortDateString(),
                        Time     = DateTime.Now.ToShortTimeString()
                    });

                    await db.SaveChangesAsync();

                    await Context.Channel.SendMessageAsync($"{title} was successfully created!");
                }
            }
            catch (Exception ex)
            {
                await ExceptionHandler.HandleExceptionQuietly(GetType().FullName, ExceptionHandler.GetAsyncMethodName(), ex);
            }
        }
Esempio n. 8
0
        private async Task CallMemeID(int id)
        {
            var insult = await Insults.GetInsult();

            using (var db = new Memestorage())
            {
                try
                {
                    var meme = db.Memestore.AsQueryable().Where(x => x.MemeId == id).FirstOrDefault();
                    if (meme != null)
                    {
                        if (!string.IsNullOrEmpty(meme.Content))
                        {
                            Regex rgx   = new Regex("(<@![0-9]+>)");
                            var   match = rgx.Match(meme.Content);
                            if (match.Success)
                            {
                                db.Memestore.Remove(meme);
                                await Context.Channel.SendMessageAsync($"{meme.Title} contained some pings so get deleted son lmfao hahahah");
                            }
                            else
                            {
                                meme.MemeUses = meme.MemeUses + 1;

                                await Context.Channel.SendMessageAsync($"{meme.Content}");
                            }
                        }

                        await db.SaveChangesAsync();
                    }
                }
                catch (Exception ex)
                {
                    await ExceptionHandler.HandleExceptionQuietly(GetType().FullName, ExceptionHandler.GetAsyncMethodName(), ex);
                }
            }
        }