Example #1
0
        private async Task AvatarAsync(ulong userid)
        {
            await Context.Message.DeleteAsync();

            IUser user = (await Context.Guild.GetUserAsync(userid) as IUser);

            if (user == null)
            {
                foreach (var guild in CommandHandler.GetBot().Guilds)
                {
                    if (await(guild as IGuild).GetUserAsync(userid) as IUser != null)
                    {
                        user = await(guild as IGuild).GetUserAsync(userid) as IUser;
                    }
                }
            }

            if (user == null)
            {
                user = (Context.User as IUser);
            }

            string       avatar = user.GetAvatarUrl(size: 2048);
            EmbedBuilder embed  = new EmbedBuilder()
            {
                Title    = $"{user.Username}#{user.Discriminator}",
                Color    = Color.DarkPurple,
                ImageUrl = avatar,
                Footer   = new EmbedFooterBuilder()
                {
                    Text = $"{EmojiUtil.GetRandomEmoji()}  Requested by {Context.User.Username}#{Context.User.Discriminator}."
                },
            };
            await Context.Channel.SendMessageAsync(null, false, embed.Build());
        }
Example #2
0
        private async Task BinaryAsync([Remainder] string text = null)
        {
            await Context.Message.DeleteAsync();

            if (text != null)
            {
                var binary = ToBinary(ConvertToByteArray(text, Encoding.ASCII));

                EmbedBuilder embed = new EmbedBuilder()
                {
                    Title       = $"Text to Binary",
                    Description = $"''{text}''\n\n{binary}",
                    Color       = Color.DarkPurple
                };
                embed.Footer = new EmbedFooterBuilder()
                {
                    Text = $"{EmojiUtil.GetRandomEmoji()}  Requested by {Context.User.Username}#{Context.User.Discriminator}."
                };
                await Context.Channel.SendMessageAsync(null, false, embed.Build());
            }
            else
            {
                BotConfig conf  = BotConfig.Load();
                var       gconf = conf.GetConfig(Context.Guild.Id);
                await MessageUtil.SendErrorAsync((Context.Channel as ITextChannel), "Incorrect Command Usage", $"Correct Usage: `{gconf.Prefix}binary <message>`", false);

                return;
            }
        }
Example #3
0
        private async Task HugAsync(IUser user = null)
        {
            await Context.Message.DeleteAsync();

            if (user == null)
            {
                BotConfig conf  = BotConfig.Load();
                var       gconf = conf.GetConfig(Context.Guild.Id);
                await MessageUtil.SendErrorAsync((Context.Channel as ITextChannel), "Incorrect Command Usage", $"Correct Usage: `{gconf.Prefix}hug <@user>`", false);

                return;
            }

            List <FunObject> hugs = await FunDatabase.GetOfTypeAsync("hug");

            Random rnd = new Random();
            int    g   = rnd.Next(0, hugs.Count);
            string GIF = hugs[g].Extra;

            EmbedBuilder embed = new EmbedBuilder()
            {
                Title    = $"{Context.User.Username} hugged {user.Username}",
                ImageUrl = GIF,
                Color    = Color.DarkPurple,
                Footer   = new EmbedFooterBuilder()
                {
                    Text = $"{EmojiUtil.GetRandomEmoji()}  Requested by {Context.User.ToString()}"
                }
            };
            await Context.Channel.SendMessageAsync(null, false, embed.Build());
        }
Example #4
0
        private async Task UsersAsync()
        {
            await Context.Message.DeleteAsync();

            var bot    = LCommandHandler.GetBot();
            int guilds = bot.Guilds.Count;
            int users  = (await Context.Guild.GetUsersAsync()).Count;
            int total  = 0;

            foreach (var guild in bot.Guilds)
            {
                total += guild.Users.Count;
            }

            EmbedBuilder embed = new EmbedBuilder()
            {
                Title       = "Lori's Angels Statistics",
                Color       = Color.DarkPurple,
                Description = $"Out of the {guilds} guilds I am watching {total} total users, {users} of which are from this guild!",
                Footer      = new EmbedFooterBuilder()
                {
                    Text = $"{EmojiUtil.GetRandomEmoji()}  Requested by {Context.User.Username}#{Context.User.Id}"
                }
            };

            await Context.Channel.SendMessageAsync(null, false, embed.Build());
        }
