Ejemplo n.º 1
0
        public async Task ListMemesAsync(SocketUser user = null)
        {
            List <Meme> Memes;
            User        local;

            switch (user)
            {
            case null:
                Memes = DatabaseHandler.ListAll(new Meme());
                local = DatabaseHandler.GetFromDb(Context.User);
                break;

            default:
                local = DatabaseHandler.GetFromDb(user);
                Memes = DatabaseHandler.ListAll(new Meme(), local);
                break;
            }

            if (Memes.Count > 0)
            {
                EmbedBuilder embed = EmbedTemplate.Create(Context.Client.CurrentUser, Context.User);

                foreach (Meme meme in Memes)
                {
                    embed.AddField($"{meme.Id} - {meme.Url}", $"Submitted by {meme.User.Username} on {meme.CreatedAt}");
                }

                await ReplyAsync(Message.Info.Generic, false, embed.Build());
            }
            else
            {
                await ReplyAsync(Message.Error.NoContent(local));
            }
        }
Ejemplo n.º 2
0
        public async Task ShowJokeAsync(SocketUser user = null)
        {
            List <Joke> Jokes;
            Random      rn = new Random();
            User        localUser;

            switch (user)
            {
            case null:
                localUser = DatabaseHandler.GetFromDb(Context.User);
                Jokes     = DatabaseHandler.ListAll(new Joke());
                break;

            default:
                localUser = DatabaseHandler.GetFromDb(user);
                Jokes     = DatabaseHandler.ListAll(new Joke(), localUser);
                break;
            }

            if (Jokes.Count > 0)
            {
                Joke         joke  = Jokes[rn.Next(Jokes.Count)];
                EmbedBuilder embed = EmbedTemplate.Create(Context.Client.CurrentUser, Context.User);
                embed.WithTitle($"{joke.Id} - {joke.Text}");
                embed.WithFooter($"Submitted by: {joke.User.Username}#{joke.User.Discriminator}", joke.User.AvatarUrl);

                await ReplyAsync($"Here you go:", false, embed.Build());
            }
            else
            {
                await ReplyAsync(Message.Error.NoContent(localUser));
            }
        }
Ejemplo n.º 3
0
        public async Task ShowMemeAsync(SocketUser user = null)
        {
            List <Meme> Memes;
            Random      rn = new Random();
            User        localUser;

            switch (user)
            {
            case null:
                localUser = DatabaseHandler.GetFromDb(Context.User);
                Memes     = DatabaseHandler.ListAll(new Meme());
                break;

            default:
                localUser = DatabaseHandler.GetFromDb(user);
                Memes     = DatabaseHandler.ListAll(new Meme(), localUser);
                break;
            }

            if (Memes.Count > 0)
            {
                Meme         meme  = Memes[rn.Next(Memes.Count)];
                EmbedBuilder embed = EmbedTemplate.Create(Context.Client.CurrentUser, Context.User);
                embed.WithFooter($"Submitted by: {meme.User.Username}#{meme.User.Discriminator}", meme.User.AvatarUrl);
                embed.WithImageUrl(meme.Url);
                embed.WithTitle($"{meme.Id} - {meme.Url}");

                await ReplyAsync(Message.Info.Generic, false, embed.Build());
            }
            else
            {
                await ReplyAsync(Message.Error.NoContent(localUser));
            }
        }
Ejemplo n.º 4
0
        public async Task ListJokesAsync(SocketUser user = null)
        {
            List <Joke> Jokes;
            User        localUser;

            switch (user)
            {
            case null:
                Jokes     = DatabaseHandler.ListAll(new Joke());
                localUser = DatabaseHandler.GetFromDb(Context.User);
                break;

            default:
                localUser = DatabaseHandler.GetFromDb(user);
                Jokes     = DatabaseHandler.ListAll(new Joke(), localUser);
                break;
            }

            if (Jokes.Count > 0)
            {
                EmbedBuilder embed = EmbedTemplate.Create(Context.Client.CurrentUser, Context.User);

                foreach (Joke joke in Jokes)
                {
                    embed.AddField($"{joke.Id} - {joke.Text}", $"Submitted by {joke.User.Username} on {joke.CreatedAt}");
                }

                await ReplyAsync(Message.Info.Generic, false, embed.Build());
            }
            else
            {
                await ReplyAsync(Message.Error.NoContent(localUser));
            }
        }
