diff --git a/src/Discord.Net.Interactions/Info/Commands/ContextCommands/ContextCommandInfo.cs b/src/Discord.Net.Interactions/Info/Commands/ContextCommands/ContextCommandInfo.cs
index 4c2e7af7d..2d6d748d4 100644
--- a/src/Discord.Net.Interactions/Info/Commands/ContextCommands/ContextCommandInfo.cs
+++ b/src/Discord.Net.Interactions/Info/Commands/ContextCommands/ContextCommandInfo.cs
@@ -17,6 +17,12 @@ namespace Discord.Interactions
///
public bool DefaultPermission { get; }
+ ///
+ public bool IsEnabledInDm { get; }
+
+ ///
+ public GuildPermission? DefaultMemberPermissions { get; }
+
///
public override IReadOnlyCollection Parameters { get; }
@@ -31,6 +37,8 @@ namespace Discord.Interactions
{
CommandType = builder.CommandType;
DefaultPermission = builder.DefaultPermission;
+ IsEnabledInDm = builder.IsEnabledInDm;
+ DefaultMemberPermissions = builder.DefaultMemberPermissions;
Parameters = builder.Parameters.Select(x => x.Build(this)).ToImmutableArray();
}
diff --git a/src/Discord.Net.Interactions/Info/Commands/SlashCommandInfo.cs b/src/Discord.Net.Interactions/Info/Commands/SlashCommandInfo.cs
index a123ac183..e428144c7 100644
--- a/src/Discord.Net.Interactions/Info/Commands/SlashCommandInfo.cs
+++ b/src/Discord.Net.Interactions/Info/Commands/SlashCommandInfo.cs
@@ -26,6 +26,12 @@ namespace Discord.Interactions
///
public bool DefaultPermission { get; }
+ ///
+ public bool IsEnabledInDm { get; }
+
+ ///
+ public GuildPermission? DefaultMemberPermissions { get; }
+
///
public override IReadOnlyCollection Parameters { get; }
@@ -41,6 +47,8 @@ namespace Discord.Interactions
{
Description = builder.Description;
DefaultPermission = builder.DefaultPermission;
+ IsEnabledInDm = builder.IsEnabledInDm;
+ DefaultMemberPermissions = builder.DefaultMemberPermissions;
Parameters = builder.Parameters.Select(x => x.Build(this)).ToImmutableArray();
FlattenedParameters = FlattenParameters(Parameters).ToImmutableArray();
diff --git a/src/Discord.Net.Interactions/Info/IApplicationCommandInfo.cs b/src/Discord.Net.Interactions/Info/IApplicationCommandInfo.cs
index 1e0d532b0..dd1b97899 100644
--- a/src/Discord.Net.Interactions/Info/IApplicationCommandInfo.cs
+++ b/src/Discord.Net.Interactions/Info/IApplicationCommandInfo.cs
@@ -1,3 +1,5 @@
+using System;
+
namespace Discord.Interactions
{
///
@@ -18,6 +20,17 @@ namespace Discord.Interactions
///
/// Gets the DefaultPermission of this command.
///
+ [Obsolete($"To be deprecated soon, use {nameof(IsEnabledInDm)} and {nameof(DefaultMemberPermissions)} instead.")]
bool DefaultPermission { get; }
+
+ ///
+ /// Gets whether this command can be used in DMs.
+ ///
+ public bool IsEnabledInDm { get; }
+
+ ///
+ /// Gets the default permissions needed for executing this command.
+ ///
+ public GuildPermission? DefaultMemberPermissions { get; }
}
}
diff --git a/src/Discord.Net.Interactions/Info/ModuleInfo.cs b/src/Discord.Net.Interactions/Info/ModuleInfo.cs
index 321e0bfa9..904d67410 100644
--- a/src/Discord.Net.Interactions/Info/ModuleInfo.cs
+++ b/src/Discord.Net.Interactions/Info/ModuleInfo.cs
@@ -41,8 +41,19 @@ namespace Discord.Interactions
///
/// Gets the default Permission of this module.
///
+ [Obsolete($"To be deprecated soon, use {nameof(IsEnabledInDm)} and {nameof(DefaultMemberPermissions)} instead.")]
public bool DefaultPermission { get; }
+ ///
+ /// Gets whether this command can be used in DMs.
+ ///
+ public bool IsEnabledInDm { get; }
+
+ ///
+ /// Gets the default permissions needed for executing this command.
+ ///
+ public GuildPermission? DefaultMemberPermissions { get; }
+
///
/// Gets the collection of Sub Modules of this module.
///
@@ -110,6 +121,8 @@ namespace Discord.Interactions
Description = builder.Description;
Parent = parent;
DefaultPermission = builder.DefaultPermission;
+ IsEnabledInDm = builder.IsEnabledInDm;
+ DefaultMemberPermissions = BuildDefaultMemberPermissions(builder);
SlashCommands = BuildSlashCommands(builder).ToImmutableArray();
ContextCommands = BuildContextCommands(builder).ToImmutableArray();
ComponentCommands = BuildComponentCommands(builder).ToImmutableArray();
@@ -226,5 +239,20 @@ namespace Discord.Interactions
}
return true;
}
+
+ private static GuildPermission? BuildDefaultMemberPermissions(ModuleBuilder builder)
+ {
+ var permissions = builder.DefaultMemberPermissions;
+
+ var parent = builder.Parent;
+
+ while (parent != null)
+ {
+ permissions = (permissions ?? 0) | (parent.DefaultMemberPermissions ?? 0);
+ parent = parent.Parent;
+ }
+
+ return permissions;
+ }
}
}
diff --git a/src/Discord.Net.Interactions/Utilities/ApplicationCommandRestUtil.cs b/src/Discord.Net.Interactions/Utilities/ApplicationCommandRestUtil.cs
index 46f0f4a4a..60ba57cd5 100644
--- a/src/Discord.Net.Interactions/Utilities/ApplicationCommandRestUtil.cs
+++ b/src/Discord.Net.Interactions/Utilities/ApplicationCommandRestUtil.cs
@@ -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)