feature: V2 Permissions (#2222)

* Initial V2 permissions

* add perms-v2 attributes and properties, add deprecation messages

* add perms-v2 properties to command info classes

* add perms-v2 fields to Rest/SocketApplicationCommand entities and IApplicationCommand

* fix json name of DmPermission field

Co-authored-by: Cenngo <cenk.ergen1@gmail.com>
This commit is contained in:
Quin Lynch
2022-04-28 08:47:52 -03:00
committed by GitHub
parent 4ce1801bdf
commit d98b3cc495
22 changed files with 451 additions and 9 deletions

View File

@@ -36,6 +36,12 @@ namespace Discord.WebSocket
/// <inheritdoc/>
public bool IsDefaultPermission { get; private set; }
/// <inheritdoc/>
public bool IsEnabledInDm { get; private set; }
/// <inheritdoc/>
public GuildPermissions DefaultMemberPermissions { get; private set; }
/// <summary>
/// Gets a collection of <see cref="SocketApplicationCommandOption"/>s for this command.
/// </summary>
@@ -86,6 +92,10 @@ namespace Discord.WebSocket
Options = model.Options.IsSpecified
? model.Options.Value.Select(SocketApplicationCommandOption.Create).ToImmutableArray()
: ImmutableArray.Create<SocketApplicationCommandOption>();
IsEnabledInDm = model.DmPermission.GetValueOrDefault(true).GetValueOrDefault(true);
DefaultMemberPermissions = model.DefaultMemberPermission.IsSpecified
? new GuildPermissions((ulong)model.DefaultMemberPermission.Value) : GuildPermissions.None;
}
/// <inheritdoc/>