Ejemplo n.º 1
0
        public async Task <ICategoryChannel> GetCategory(IGuild guild)
        {
            if (GuildMap.TryGetValue(guild.Id, out var guildInfo))
            {
                if (guildInfo.Category == null)
                {
                    await createCategory(guild, guildInfo);

                    isDirty = true;
                }
                else if (guildInfo.Category.Name != guild.Name)
                {
                    await guildInfo.Category.ModifyAsync(x => x.Name = guild.Name);
                }
                return(guildInfo.Category);
            }
            var map = new guildSave()
            {
                Actions = new Dictionary <string, ITextChannel>()
            };

            await createCategory(guild, map);

            GuildMap[guild.Id] = map;
            isDirty            = true;
            return(map.Category);
        }
Ejemplo n.º 2
0
        async Task createCategory(IGuild guild, guildSave guildInfo)
        {
            guildInfo.Category = await LogGuild.CreateCategoryAsync(guild.Name);

            guildInfo.Role = await LogGuild.CreateRoleAsync(guild.Name, GuildPermissions.None, isMentionable : false);

            await guildInfo.Category.AddPermissionOverwriteAsync(LogGuild.EveryoneRole,
                                                                 new OverwritePermissions(viewChannel : PermValue.Deny, sendMessages : PermValue.Deny));

            await guildInfo.Category.AddPermissionOverwriteAsync(guildInfo.Role,
                                                                 new OverwritePermissions(viewChannel : PermValue.Allow));
        }