Esempio n. 1
0
        private static List <RoleDupe> DuplicateRoles(Guild targetGuild, Guild ourGuild)
        {
            List <RoleDupe> ourRoles = new List <RoleDupe>();

            Console.WriteLine("Duplicating roles...");

            //duplicate roles
            foreach (var role in targetGuild.GetRoles())
            {
                RoleDupe dupe = new RoleDupe
                {
                    TargetRole = role
                };

                if (role.Name == "@everyone") //we don't wanna create another @everyone role, so we just modify ours instead
                {
                    DiscordRole ourRole = ourGuild.GetRoles().First(r => r.Name == "@everyone");
                    ourRole.Modify(new RoleProperties()
                    {
                        Permissions = new DiscordEditablePermissions(role.Permissions), Color = role.Color, Mentionable = role.Mentionable, Seperated = role.Seperated
                    });
                    dupe.OurRole = ourRole;
                }
                else
                {
                    dupe.OurRole = ourGuild.CreateRole(new RoleProperties()
                    {
                        Name = role.Name, Permissions = new DiscordEditablePermissions(role.Permissions), Color = role.Color, Mentionable = role.Mentionable, Seperated = role.Seperated
                    });
                }
                ourRoles.Add(dupe);

                Console.WriteLine($"Duplicated {role}");
            }

            return(ourRoles);
        }