[Feature] Initial user apps support (#2883)
* omg it kinda works somehow * more things added * a bit of xmldocs * added interaction framework support * working? IF * more builder stuff * space * rename attribute to prevent conflict with `ContextType` enum * context type * moar features * remove integration types * trigger workflow * modelzzzz * `InteractionContextType` * allow setting custom status with `SetGameAsync` * bugzzz * app permissions * message interaction context * hm * push for cd * structs lets goooo * whoops forgot to change types * whoops x2 * tweak some things * xmldocs + missing prop + fix enabled in dm * moar validations * deprecate a bunch of stuffz * disable moar obsolete warnings * add IF sample * Apply suggestions from code review Co-authored-by: Quin Lynch <49576606+quinchs@users.noreply.github.com> * Update src/Discord.Net.Rest/Entities/RestApplication.cs Co-authored-by: Quin Lynch <49576606+quinchs@users.noreply.github.com> --------- Co-authored-by: Quin Lynch <49576606+quinchs@users.noreply.github.com>
This commit is contained in:
@@ -37,6 +37,7 @@ namespace Discord.WebSocket
|
||||
public bool IsDefaultPermission { get; private set; }
|
||||
|
||||
/// <inheritdoc/>
|
||||
[Obsolete("This property will be deprecated soon. Use ContextTypes instead.")]
|
||||
public bool IsEnabledInDm { get; private set; }
|
||||
|
||||
/// <inheritdoc/>
|
||||
@@ -79,6 +80,12 @@ namespace Discord.WebSocket
|
||||
/// </remarks>
|
||||
public string DescriptionLocalized { get; private set; }
|
||||
|
||||
/// <inheritdoc />
|
||||
public IReadOnlyCollection<ApplicationIntegrationType> IntegrationTypes { get; private set; }
|
||||
|
||||
/// <inheritdoc />
|
||||
public IReadOnlyCollection<InteractionContextType> ContextTypes { get; private set; }
|
||||
|
||||
/// <inheritdoc/>
|
||||
public DateTimeOffset CreatedAt
|
||||
=> SnowflakeUtils.FromSnowflake(Id);
|
||||
@@ -131,9 +138,14 @@ namespace Discord.WebSocket
|
||||
NameLocalized = model.NameLocalized.GetValueOrDefault();
|
||||
DescriptionLocalized = model.DescriptionLocalized.GetValueOrDefault();
|
||||
|
||||
#pragma warning disable CS0618 // Type or member is obsolete
|
||||
IsEnabledInDm = model.DmPermission.GetValueOrDefault(true).GetValueOrDefault(true);
|
||||
#pragma warning restore CS0618 // Type or member is obsolete
|
||||
DefaultMemberPermissions = new GuildPermissions((ulong)model.DefaultMemberPermission.GetValueOrDefault(0).GetValueOrDefault(0));
|
||||
IsNsfw = model.Nsfw.GetValueOrDefault(false).GetValueOrDefault(false);
|
||||
|
||||
IntegrationTypes = model.IntegrationTypes.GetValueOrDefault(null)?.ToImmutableArray();
|
||||
ContextTypes = model.ContextTypes.GetValueOrDefault(null)?.ToImmutableArray();
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
|
||||
@@ -73,9 +73,18 @@ namespace Discord.WebSocket
|
||||
/// <inheritdoc/>
|
||||
public ulong ApplicationId { get; private set; }
|
||||
|
||||
/// <inheritdoc/>
|
||||
public InteractionContextType? ContextType { get; private set; }
|
||||
|
||||
/// <inheritdoc/>
|
||||
public GuildPermissions Permissions { get; private set; }
|
||||
|
||||
/// <inheritdoc cref="IDiscordInteraction.Entitlements" />
|
||||
public IReadOnlyCollection<RestEntitlement> Entitlements { get; private set; }
|
||||
|
||||
/// <inheritdoc/>
|
||||
public IReadOnlyDictionary<ApplicationIntegrationType, ulong> IntegrationOwners { get; private set; }
|
||||
|
||||
internal SocketInteraction(DiscordSocketClient client, ulong id, ISocketMessageChannel channel, SocketUser user)
|
||||
: base(client, id)
|
||||
{
|
||||
@@ -149,6 +158,13 @@ namespace Discord.WebSocket
|
||||
: null;
|
||||
|
||||
Entitlements = model.Entitlements.Select(x => RestEntitlement.Create(Discord, x)).ToImmutableArray();
|
||||
|
||||
IntegrationOwners = model.IntegrationOwners;
|
||||
ContextType = model.ContextType.IsSpecified
|
||||
? model.ContextType.Value
|
||||
: null;
|
||||
|
||||
Permissions = new GuildPermissions((ulong)model.ApplicationPermissions);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -334,6 +334,7 @@ namespace Discord.WebSocket
|
||||
IReadOnlyCollection<IMessageComponent> IMessage.Components => Components;
|
||||
|
||||
/// <inheritdoc/>
|
||||
[Obsolete("This property will be deprecated soon. Use IUserMessage.InteractionMetadata instead.")]
|
||||
IMessageInteraction IMessage.Interaction => Interaction;
|
||||
|
||||
/// <inheritdoc />
|
||||
|
||||
@@ -49,6 +49,9 @@ namespace Discord.WebSocket
|
||||
/// <inheritdoc />
|
||||
public IUserMessage ReferencedMessage => _referencedMessage;
|
||||
|
||||
/// <inheritdoc />
|
||||
public IMessageInteractionMetadata InteractionMetadata { get; internal set; }
|
||||
|
||||
/// <inheritdoc />
|
||||
public MessageResolvedData ResolvedData { get; internal set; }
|
||||
|
||||
@@ -203,6 +206,9 @@ namespace Discord.WebSocket
|
||||
|
||||
ResolvedData = new MessageResolvedData(users, members, roles, channels);
|
||||
}
|
||||
|
||||
if (model.InteractionMetadata.IsSpecified)
|
||||
InteractionMetadata = model.InteractionMetadata.Value.ToInteractionMetadata();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
|
||||
Reference in New Issue
Block a user