internal static RestGlobalCommand Create(BaseDiscordClient client, Model model) { var entity = new RestGlobalCommand(client, model.Id); entity.Update(model); return(entity); }
internal static RestGuildCommand Create(BaseDiscordClient client, Model model, ulong guildId) { var entity = new RestGuildCommand(client, model.Id, guildId); entity.Update(model); return(entity); }
internal static SocketApplicationCommand Create(DiscordSocketClient client, Model model, ulong?guildId = null) { var entity = new SocketApplicationCommand(client, model.Id, guildId); entity.Update(model); return(entity); }
internal static RestApplicationCommand Create(BaseDiscordClient client, Model model, RestApplicationCommandType type, ulong guildId = 0) { return(type switch { RestApplicationCommandType.GlobalCommand => RestGlobalCommand.Create(client, model), RestApplicationCommandType.GuildCommand => RestGuildCommand.Create(client, model, guildId), _ => null });
internal virtual void Update(Model model) { this.ApplicationId = model.ApplicationId; this.Name = model.Name; this.Description = model.Description; this.Options = model.Options.IsSpecified ? model.Options.Value.Select(x => RestApplicationCommandOption.Create(x)).ToImmutableArray() : null; }
internal void Update(Model model) { ApplicationId = model.ApplicationId; Description = model.Description; Name = model.Name; IsDefaultPermission = model.DefaultPermissions.GetValueOrDefault(true); Type = model.Type; Options = model.Options.IsSpecified ? model.Options.Value.Select(SocketApplicationCommandOption.Create).ToImmutableArray() : ImmutableArray.Create <SocketApplicationCommandOption>(); }
internal static RestApplicationCommand Create(BaseDiscordClient client, Model model, RestApplicationCommandType type, ulong guildId = 0) { if (type == RestApplicationCommandType.GlobalCommand) { return(RestGlobalCommand.Create(client, model)); } if (type == RestApplicationCommandType.GuildCommand) { return(RestGuildCommand.Create(client, model, guildId)); } return(null); }
internal virtual void Update(Model model) { Type = model.Type; ApplicationId = model.ApplicationId; Name = model.Name; Description = model.Description; IsDefaultPermission = model.DefaultPermissions.GetValueOrDefault(true); Options = model.Options.IsSpecified ? model.Options.Value.Select(RestApplicationCommandOption.Create).ToImmutableArray() : ImmutableArray.Create <RestApplicationCommandOption>(); IsEnabledInDm = model.DmPermission.GetValueOrDefault(true).GetValueOrDefault(true); DefaultMemberPermissions = new GuildPermissions((ulong)model.DefaultMemberPermission.GetValueOrDefault(0).GetValueOrDefault(0)); }
internal static RestApplicationCommand Create(BaseDiscordClient client, Model model, ulong?guildId) { return(guildId.HasValue ? RestGuildCommand.Create(client, model, guildId.Value) : RestGlobalCommand.Create(client, model)); }