Ejemplo n.º 5
0
        public async Task ShowRandomMemeAsync()
        {
            Random rn    = new Random();
            int    limit = 33000;

            string Path(int n) => $"http://images.memes.com/meme/{n}.jpg";

            string meme = Path(rn.Next(limit));

            EmbedBuilder embed = EmbedTemplate.Create(Context.Client.CurrentUser, Context.User);

            embed.WithImageUrl(meme);
            embed.WithTitle(meme);

            await ReplyAsync(Message.Info.Generic, false, embed.Build());
        }
Ejemplo n.º 6
0
        public async Task Help()
        {
            var embed = EmbedTemplate.Create(Context.Client.CurrentUser, Context.User);

            embed.Title = "Inquisition Help:";

            foreach (var c in _commands.Commands)
            {
                string str = "";
                foreach (var a in c.Aliases.Skip(1))
                {
                    if (a != null)
                    {
                        str += a + " | ";
                    }
                }
                embed.AddField(c.Module.Aliases.FirstOrDefault() + " " + c.Name, $"Aliases: {str}\n\n{c.Summary ?? "No specific description"}");
            }
            await Context.User.SendMessageAsync(Message.Info.Generic, false, embed.Build());
        }
Ejemplo n.º 7
0
        public async Task ListAlertsAsync()
        {
            User         localUser = DatabaseHandler.GetFromDb(Context.User);
            List <Alert> Alerts    = DatabaseHandler.ListAll(new Alert(), localUser);

            if (Alerts.Count == 0)
            {
                await ReplyAsync(Message.Error.NoContentGeneric);

                return;
            }

            EmbedBuilder embed = EmbedTemplate.Create(Context.Client.CurrentUser, Context.User);

            foreach (Alert n in Alerts)
            {
                embed.AddField($"For when {n.TargetUser.Username} joins", $"Created: {n.CreatedAt}");
            }

            await ReplyAsync(Message.Info.Generic, false, embed.Build());
        }
Ejemplo n.º 8
0
        public async Task ListRemindersAsync()
        {
            User            localUser = DatabaseHandler.GetFromDb(Context.User);
            List <Reminder> Reminders = DatabaseHandler.ListAll(new Reminder(), localUser);

            if (Reminders.Count > 0)
            {
                EmbedBuilder embed = EmbedTemplate.Create(Context.Client.CurrentUser, Context.User);

                foreach (Reminder reminder in Reminders)
                {
                    embed.AddField($"{reminder.Id} - {reminder.Message ?? "No message"}", $"{reminder.DueDate}");
                }

                await ReplyAsync(Message.Info.Generic, false, embed.Build());
            }
            else
            {
                await ReplyAsync(Message.Error.NoContentGeneric);
            }
        }
Ejemplo n.º 9
0
        public async Task ListAllGamesAsync()
        {
            List <Data.Game> Games = DatabaseHandler.ListAll(new Data.Game());

            if (Games.Count > 0)
            {
                EmbedBuilder builder = EmbedTemplate.Create(Context.Client.CurrentUser, Context.User);

                foreach (Data.Game game in Games)
                {
                    string st = game.IsOnline ? "Online " : "Offline ";
                    builder.AddInlineField(game.Name, st + $"on: {game.Port}, v: {game.Version}");
                }

                await ReplyAsync(Message.Info.Generic, false, builder.Build());
            }
            else
            {
                await ReplyAsync(Message.Error.NoContent(Context.User));
            }
        }
Ejemplo n.º 10
0
        public async Task CreatePollAsync([Remainder] string r = "")
        {
            List <Emoji> reactions = new List <Emoji> {
                new Emoji("👍🏻"), new Emoji("👎🏻"), new Emoji("🤷🏻")
            };

            var messages = await Context.Channel.GetMessagesAsync(1).Flatten();

            await Context.Channel.DeleteMessagesAsync(messages);

            EmbedBuilder embed = EmbedTemplate.Create(Context.Client.CurrentUser, Context.User);

            embed.WithTitle(r);
            embed.WithFooter($"Asked by: {Context.User}", Context.User.GetAvatarUrl());

            var msg = await ReplyAsync("", false, embed.Build());

            foreach (Emoji e in reactions)
            {
                await msg.AddReactionAsync(e);
            }
        }