| @@ -0,0 +1,23 @@ | |||||
| using System; | |||||
| using System.Collections.Generic; | |||||
| using System.Linq; | |||||
| using System.Text; | |||||
| using System.Threading.Tasks; | |||||
| namespace Discord | |||||
| { | |||||
| /// <summary> | |||||
| /// Represents public flags for an application. | |||||
| /// </summary> | |||||
| public enum ApplicationFlags | |||||
| { | |||||
| GatewayPresence = 1 << 12, | |||||
| GatewayPresenceLimited = 1 << 13, | |||||
| GatewayGuildMembers = 1 << 14, | |||||
| GatewayGuildMembersLimited = 1 << 15, | |||||
| VerificationPendingGuildLimit = 1 << 16, | |||||
| Embedded = 1 << 17, | |||||
| GatewayMessageContent = 1 << 18, | |||||
| GatewayMessageContentLimited = 1 << 19 | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,31 @@ | |||||
| using System; | |||||
| using System.Collections.Generic; | |||||
| using System.Collections.Immutable; | |||||
| using System.Linq; | |||||
| using System.Text; | |||||
| using System.Threading.Tasks; | |||||
| namespace Discord | |||||
| { | |||||
| /// <summary> | |||||
| /// Represents install parameters for an application. | |||||
| /// </summary> | |||||
| public class ApplicationInstallParams | |||||
| { | |||||
| /// <summary> | |||||
| /// Gets the scopes to install this application. | |||||
| /// </summary> | |||||
| public IReadOnlyCollection<string> Scopes { get; } | |||||
| /// <summary> | |||||
| /// Gets the default permissions to install this application | |||||
| /// </summary> | |||||
| public GuildPermission? Permission { get; } | |||||
| internal ApplicationInstallParams(string[] scopes, GuildPermission? permission) | |||||
| { | |||||
| Scopes = scopes.ToImmutableArray(); | |||||
| Permission = permission; | |||||
| } | |||||
| } | |||||
| } | |||||
| @@ -1,3 +1,5 @@ | |||||
| using System.Collections.Generic; | |||||
| namespace Discord | namespace Discord | ||||
| { | { | ||||
| /// <summary> | /// <summary> | ||||
| @@ -16,8 +18,16 @@ namespace Discord | |||||
| /// <summary> | /// <summary> | ||||
| /// Gets the RPC origins of the application. | /// Gets the RPC origins of the application. | ||||
| /// </summary> | /// </summary> | ||||
| string[] RPCOrigins { get; } | |||||
| ulong Flags { get; } | |||||
| IReadOnlyCollection<string> RPCOrigins { get; } | |||||
| ApplicationFlags Flags { get; } | |||||
| /// <summary> | |||||
| /// Gets a collection of install parameters for this application. | |||||
| /// </summary> | |||||
| ApplicationInstallParams InstallParams { get; } | |||||
| /// <summary> | |||||
| /// Gets a collection of tags related to the application. | |||||
| /// </summary> | |||||
| IReadOnlyCollection<string> Tags { get; } | |||||
| /// <summary> | /// <summary> | ||||
| /// Gets the icon URL of the application. | /// Gets the icon URL of the application. | ||||
| /// </summary> | /// </summary> | ||||
| @@ -7,7 +7,7 @@ namespace Discord.API | |||||
| [JsonProperty("description")] | [JsonProperty("description")] | ||||
| public string Description { get; set; } | public string Description { get; set; } | ||||
| [JsonProperty("rpc_origins")] | [JsonProperty("rpc_origins")] | ||||
| public string[] RPCOrigins { get; set; } | |||||
| public Optional<string[]> RPCOrigins { get; set; } | |||||
| [JsonProperty("name")] | [JsonProperty("name")] | ||||
| public string Name { get; set; } | public string Name { get; set; } | ||||
| [JsonProperty("id")] | [JsonProperty("id")] | ||||
| @@ -18,12 +18,16 @@ namespace Discord.API | |||||
| public bool IsBotPublic { get; set; } | public bool IsBotPublic { get; set; } | ||||
| [JsonProperty("bot_require_code_grant")] | [JsonProperty("bot_require_code_grant")] | ||||
| public bool BotRequiresCodeGrant { get; set; } | public bool BotRequiresCodeGrant { get; set; } | ||||
| [JsonProperty("install_params")] | |||||
| public Optional<InstallParams> InstallParams { get; set; } | |||||
| [JsonProperty("team")] | [JsonProperty("team")] | ||||
| public Team Team { get; set; } | public Team Team { get; set; } | ||||
| [JsonProperty("flags"), Int53] | [JsonProperty("flags"), Int53] | ||||
| public Optional<ulong> Flags { get; set; } | |||||
| public Optional<ApplicationFlags> Flags { get; set; } | |||||
| [JsonProperty("owner")] | [JsonProperty("owner")] | ||||
| public Optional<User> Owner { get; set; } | public Optional<User> Owner { get; set; } | ||||
| public Optional<string[]> Tags { get; set; } | |||||
| } | } | ||||
| } | } | ||||
| @@ -0,0 +1,17 @@ | |||||
| using Newtonsoft.Json; | |||||
| using System; | |||||
| using System.Collections.Generic; | |||||
| using System.Linq; | |||||
| using System.Text; | |||||
| using System.Threading.Tasks; | |||||
| namespace Discord.API | |||||
| { | |||||
| internal class InstallParams | |||||
| { | |||||
| [JsonProperty("scopes")] | |||||
| public string[] Scopes { get; set; } | |||||
| [JsonProperty("permissions")] | |||||
| public ulong Permission { get; set; } | |||||
| } | |||||
| } | |||||
| @@ -1,4 +1,6 @@ | |||||
| using System; | using System; | ||||
| using System.Collections.Generic; | |||||
| using System.Collections.Immutable; | |||||
| using System.Diagnostics; | using System.Diagnostics; | ||||
| using System.Threading.Tasks; | using System.Threading.Tasks; | ||||
| using Model = Discord.API.Application; | using Model = Discord.API.Application; | ||||
| @@ -18,9 +20,9 @@ namespace Discord.Rest | |||||
| /// <inheritdoc /> | /// <inheritdoc /> | ||||
| public string Description { get; private set; } | public string Description { get; private set; } | ||||
| /// <inheritdoc /> | /// <inheritdoc /> | ||||
| public string[] RPCOrigins { get; private set; } | |||||
| public IReadOnlyCollection<string> RPCOrigins { get; private set; } | |||||
| /// <inheritdoc /> | /// <inheritdoc /> | ||||
| public ulong Flags { get; private set; } | |||||
| public ApplicationFlags Flags { get; private set; } | |||||
| /// <inheritdoc /> | /// <inheritdoc /> | ||||
| public bool IsBotPublic { get; private set; } | public bool IsBotPublic { get; private set; } | ||||
| /// <inheritdoc /> | /// <inheritdoc /> | ||||
| @@ -36,6 +38,10 @@ namespace Discord.Rest | |||||
| /// <inheritdoc /> | /// <inheritdoc /> | ||||
| public string IconUrl => CDN.GetApplicationIconUrl(Id, _iconId); | public string IconUrl => CDN.GetApplicationIconUrl(Id, _iconId); | ||||
| public ApplicationInstallParams InstallParams { get; private set; } | |||||
| public IReadOnlyCollection<string> Tags { get; private set; } | |||||
| internal RestApplication(BaseDiscordClient discord, ulong id) | internal RestApplication(BaseDiscordClient discord, ulong id) | ||||
| : base(discord, id) | : base(discord, id) | ||||
| { | { | ||||
| @@ -49,14 +55,17 @@ namespace Discord.Rest | |||||
| internal void Update(Model model) | internal void Update(Model model) | ||||
| { | { | ||||
| Description = model.Description; | Description = model.Description; | ||||
| RPCOrigins = model.RPCOrigins; | |||||
| RPCOrigins = model.RPCOrigins.IsSpecified ? model.RPCOrigins.Value.ToImmutableArray() : ImmutableArray<string>.Empty; | |||||
| Name = model.Name; | Name = model.Name; | ||||
| _iconId = model.Icon; | _iconId = model.Icon; | ||||
| IsBotPublic = model.IsBotPublic; | IsBotPublic = model.IsBotPublic; | ||||
| BotRequiresCodeGrant = model.BotRequiresCodeGrant; | BotRequiresCodeGrant = model.BotRequiresCodeGrant; | ||||
| Tags = model.Tags.GetValueOrDefault(null)?.ToImmutableArray() ?? ImmutableArray<string>.Empty; | |||||
| var installParams = model.InstallParams.GetValueOrDefault(null); | |||||
| InstallParams = new ApplicationInstallParams(installParams?.Scopes ?? new string[0], (GuildPermission?)installParams?.Permission ?? null); | |||||
| if (model.Flags.IsSpecified) | if (model.Flags.IsSpecified) | ||||
| Flags = model.Flags.Value; //TODO: Do we still need this? | |||||
| Flags = model.Flags.Value; | |||||
| if (model.Owner.IsSpecified) | if (model.Owner.IsSpecified) | ||||
| Owner = RestUser.Create(Discord, model.Owner.Value); | Owner = RestUser.Create(Discord, model.Owner.Value); | ||||
| if (model.Team != null) | if (model.Team != null) | ||||