Example #5
0
        private async Task UptimeAsync()
        {
            await Context.Message.DeleteAsync();

            BotConfig conf    = BotConfig.Load();
            DateTime  time    = DateTime.UtcNow;
            int       minutes = (int)((time - conf.LastStartup).TotalMinutes);
            int       uptime  = 0;
            string    m       = "minutes";

            if (minutes >= 60)
            {
                uptime = minutes / 60;
                m      = "hours";
            }
            else
            {
                uptime = minutes;
            }

            EmbedBuilder embed = new EmbedBuilder()
            {
                Title       = "Lori's Angels Statistics",
                Color       = Color.DarkPurple,
                Description = $"Lori's Angel has been online since {time}, thats an uptime of {uptime} {m}!",
                Footer      = new EmbedFooterBuilder()
                {
                    Text = $"{EmojiUtil.GetRandomEmoji()}  Requested by {Context.User.Username}#{Context.User.Id}"
                }
            };

            await Context.Channel.SendMessageAsync(null, false, embed.Build());
        }
Example #6
0
        private async Task EightBallAsync([Remainder] string question = null)
        {
            await Context.Message.DeleteAsync();


            if (question != null)
            {
                string reply;
                Random rnd    = new Random();
                int    random = rnd.Next(0, 3);
                switch (random)
                {
                case 0:
                    int y = rnd.Next(0, YES_REPLIES.Length);
                    reply = YES_REPLIES[y];
                    break;

                case 1:
                    int n = rnd.Next(0, NO_REPLIES.Length);
                    reply = NO_REPLIES[n];
                    break;

                default:
                    int m = rnd.Next(0, MAYBE_REPLIES.Length);
                    reply = MAYBE_REPLIES[m];
                    break;
                }

                EmbedBuilder embed = new EmbedBuilder()
                {
                    Title       = question,
                    Description = reply + "!",
                    Color       = Color.DarkPurple,
                    Footer      = new EmbedFooterBuilder()
                    {
                        Text = $"{EmojiUtil.GetRandomEmoji()}  Requested by {Context.User.Username}#{Context.User.Discriminator}."
                    },
                };

                await Context.Channel.SendMessageAsync(null, false, embed.Build());
            }
            else
            {
                BotConfig conf  = BotConfig.Load();
                var       gconf = conf.GetConfig(Context.Guild.Id);
                await MessageUtil.SendErrorAsync((Context.Channel as ITextChannel), "Incorrect Command Usage", $"Correct Usage: `{gconf.Prefix}8ball <question>`", false);

                return;
            }
        }
Example #7
0
        private async Task WhoAsync([Remainder] string question = null)
        {
            await Context.Message.DeleteAsync();

            if (question == null)
            {
                BotConfig conf  = BotConfig.Load();
                var       gconf = conf.GetConfig(Context.Guild.Id);
                await MessageUtil.SendErrorAsync((Context.Channel as ITextChannel), "Incorrect Command Usage", $"Correct Usage: `{gconf.Prefix}who <question>`", false);

                return;
            }

            ulong[] mentions = Context.Message.MentionedUserIds.ToArray <ulong>();

            IGuildUser answerUser;

            if (mentions.Length > 0)
            {
                Random rnd    = new Random();
                int    answer = rnd.Next(0, mentions.Length);
                answerUser = await Context.Guild.GetUserAsync(mentions[answer]);
            }
            else
            {
                var users = await Context.Guild.GetUsersAsync();

                Random rnd    = new Random();
                int    answer = rnd.Next(0, users.Count);
                answerUser = users.ToArray()[answer];
            }

            EmbedBuilder embed = new EmbedBuilder()
            {
                Title       = $"Who {await StringUtil.GetReadableMentionsAsync(Context.Guild as IGuild, question.ToLower())}",
                Description = $"The answer to that would be {answerUser.Username}.",
                Color       = Color.DarkPurple,
                Footer      = new EmbedFooterBuilder()
                {
                    Text = $"{EmojiUtil.GetRandomEmoji()}  Requested by {Context.User.Username}#{Context.User.Discriminator}"
                }
            };

            await Context.Channel.SendMessageAsync(null, false, embed.Build());
        }
