private List <DiscordOverwriteBuilder> CreatePermissions(DiscordGuild guild, DiscordRole allowedRole, DiscordRole deniedRole)
        {
            var permissions = new List <DiscordOverwriteBuilder> ();

            var adminRole = guild.Roles.Values.Where(role => role.Name.Equals("smashfest-admin")).FirstOrDefault();

            if (adminRole != null)
            {
                var adminPermissions = new DiscordOverwriteBuilder();
                adminPermissions.For(adminRole);
                adminPermissions.Allow(Permissions.SendMessages);
                adminPermissions.Allow(Permissions.AccessChannels);
                adminPermissions.Allow(Permissions.PrioritySpeaker);
                permissions.Add(adminPermissions);
            }
            Console.WriteLine($"allowed: {allowedRole.Name}");
            DiscordOverwriteBuilder allowed = new DiscordOverwriteBuilder();

            allowed.For(allowedRole);
            allowed.Allow(Permissions.SendMessages);
            allowed.Allow(Permissions.AccessChannels);
            allowed.Allow(Permissions.ReadMessageHistory);
            permissions.Add(allowed);

            Console.WriteLine($"denied: {deniedRole.Name}");
            DiscordOverwriteBuilder denied = new DiscordOverwriteBuilder();

            denied.For(deniedRole);
            denied.Deny(Permissions.SendMessages);
            denied.Deny(Permissions.AccessChannels);
            denied.Deny(Permissions.ReadMessageHistory);
            permissions.Add(denied);

            return(permissions);
        }
Esempio n. 2
0
        private List <DiscordOverwriteBuilder> GetOverwrites(List <DiscordMember> v, DiscordGuild guild, DiscordMember owner)
        {
            v.Add(owner);

            List <DiscordOverwriteBuilder> res = new List <DiscordOverwriteBuilder>();
            //@everyone - READ FALSE, WRITE FALSE
            DiscordOverwriteBuilder v1 = new DiscordOverwriteBuilder();

            v1.For(guild.EveryoneRole);
            v1.Deny(Permissions.AccessChannels);
            v1.Deny(Permissions.SendMessages);
            res.Add(v1);

            //Frozen - WRITE FALSE
            DiscordOverwriteBuilder v7 = new DiscordOverwriteBuilder();

            v7.For(Dependencies.Settings.FrozenPlayerRole);
            v7.Deny(Permissions.SendMessages);
            res.Add(v7);

            //Participant - WRITE TRUE
            DiscordOverwriteBuilder v2 = new DiscordOverwriteBuilder();

            v2.For(Dependencies.Settings.AliveParticipantRole);
            v2.Allow(Permissions.SendMessages);
            res.Add(v2);

            //Dead - Read TRUE, Write FALSE
            DiscordOverwriteBuilder v3 = new DiscordOverwriteBuilder();

            v3.For(Dependencies.Settings.DeadParticipantRole);
            v3.Allow(Permissions.AccessChannels);
            v3.Deny(Permissions.SendMessages);
            res.Add(v3);

            //GM - Read TRUE, Write True
            DiscordOverwriteBuilder v4 = new DiscordOverwriteBuilder();

            v4.For(Dependencies.Settings.GameMasterRole);
            v4.Allow(Permissions.SendMessages);
            v4.Allow(Permissions.AccessChannels);
            res.Add(v4);

            foreach (var v5 in v)
            {
                DiscordOverwriteBuilder v6 = new DiscordOverwriteBuilder();
                v6.For(v5);
                v6.Allow(Permissions.AccessChannels);
                res.Add(v6);
            }

            return(res);
        }