Exemplo n.º 1
0
        public void Modify(RoleProperties properties)
        {
            if (!properties.NameProperty.Set)
            {
                properties.Name = Name;
            }
            if (!properties.ColorProperty.Set)
            {
                properties.Color = Color;
            }
            if (!properties.SeperatedProperty.Set)
            {
                properties.Seperated = Seperated;
            }
            if (!properties.MentionableProperty.Set)
            {
                properties.Mentionable = Mentionable;
            }
            if (properties.Permissions == null)
            {
                properties.Permissions = new EditablePermissions(Permissions);
            }

            Role role = Client.ModifyGuildRole(GuildId, Id, properties);

            Name        = role.Name;
            Permissions = role.Permissions;
            Color       = role.Color;
            Seperated   = role.Seperated;
            Position    = role.Position;
        }
Exemplo n.º 2
0
        /// <summary>
        /// Modifies the role
        /// </summary>
        /// <param name="properties">Options for modifying the role</param>
        public void Modify(RoleProperties properties)
        {
            Role role = Client.ModifyGuildRole(GuildId, Id, properties);

            Name        = role.Name;
            Permissions = role.Permissions;
            Color       = role.Color;
            Seperated   = role.Seperated;
            Position    = role.Position;
        }
Exemplo n.º 3
0
        /// <summary>
        /// Modifies the role
        /// </summary>
        /// <param name="properties">Options for modifying the role</param>
        public new void Modify(RoleProperties properties)
        {
            DiscordRole role = base.Modify(properties);

            Name        = role.Name;
            Permissions = role.Permissions;
            Color       = role.Color;
            Seperated   = role.Seperated;
            Position    = role.Position;
        }
Exemplo n.º 4
0
        /// <summary>
        /// Creates a role
        /// </summary>
        /// <param name="guildId">ID of the guild</param>
        /// <param name="properties">Options for modifying the created ole</param>
        /// <returns>The created <see cref="Role"/></returns>
        public static Role CreateGuildRole(this DiscordClient client, ulong guildId, RoleProperties properties = null)
        {
            Role role = client.HttpClient.Post($"/guilds/{guildId}/roles")
                        .Deserialize <Role>().SetClient(client);

            role.GuildId = guildId;
            if (properties != null)
            {
                role.Modify(properties);
            }
            return(role);
        }
Exemplo n.º 5
0
        /// <summary>
        /// Modifies a role
        /// </summary>
        /// <param name="guildId">ID of the guild</param>
        /// <param name="roleId">ID of the role</param>
        /// <param name="properties"></param>
        /// <returns>The modified <see cref="Role"/></returns>
        public static Role ModifyGuildRole(this DiscordClient client, ulong guildId, ulong roleId, RoleProperties properties)
        {
            Role changed = client.HttpClient.Patch($"/guilds/{guildId}/roles/{roleId}",
                                                   JsonConvert.SerializeObject(properties)).Deserialize <Role>().SetClient(client);

            changed.GuildId = guildId;
            return(changed);
        }
Exemplo n.º 6
0
 /// <summary>
 /// Modifies the role
 /// </summary>
 /// <param name="properties">Options for modifying the role</param>
 public DiscordRole Modify(RoleProperties properties)
 {
     return(Client.ModifyRole(GuildId, Id, properties));
 }
Exemplo n.º 7
0
 /// <summary>
 /// Creates a role
 /// </summary>
 /// <param name="properties">Options for modifying the role after creating it</param>
 /// <returns>The created role</returns>
 public DiscordRole CreateRole(RoleProperties properties = null)
 {
     return(CreateRoleAsync(properties).GetAwaiter().GetResult());
 }
Exemplo n.º 8
0
 public async Task <DiscordRole> CreateRoleAsync(RoleProperties properties = null)
 {
     return(await Client.CreateRoleAsync(Id, properties));
 }
Exemplo n.º 9
0
 /// <summary>
 /// Creates a role
 /// </summary>
 /// <param name="properties">Options for modifying the role after creating it</param>
 /// <returns>The created role</returns>
 public DiscordRole CreateRole(RoleProperties properties = null)
 {
     return(Client.CreateGuildRole(Id, properties));
 }
Exemplo n.º 10
0
 /// <summary>
 /// Modifies the role
 /// </summary>
 /// <param name="properties">Options for modifying the role</param>
 public DiscordRole Modify(RoleProperties properties)
 {
     return(ModifyAsync(properties).GetAwaiter().GetResult());
 }
Exemplo n.º 11
0
 public async Task <DiscordRole> ModifyAsync(RoleProperties properties)
 {
     return(await Client.ModifyRoleAsync(GuildId, Id, properties));
 }
Exemplo n.º 12
0
        /// <summary>
        /// Modifies a role
        /// </summary>
        /// <param name="guildId">ID of the guild</param>
        /// <param name="roleId">ID of the role</param>
        /// <param name="properties"></param>
        /// <returns>The modified <see cref="DiscordRole"/></returns>
        public static DiscordRole ModifyRole(this DiscordClient client, ulong guildId, ulong roleId, RoleProperties properties)
        {
            DiscordRole changed = client.HttpClient.Patch($"/guilds/{guildId}/roles/{roleId}", properties).Deserialize <DiscordRole>().SetClient(client);

            changed.GuildId = guildId;
            return(changed);
        }
Exemplo n.º 13
0
        public static async Task <DiscordRole> CreateRoleAsync(this DiscordClient client, ulong guildId, RoleProperties properties = null)
        {
            DiscordRole role = (await client.HttpClient.PostAsync($"/guilds/{guildId}/roles"))
                               .Deserialize <DiscordRole>().SetClient(client);

            role.GuildId = guildId;
            if (properties != null)
            {
                role.Modify(properties);
            }
            return(role);
        }
Exemplo n.º 14
0
 /// <summary>
 /// Modifies a role
 /// </summary>
 /// <param name="guildId">ID of the guild</param>
 /// <param name="roleId">ID of the role</param>
 /// <param name="properties"></param>
 /// <returns>The modified <see cref="DiscordRole"/></returns>
 public static DiscordRole ModifyRole(this DiscordClient client, ulong guildId, ulong roleId, RoleProperties properties)
 {
     return(client.ModifyRoleAsync(guildId, roleId, properties).GetAwaiter().GetResult());
 }
Exemplo n.º 15
0
 /// <summary>
 /// Creates a role
 /// </summary>
 /// <param name="guildId">ID of the guild</param>
 /// <param name="properties">Options for modifying the created ole</param>
 /// <returns>The created <see cref="DiscordRole"/></returns>
 public static DiscordRole CreateRole(this DiscordClient client, ulong guildId, RoleProperties properties = null)
 {
     return(client.CreateRoleAsync(guildId, properties).GetAwaiter().GetResult());
 }