Example #8
0
        private async Task TempBanMemberAsync(IUser user = null, int time = 60, string reason = null)
        {
            await Context.Message.DeleteAsync();

            BotConfig conf  = BotConfig.Load();
            var       gconf = conf.GetConfig(Context.Guild.Id);

            if (user == null)
            {
                await MessageUtil.SendErrorAsync((Context.Channel as ITextChannel), "Incorrect Command Usage", $"Correct Usage: `{gconf.Prefix}ban <user> <time> [reason]`", false);

                return;
            }

            if (reason == null)
            {
                reason = "Banned by " + Context.User.Username + "#" + Context.User.Discriminator + " for " + time + " minutes";
            }
            else
            {
                reason += " - Banned by " + Context.User.Username + "#" + Context.User.Discriminator + " for " + time + " minutes";
            }

            await BanMemberAsync(user, reason);

            await ModerationDatabase.AddTempBanAsync(Context.Guild.Id, user.Id, DateTime.Now.AddMinutes(time));

            EmbedBuilder embed = new EmbedBuilder()
            {
                Title       = user.Username + " was temp banned",
                Description = reason,
                Color       = Color.DarkPurple,
                Footer      = new EmbedFooterBuilder()
                {
                    Text = $"{EmojiUtil.GetRandomEmoji()}  Edit moderation settings on the webpanel."
                }
            };

            await CreateLogAsync(gconf, embed);
        }
Example #9
0
        private async Task DiceAsync(int amount = 1)
        {
            await Context.Message.DeleteAsync();

            if (amount < 1)
            {
                amount = 1;
            }
            else if (amount > 100)
            {
                amount = 100;
            }

            Random     rnd   = new Random();
            List <int> rolls = new List <int>();
            int        total = 0;
            string     text  = "";

            for (int i = 0; i < amount; i++)
            {
                int roll = rnd.Next(1, 7);
                rolls.Add(roll);
                total += roll;
                text  += $"**{roll}**, ";
            }
            text = text.Substring(0, text.Length - 2);

            EmbedBuilder embed = new EmbedBuilder()
            {
                Title       = "Dice Roll",
                Description = $"You rolled **{amount}** dice for **{total}**! Dice: [{text}]",
                Color       = Color.DarkPurple,
                Footer      = new EmbedFooterBuilder()
                {
                    Text = $"{EmojiUtil.GetRandomEmoji()}  Requested by {Context.User.Username}#{Context.User.Discriminator}"
                }
            };

            await Context.Channel.SendMessageAsync(null, false, embed.Build());
        }
Example #10
0
        public async Task OldestAsync()
        {
            await Context.Message.DeleteAsync();

            IUser oldest = null;

            foreach (var user in await Context.Guild.GetUsersAsync())
            {
                if (!user.IsBot)
                {
                    if (oldest == null)
                    {
                        oldest = user;
                    }
                    else if (oldest.CreatedAt.Date > user.CreatedAt.Date)
                    {
                        oldest = user;
                    }
                }
            }

            if (oldest != null)
            {
                EmbedBuilder embed = new EmbedBuilder()
                {
                };
                embed.WithAuthor(new EmbedAuthorBuilder()
                {
                    Name = oldest.Username + "#" + oldest.Discriminator, IconUrl = oldest.GetAvatarUrl()
                });
                embed.WithDescription($"The oldest account in the server, first registered {oldest.CreatedAt.Date}!");
                embed.WithColor(Color.DarkPurple);
                embed.Footer = new EmbedFooterBuilder()
                {
                    Text = $"{EmojiUtil.GetRandomEmoji()}  Requested by {Context.User.Username}#{Context.User.Discriminator}."
                };
                await Context.Channel.SendMessageAsync(null, false, embed.Build());
            }
        }
