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:
@@ -40,7 +40,8 @@ namespace Discord.Interactions
|
||||
{
|
||||
Name = commandInfo.Name,
|
||||
Description = commandInfo.Description,
|
||||
IsDefaultPermission = commandInfo.DefaultPermission,
|
||||
IsDMEnabled = commandInfo.IsEnabledInDm,
|
||||
DefaultMemberPermissions = (commandInfo.DefaultMemberPermissions ?? 0) | (commandInfo.Module.DefaultMemberPermissions ?? 0)
|
||||
}.Build();
|
||||
|
||||
if (commandInfo.Parameters.Count > SlashCommandBuilder.MaxOptionsCount)
|
||||
@@ -64,8 +65,20 @@ namespace Discord.Interactions
|
||||
public static ApplicationCommandProperties ToApplicationCommandProps(this ContextCommandInfo commandInfo)
|
||||
=> commandInfo.CommandType switch
|
||||
{
|
||||
ApplicationCommandType.Message => new MessageCommandBuilder { Name = commandInfo.Name, IsDefaultPermission = commandInfo.DefaultPermission}.Build(),
|
||||
ApplicationCommandType.User => new UserCommandBuilder { Name = commandInfo.Name, IsDefaultPermission=commandInfo.DefaultPermission}.Build(),
|
||||
ApplicationCommandType.Message => new MessageCommandBuilder
|
||||
{
|
||||
Name = commandInfo.Name,
|
||||
IsDefaultPermission = commandInfo.DefaultPermission,
|
||||
DefaultMemberPermissions = (commandInfo.DefaultMemberPermissions ?? 0) | (commandInfo.Module.DefaultMemberPermissions ?? 0),
|
||||
IsDMEnabled = commandInfo.IsEnabledInDm
|
||||
}.Build(),
|
||||
ApplicationCommandType.User => new UserCommandBuilder
|
||||
{
|
||||
Name = commandInfo.Name,
|
||||
IsDefaultPermission = commandInfo.DefaultPermission,
|
||||
DefaultMemberPermissions = (commandInfo.DefaultMemberPermissions ?? 0) | (commandInfo.Module.DefaultMemberPermissions ?? 0),
|
||||
IsDMEnabled = commandInfo.IsEnabledInDm
|
||||
}.Build(),
|
||||
_ => throw new InvalidOperationException($"{commandInfo.CommandType} isn't a supported command type.")
|
||||
};
|
||||
#endregion
|
||||
@@ -113,6 +126,8 @@ namespace Discord.Interactions
|
||||
Name = moduleInfo.SlashGroupName,
|
||||
Description = moduleInfo.Description,
|
||||
IsDefaultPermission = moduleInfo.DefaultPermission,
|
||||
IsDMEnabled = moduleInfo.IsEnabledInDm,
|
||||
DefaultMemberPermissions = moduleInfo.DefaultMemberPermissions
|
||||
}.Build();
|
||||
|
||||
if (options.Count > SlashCommandBuilder.MaxOptionsCount)
|
||||
|
||||
Reference in New Issue
Block a user