Esempio n. 1
0
        public async Task ListPermissionsAsync(int methodID)
        {
            await Context.Guild.SyncGuildAsync().ConfigureAwait(false);

            var method = ConfigRepository.GetMethod(Context.Guild, methodID);

            await ReplyAsync($"ID: `{method.ID}`\nSkupina/Příkaz: `{method.Group}/{method.Command}`\nOnlyAdmins: `{method.OnlyAdmins}`").ConfigureAwait(false);

            var rowsData = method.Permissions.Select(o =>
            {
                switch (o.PermType)
                {
                case PermType.Role:
                    var role = Context.Guild.GetRole(o.DiscordIDSnowflake);
                    return($"{o.PermID}\t{role.Name} ({role.Id})\t{o.PermType}\t{o.AllowType}");

                case PermType.User:
                    var user = Context.Guild.GetUserFromGuildAsync(o.DiscordID).Result;
                    return($"{o.PermID}\t{user.GetFullName()}\t{o.PermType}\t{o.AllowType}");

                case PermType.Everyone:
                    return($"{o.PermID}\tEveryone\t-\t{o.AllowType}");
                }

                return(null);
            }).Where(o => o != null).ToList();

            if (rowsData.Count > 0)
            {
                rowsData.Insert(0, "ID\tUživatel/Role\tTyp práva\tTyp povolení");
                await ReplyAsync($"```{string.Join("\n", rowsData)}```").ConfigureAwait(false);
            }
            else
            {
                await ReplyAsync("Tato metoda nemá nastaveny žádné oprávnění.").ConfigureAwait(false);
            }
        }
Esempio n. 2
0
        public async Task GetJsonConfig(int methodID)
        {
            var config = ConfigRepository.GetMethod(Context.Guild, methodID);

            await ReplyAsync($"```json\n {config.ConfigData}```").ConfigureAwait(false);
        }