Example #11
0
        private async Task KickMemberAsync(IUser user = null, string reason = null)
        {
            await Context.Message.DeleteAsync();

            BotConfig conf  = BotConfig.Load();
            var       gconf = conf.GetConfig(Context.Guild.Id);

            if (user == null)
            {
                await MessageUtil.SendErrorAsync((Context.Channel as ITextChannel), "Incorrect Command Usage", $"Correct Usage: `{gconf.Prefix}kick <user> <reason>`", false);

                return;
            }

            if (reason == null)
            {
                reason = "Kicked by " + Context.User.Username + "#" + Context.User.Discriminator;
            }
            else
            {
                reason += " - Kicked by " + Context.User.Username + "#" + Context.User.Discriminator;
            }

            await KickMemberAsync(user, reason);

            EmbedBuilder embed = new EmbedBuilder()
            {
                Title       = user.Username + " was kicked",
                Description = reason,
                Color       = Color.DarkPurple,
                Footer      = new EmbedFooterBuilder()
                {
                    Text = $"{EmojiUtil.GetRandomEmoji()}  Edit moderation settings on the webpanel."
                }
            };

            await CreateLogAsync(gconf, embed);
        }
Example #12
0
        private async Task AvatarAsync(IUser user = null)
        {
            await Context.Message.DeleteAsync();

            if (user == null)
            {
                user = (Context.User as IUser);
            }
            string avatar = user.GetAvatarUrl(size: 2048);

            EmbedBuilder embed = new EmbedBuilder()
            {
                Title    = $"{user.Username}#{user.Discriminator}",
                Color    = Color.DarkPurple,
                ImageUrl = avatar,
                Footer   = new EmbedFooterBuilder()
                {
                    Text = $"{EmojiUtil.GetRandomEmoji()}  Requested by {Context.User.Username}#{Context.User.Discriminator}."
                },
            };

            await Context.Channel.SendMessageAsync(null, false, embed.Build());
        }
Example #13
0
        private async Task EpicRatingAsync(IUser user = null)
        {
            await Context.Message.DeleteAsync();

            if (user == null)
            {
                user = Context.User as IUser;
            }

            Random rnd    = new Random();
            float  rating = (float)(rnd.Next(0, 100) + rnd.NextDouble());

            if (user.IsBot && user.Id != 729696788097007717L)
            {
                rating = (float)(rnd.Next(0, 20) + rnd.NextDouble());
            }
            else if (user.IsBot && user.Id == 729696788097007717L)
            {
                rating = (float)(rnd.Next(80, 20) + rnd.NextDouble());
            }

            EmbedBuilder embed = new EmbedBuilder()
            {
                Author = new EmbedAuthorBuilder()
                {
                    IconUrl = user.GetAvatarUrl(), Name = user.Username
                },
                Description = $"You are {rating}% EPIC!",
                Color       = Color.DarkPurple,
                Footer      = new EmbedFooterBuilder()
                {
                    Text = $"{EmojiUtil.GetRandomEmoji()}  Requested by {Context.User.Username}#{Context.User.Discriminator}"
                }
            };
            await Context.Channel.SendMessageAsync(null, false, embed.Build());
        }
