Пример #1
0
        public async Task AllRoles(params string[] _)
        {
            //string rlx = "```" + string.Join('\n', Context.Guild.Roles.OrderByDescending(x => x.Position).Select(x => $"{x.Name} ID: {x.Id}")) + "```";
            var paginatedMessage = new PaginatedMessage(PaginatedAppearanceOptions.Default, Context.Channel,
                                                        new PaginatedMessage.MessagePage("Loading..."))
            {
                Title     = $"All roles in {Context.Guild.Name}",
                Timestamp = DateTimeOffset.Now,
                Color     = Blurple
            };
            var embb = new List <EmbedFieldBuilder>();

            for (var y = 0; y < Context.Guild.Roles.Count; y++)
            {
                var x = Context.Guild.Roles.OrderByDescending(x => x.Position).ElementAt(y);
                embb.Add(new EmbedFieldBuilder
                {
                    Name  = x.Name,
                    Value =
                        $"ID: {x.Id}\nPermValue: [{x.Permissions.RawValue}](http://discordapi.com/permissions.html#{x.Permissions.RawValue})\n",
                    IsInline = y % 2 == 0
                });
            }

            ;
            paginatedMessage.SetPages("Here's a list of all roles in the Server", embb, 5);
            await paginatedMessage.Resend();
        }
Пример #2
0
        public async Task RBans(params string[] _)
        {
            var mbed = new EmbedBuilder
            {
                Title = "List of bans in the server",
                Color = Blurple
            }.WithCurrentTimestamp();
            var listwherenotnull = (await Context.Guild.GetBansAsync()).ToList();

            listwherenotnull.RemoveAll(k => k == null);
            var efb = listwherenotnull.Select((r5, idx) => new EmbedFieldBuilder
            {
                Name  = r5.User.ToString() == "" ? "Probably deleted" : r5.User.ToString(),
                Value = string.Join("", r5.Reason == null ? "None given" : r5.Reason.Take(2000))
            });
            var pm = new PaginatedMessage(PaginatedAppearanceOptions.Default, Context.Channel);

            pm.SetPages("Here are your bans", efb, 5);
            await pm.Resend();
        }
Пример #3
0
        public async Task MLogs(params string[] aa)
        {
            if (aa.Length == 0)
            {
                await ReplyAsync("", false, new EmbedBuilder
                {
                    Title       = "What user?",
                    Description = "Mention the user you wish to get modlogs of",
                    Color       = Color.Red
                }.WithCurrentTimestamp());

                return;
            }

            IUser user;

            if (await GetUser(aa[0]) == null)
            {
                var regex = new Regex(@"(\d{18}|\d{17})");
                if (regex.IsMatch(aa[0]))
                {
                    var aadrc = new DiscordRestClient();
                    await aadrc.LoginAsync(TokenType.Bot, Program.token);

                    var aala = await aadrc.GetUserAsync(ulong.Parse(regex.Match(aa[0]).Groups[1].Value));

                    if (aala == null)
                    {
                        await ReplyAsync("", false, new EmbedBuilder
                        {
                            Title       = "What user?",
                            Description = "That user isn't valid :(",
                            Color       = Color.Red
                        }.WithCurrentTimestamp());

                        return;
                    }

                    user = aala;
                }
                else if (Context.Message.MentionedUsers.Any())
                {
                    user = Context.Message.MentionedUsers.First();
                }
                else
                {
                    await ReplyAsync("", false, new EmbedBuilder
                    {
                        Title       = "What user?",
                        Description = "That user isn't valid :(",
                        Color       = Color.Red
                    }.WithCurrentTimestamp());

                    return;
                }
            }
            else
            {
                user = await GetUser(aa[0]);
            }

            var emb = new EmbedBuilder
            {
                Title        = $"Modlogs for user {user.Username}#{user.Discriminator}",
                Color        = Blurple,
                ThumbnailUrl = user.GetAvatarUrl(size: 64)
            };
            var eb = new List <EmbedFieldBuilder>();

            foreach (var i in await GetUserModlogs(Context.Guild.Id, user.Id))
            {
                eb.Add(new EmbedFieldBuilder
                {
                    Name  = Infraction.GetPunishment(i.Punishment),
                    Value =
                        $"**Mod:** <@{i.ModeratorId}>\n**Date:** {i.Time.ToUniversalTime().ToShortDateString()}\n**Time: **{(i.Time.ToUniversalTime().TimeOfDay.Hours <= 12 ? i.Time.ToUniversalTime().TimeOfDay.Hours : i.Time.ToUniversalTime().TimeOfDay.Hours - 12)}:{i.Time.ToUniversalTime().TimeOfDay.Minutes} {(i.Time.ToUniversalTime().TimeOfDay.Hours < 12 ? "AM" : "PM")}\n**Reason:** {i.Reason}",
                    IsInline = true
                });
            }
            if (eb.Count == 0)
            {
                emb.Description = "They've been a good user! No modlogs :)";
            }
            var pm = new PaginatedMessage(PaginatedAppearanceOptions.Default, Context.Message.Channel,
                                          new PaginatedMessage.MessagePage {
                Description = "Error!"
            });

            pm.SetPages("Here's a list of the user's modlogs", eb, 7);
            await pm.Resend();
        }
