internal static SocketRole Create(SocketGuild guild, ClientState state, Model model) { SocketRole entity = new SocketRole(guild, model.Id); entity.Update(state, model); return(entity); }
public static async Task <Model> ModifyAsync(IRole role, BaseDiscordClient client, Action <RoleProperties> func, RequestOptions options) { RoleProperties args = new RoleProperties(); func(args); API.Rest.ModifyGuildRoleParams apiArgs = new API.Rest.ModifyGuildRoleParams { Color = args.Color.IsSpecified ? args.Color.Value.RawValue : Optional.Create <uint>(), Hoist = args.Hoist, Mentionable = args.Mentionable, Name = args.Name, Permissions = args.Permissions.IsSpecified ? args.Permissions.Value.RawValue : Optional.Create <ulong>() }; Model model = await client.ApiClient.ModifyGuildRoleAsync(role.Guild.Id, role.Id, apiArgs, options).ConfigureAwait(false); if (args.Position.IsSpecified) { BulkParams[] bulkArgs = new[] { new BulkParams(role.Id, args.Position.Value) }; await client.ApiClient.ModifyGuildRolesAsync(role.Guild.Id, bulkArgs, options).ConfigureAwait(false); model.Position = args.Position.Value; } return(model); }
internal static RestRole Create(BaseDiscordClient discord, IGuild guild, Model model) { RestRole entity = new RestRole(discord, guild, model.Id); entity.Update(model); return(entity); }
internal void Update(ClientState state, Model model) { Name = model.Name; IsHoisted = model.Hoist; IsManaged = model.Managed; IsMentionable = model.Mentionable; Position = model.Position; Color = new Color(model.Color); Permissions = new GuildPermissions(model.Permissions); if (model.Tags.IsSpecified) { Tags = model.Tags.Value.ToEntity(); } }
/// <inheritdoc /> public async Task ModifyAsync(Action <RoleProperties> func, RequestOptions options = null) { Model model = await RoleHelper.ModifyAsync(this, Discord, func, options).ConfigureAwait(false); Update(model); }