Example #14
0
        private async Task ShipAsync(IUser user = null, IUser user1 = null)
        {
            await Context.Message.DeleteAsync();

            if (user == null)
            {
                BotConfig conf  = BotConfig.Load();
                var       gconf = conf.GetConfig(Context.Guild.Id);
                await MessageUtil.SendErrorAsync((Context.Channel as ITextChannel), "Incorrect Command Usage", $"Correct Usage: `{gconf.Prefix}ship <user>` or `{gconf.Prefix}ship <user1> <user2>`", false);

                return;
            }
            if (user1 == null)
            {
                user1 = (Context.User as IUser);
            }

            string name1      = StringUtil.ToUppercaseFirst(user.Username);
            string name2      = StringUtil.ToUppercaseFirst(user1.Username);
            string title      = "";
            string message    = "";
            int    score      = 0;
            string name       = "";
            string desc       = "";
            float  percentage = 0f;

            // Check if entry exists in database
            var ship = RelationshipDatabase.DoesExist(user.Id, user1.Id);

            if (ship != null)
            {
                score      = ship.Percentage;
                name       = ship.Shipname;
                desc       = ship.ToDescriptiveString();
                percentage = ship.ToActualPercentage();
            }
            else
            {
                Random rnd = new Random();
                score = rnd.Next(10, 10000);
                name  = $"{name1[0].ToString().ToUpper()}{name1[1]}{name2[name2.Length - 3]}{name2[name2.Length - 2]}{name2[name2.Length - 1]}";

                ship = new LoriShip(user.Id, user1.Id, name1, name2, name, score);
                RelationshipDatabase.SaveShip(ship);
            }

            if (percentage > 95f)
            {
                title   = $"{name1} ๐Ÿ’˜ {name2}";
                message = desc;
            }
            else if (percentage > 55f)
            {
                title   = $"{name1} โค๏ธ {name2}";
                message = desc;
            }
            else
            {
                title   = $"{name1} ๐Ÿ’” {name2}";
                message = desc;
            }

            EmbedBuilder embed = new EmbedBuilder()
            {
                Color       = Color.DarkPurple,
                Title       = title,
                Description = message,
                Footer      = new EmbedFooterBuilder()
                {
                    Text = $"{EmojiUtil.GetRandomEmoji()}  Requested by {Context.User.Username}#{Context.User.Discriminator}."
                },
            };
            await Context.Channel.SendMessageAsync(null, false, embed.Build());
        }