Пример #4
0
        public async Task AliasCommand(params string[] args)
        {
            if (args.Length == 0 || args.Length == 1)
            {
                /*
                 * await ReplyAsync("", false, new EmbedBuilder
                 * {
                 *  Title = "Insufficient Parameters",
                 *  Description = $"The way to use the command is `{await SqliteClass.PrefixGetter(Context.Guild.Id)}alias <alias-name> <cmd-and-parameters>`",
                 *  Color = Color.Red
                 * }.WithCurrentTimestamp());*/
                var paginatedMessage = new PaginatedMessage(new PaginatedAppearanceOptions
                {
                    FooterFormat =
                        $"Do {await SqliteClass.PrefixGetter(Context.Guild.Id)}help alias to know more about adding aliases"
                }, Context.Channel,
                                                            new PaginatedMessage.MessagePage("Error :/"));
                var loembb = (await SqliteClass.GuildAliasGetter(Context.Guild.Id)).Select(k => new EmbedFieldBuilder
                {
                    Name  = k.Item1,
                    Value = $"`{k.Item2}`"
                }).ToList();
                if (!loembb.Any())
                {
                    await ReplyAsync("", false, new EmbedBuilder
                    {
                        Title       = "No aliases yet",
                        Description = "Add aliases using `alias add <alias-name> <cmd-and-parameters>`",
                        Color       = Blurple
                    });

                    return;
                }

                paginatedMessage.SetPages("Here's a list of aliases that your server has", loembb, 7);
                await paginatedMessage.Resend();

                return;
            }

            switch (args[0])
            {
            case "add" or "+":
            {
                if (args.Length == 2)
                {
                    await ReplyAsync("", false, new EmbedBuilder
                        {
                            Title       = "Insufficient Parameters",
                            Description =
                                $"Command Syntax: `{await SqliteClass.PrefixGetter(Context.Guild.Id)}alias + <alias-name> <cmd-and-parameters>`",
                            Color = Color.Red
                        }.WithCurrentTimestamp());

                    return;
                }

                var cmdAlias = args[1];
                var cmd      = string.Join(' ', args.Skip(2));
                cmd = cmd.Replace("^", "\\^").Replace("|", "\\|");
                await SqliteClass.AliasAdder(Context.Guild.Id, cmdAlias, cmd);
                await ReplyAsync("", false, new EmbedBuilder
                    {
                        Title       = $"Successfully added alias {cmdAlias}",
                        Description = "Run `alias` to find the list of aliases in your guild!",
                        Color       = Blurple
                    });

                break;
            }

            case "remove" or "-":
            {
                var didItExist = await SqliteClass.AliasRemover(Context.Guild.Id, args[1]) != 0;

                if (!didItExist)
                {
                    await ReplyAsync("", false, new EmbedBuilder
                        {
                            Title       = "No such alias",
                            Description = "Run `alias` to find the list of aliases in your guild!",
                            Color       = Blurple
                        });
                }
                else
                {
                    await ReplyAsync("", false, new EmbedBuilder
                        {
                            Title       = "Deleted alias",
                            Description = "Run `alias` to find the list of aliases in your guild!",
                            Color       = Blurple
                        });
                }
                break;
            }

            default:
            {
                await ReplyAsync("", false, new EmbedBuilder
                    {
                        Title       = "Invalid Parameters",
                        Description =
                            $"The way to add aliases is \n`{await SqliteClass.PrefixGetter(Context.Guild.Id)}alias + <alias-name> <cmd-and-parameters>`\nand removing is\n`{await SqliteClass.PrefixGetter(Context.Guild.Id)}alias - <alias-name>`",
                        Color = Color.Red
                    }.WithCurrentTimestamp());

                break;
            }
            }
        }