Example #15
0
        private async Task ViewProfileAsync(ICommandContext Context, IUser User)
        {
            if (User.IsBot)
            {
                await MessageUtil.SendErrorAsync((Context.Channel as ITextChannel), "Profile Not Found", $"You can not use this command on bots!", false);

                return;
            }

            while (!ProfileDatabase.Ready())
            {
                await Task.Delay(50);
            }

            LoriUser profile = ProfileDatabase.GetUser(User.Id);

            if (profile == null)
            {
                await MessageUtil.SendErrorAsync((Context.Channel as ITextChannel), "Profile Not Found", $"That users profile could not be found?", false);

                return;
            }

            string avatar = User.GetAvatarUrl(size: 2048);
            string status = "**" + User.Status.ToString() + " for ";

            Color color;

            switch (User.Status)
            {
            case UserStatus.Offline:
                color = Color.LightGrey;
                break;

            case UserStatus.Online:
                color = Color.Green;
                break;

            case UserStatus.Idle:
                color = Color.Orange;
                break;

            case UserStatus.AFK:
                color = Color.Orange;
                break;

            case UserStatus.DoNotDisturb:
                color = Color.Red;
                break;

            case UserStatus.Invisible:
                color = Color.LightGrey;
                break;

            default:
                color = Color.LightGrey;
                break;
            }

            DateTime now     = DateTime.Now;
            int      seconds = (int)((now - profile.LastSeen).TotalSeconds);
            int      minutes = (int)((now - profile.LastSeen).TotalMinutes);
            int      hours   = (int)((now - profile.LastSeen).TotalHours);
            int      days    = (int)((now - profile.LastSeen).TotalDays);

            if (days > 0)
            {
                status += $"{days} Days and {hours - (days * 24)} Hours**";
            }
            else if (hours > 0)
            {
                status += $"{hours} Hours and {minutes - (hours * 60)} Minutes**";
            }
            else if (minutes > 0)
            {
                status += $"{minutes} Minutes and {seconds - (minutes * 60)} Seconds**";
            }
            else
            {
                status += $"{seconds} Seconds**";
            }

            if (User.Status == UserStatus.Offline || User.Status == UserStatus.Invisible)
            {
                status += $"\n _{profile.Activity}_";
            }
            else
            {
                status += $"\n {profile.Activity}";
            }

            if (profile.Motto.Length > 0)
            {
                status += $"\n**Motto:** {profile.Motto}";
            }

            EmbedBuilder embed = new EmbedBuilder()
            {
                Author = new EmbedAuthorBuilder()
                {
                    IconUrl = avatar, Name = $"{User.Username}#{User.Discriminator}"
                },
                Description = status,
                Color       = color,
                Footer      = new EmbedFooterBuilder()
                {
                    Text = $"{EmojiUtil.GetRandomEmoji()}  This is a temporary look for profiles..."
                },
            };

            embed.AddField(new EmbedFieldBuilder()
            {
                Name = "Account Created On: ", Value = profile.CreatedOn.ToShortDateString(), IsInline = true
            });
            embed.AddField(new EmbedFieldBuilder()
            {
                Name = "Profile Created On: ", Value = profile.JoinedOn.ToShortDateString(), IsInline = true
            });
            embed.AddField(new EmbedFieldBuilder()
            {
                Name = "Last Updated On: ", Value = profile.LastUpdated.ToShortDateString(), IsInline = true
            });
            embed.AddField(new EmbedFieldBuilder()
            {
                Name = "Unique Identifier: ", Value = profile.Id, IsInline = true
            });
            embed.AddField(new EmbedFieldBuilder()
            {
                Name = "Username: "******"#" + User.Discriminator, IsInline = true
            });
            embed.AddField(new EmbedFieldBuilder()
            {
                Name = "Lori's Angel Guilds: ", Value = LCommandHandler.GetUserGuildCount(User.Id), IsInline = true
            });

            ProfileRenderer renderer = new ProfileRenderer(User.Id, profile);

            renderer.Render();
            await Context.Channel.SendFileAsync(renderer.GetPath());

            renderer.Dispose();

            await Context.Channel.SendMessageAsync(null, false, embed.Build());
        }
Example #16
0
        public static EmbedBuilder GetCommandHelp(ulong guildId, string c = null, int page = 1)
        {
            BotConfig         conf     = BotConfig.Load();
            IndividualConfig  gconf    = conf.GetConfig(guildId);
            List <BotCommand> commands = conf.Commands;
            int pages;

            CommandCategory category = CommandCategory.Main;

            if (c != null)
            {
                c = c.ToLower().Trim();

                switch (c)
                {
                case "fun":
                    category = CommandCategory.Fun;
                    break;

                case "user":
                    category = CommandCategory.User;
                    break;

                case "server":
                    category = CommandCategory.Server;
                    break;

                case "botrelated":
                    category = CommandCategory.BotRelated;
                    break;

                case "moderation":
                    category = CommandCategory.Moderation;
                    break;

                case "games":
                    category = CommandCategory.Games;
                    break;

                case "nsfw":
                    category = CommandCategory.NSFW;
                    break;

                case "currency":
                    category = CommandCategory.Currency;
                    break;

                default:
                    category = CommandCategory.Main;
                    break;
                }
            }


            List <CommandCategory> cats           = new List <CommandCategory>();
            List <BotCommand>      commandsToShow = new List <BotCommand>();

            bool       displayCommandInfo = false;
            BotCommand commandToDisplay   = null;

            foreach (BotCommand command in commands)
            {
                if (c != null)
                {
                    if (command.Handle.ToLower() == c.ToLower().Trim())
                    {
                        commandToDisplay   = command;
                        displayCommandInfo = true;
                        break;
                    }
                }

                if (category == CommandCategory.Main)
                {
                    if (!cats.Contains(command.Category))
                    {
                        cats.Add(command.Category);
                    }
                }
                if (command.Category == category)
                {
                    if (!commandsToShow.Contains(command))
                    {
                        commandsToShow.Add(command);
                    }
                }
            }

            EmbedBuilder embed;

            if (!displayCommandInfo)
            {
                if (category == CommandCategory.Main)
                {
                    pages = (cats.Count / 10);
                }
                else
                {
                    pages = (commandsToShow.Count / 8);
                }

                if (page > pages)
                {
                    page = pages;
                }

                embed = new EmbedBuilder()
                {
                    Title  = "Help: " + StringUtil.ToUppercaseFirst(category.ToString()),
                    Color  = Color.DarkPurple,
                    Footer = new EmbedFooterBuilder()
                    {
                        Text = $"{EmojiUtil.GetRandomEmoji()}  Server Prefix: {gconf.Prefix}"
                    }
                };

                if (category == CommandCategory.Main)
                {
                    embed.Description = $"For further help use `{gconf.Prefix}help <commandCategory>`, for example `{gconf.Prefix}help fun`";

                    foreach (var cat in cats)
                    {
                        embed.AddField(new EmbedFieldBuilder()
                        {
                            Name = StringUtil.ToUppercaseFirst(cat.ToString()), Value = "category description", IsInline = true
                        });
                    }
                }
                else
                {
                    embed.Description = $"For further help use `{gconf.Prefix}help <commandName>`, for example `{gconf.Prefix}help roast`";

                    foreach (var command in commandsToShow)
                    {
                        embed.AddField(new EmbedFieldBuilder()
                        {
                            Name = StringUtil.ToUppercaseFirst(command.Handle), Value = command.Description, IsInline = true
                        });
                    }
                }
            }
            else
            {
                embed = new EmbedBuilder()
                {
                    Title  = "Help: " + StringUtil.ToUppercaseFirst(commandToDisplay.Handle),
                    Color  = Color.DarkPurple,
                    Footer = new EmbedFooterBuilder()
                    {
                        Text = $"{EmojiUtil.GetRandomEmoji()}  <> - Required argument, [] - Optional argument"
                    }
                };

                string desc = $"{commandToDisplay.Description}\n\n**Usage:**";

                foreach (var usage in commandToDisplay.Usage)
                {
                    desc += $"\n**{gconf.Prefix}{usage.ToString()}** (eg. {gconf.Prefix}{usage.ToExample()})";
                }

                embed.Description = desc;
            }

            return(embed);
        }
Example #17
0
        // TODO: UPDATE TO USE NEW USAGE PARAMS
        public static async Task HelpAsync(ICommandContext Context, string section = "")
        {
            await Context.Message.DeleteAsync();

            BotConfig conf = BotConfig.Load();

            string CommandHelpText            = "";
            List <CommandCategory> Categories = new List <CommandCategory>();
            bool   hasNewCommands             = false;
            bool   isSpecificCommand          = false;
            string CategoryText = "";
            string Prefix       = CommandHandler.GetPrefix(Context.Guild.Id);

            foreach (BotCommand command in conf.Commands)
            {
                if (command.Category.ToString().ToLower() == section.ToLower() || (section.ToLower() == "new" && command.New))
                {
                    if (CommandHelpText.Length > 0)
                    {
                        CommandHelpText = CommandHelpText + ", " + StringUtil.ToUppercaseFirst(command.Name);
                    }
                    else
                    {
                        CommandHelpText = StringUtil.ToUppercaseFirst(command.Name);
                    }
                }

                if (command.Name.ToLower() == section.ToLower())
                {
                    string help = $"**{command.Name.ToUpper()}**\nUsage:\n{command.Usage}\n{command.Description}";
                    if (command.New)
                    {
                        help = $"**NEW** - {help}";
                    }
                    if (command.ExtraInfo != "")
                    {
                        help = $"{help}\nFeature requested by: {command.ExtraInfo}";
                    }

                    CommandHelpText   = CommandHelpText + "\n\n" + help;
                    isSpecificCommand = true;
                }

                if (!Categories.Contains(command.Category))
                {
                    Categories.Add(command.Category);
                    CategoryText = $"{CategoryText}, {StringUtil.ToUppercaseFirst(command.Category.ToString())}";
                }
                if (command.New)
                {
                    hasNewCommands = true;
                }
            }
            CategoryText = CategoryText.Split(",", 2)[1];
            if (hasNewCommands)
            {
                CategoryText = $"{CategoryText}, New";
            }

            if (CommandHelpText.Length <= 0)
            {
                CommandHelpText = $"Command Usage: {Prefix}help <category>\n\nCategories:\n{CategoryText}\n\nKnown Errors:\nerror 50007 - Users privacy settings prevent dm's\nerror 403 - Bot does not have required permissions\nOther errors are tracked by the bot, and will be looked into.";
            }
            else if (!isSpecificCommand)
            {
                CommandHelpText = $"Command Usage: {Prefix}help <command>\n\n{StringUtil.ToUppercaseFirst(section)} Commands:\n{CommandHelpText}";
            }

            EmbedBuilder embed = new EmbedBuilder()
            {
                Title       = "Bot Command Help",
                Description = CommandHelpText,
                Color       = Color.DarkPurple,
                Footer      = new EmbedFooterBuilder()
                {
                    Text = $"{EmojiUtil.GetRandomEmoji()}  Bot Prefix: {Prefix}"
                }
            };

            await Context.Channel.SendMessageAsync(null, false, embed.Build());
        }
Example #18
0
        /***
         *  Remove any bans that have timed out
         */
        public static async Task ProcessBansAsync()
        {
            var processBans = Task.Run(async() =>
            {
                while (true)
                {
                    var dbCon          = DBConnection.Instance();
                    dbCon.DatabaseName = LCommandHandler.DATABASE_NAME;
                    BotConfig conf     = BotConfig.Load();

                    if (dbCon.IsConnect())
                    {
                        var cmd    = new MySqlCommand($"SELECT * FROM tempbans", dbCon.Connection);
                        var reader = cmd.ExecuteReader();
                        if (reader.HasRows)
                        {
                            while (reader.Read())
                            {
                                DateTime bannedTill = reader.GetDateTime(2);
                                if (bannedTill < DateTime.Now)
                                {
                                    ulong guildid = reader.GetUInt64(0);
                                    ulong userid  = reader.GetUInt64(1);

                                    var guild = CommandHandler.GetBot().GetGuild(guildid);

                                    if (guild != null)
                                    {
                                        var gconf = conf.GetConfig(guild.Id);
                                        if (gconf.LogActions)
                                        {
                                            var logs = guild.GetTextChannel(gconf.LogChannel);
                                            if (logs != null)
                                            {
                                                EmbedBuilder embed = new EmbedBuilder()
                                                {
                                                    Title       = "User Unbanned",
                                                    Description = $"A users temp ban was removed. Check audit log for more info.",
                                                    Color       = Color.DarkPurple,
                                                    Footer      = new EmbedFooterBuilder()
                                                    {
                                                        Text = $"{EmojiUtil.GetRandomEmoji()}  Edit moderation settings on the webpanel."
                                                    }
                                                };
                                                await logs.SendMessageAsync(null, false, embed.Build());
                                            }
                                        }

                                        await guild.RemoveBanAsync(userid);
                                    }

                                    var removecmd = new MySqlCommand($"REMOVE FROM tempbans WHERE userid = '{userid}'", dbCon.Connection);
                                    try
                                    {
                                        await removecmd.ExecuteNonQueryAsync();
                                        removecmd.Dispose();
                                    }
                                    catch (Exception e)
                                    {
                                        Console.WriteLine($"Failed to remove temp ban: {e.Message}");
                                        removecmd.Dispose();
                                    }
                                }
                            }
                        }

                        reader.Close();
                        cmd.Dispose();
                        dbCon.Close();
                    }

                    await Task.Delay(60000);
                }
            });
        }