fix: Application commands are disabled to everyone except admins by default (#2293)
This commit is contained in:
@@ -248,7 +248,7 @@ namespace Discord.Interactions
|
|||||||
|
|
||||||
while (parent != null)
|
while (parent != null)
|
||||||
{
|
{
|
||||||
permissions = (permissions ?? 0) | (parent.DefaultMemberPermissions ?? 0);
|
permissions = (permissions ?? 0) | (parent.DefaultMemberPermissions ?? 0).SanitizeGuildPermissions();
|
||||||
parent = parent.Parent;
|
parent = parent.Parent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ namespace Discord.Interactions
|
|||||||
Name = commandInfo.Name,
|
Name = commandInfo.Name,
|
||||||
Description = commandInfo.Description,
|
Description = commandInfo.Description,
|
||||||
IsDMEnabled = commandInfo.IsEnabledInDm,
|
IsDMEnabled = commandInfo.IsEnabledInDm,
|
||||||
DefaultMemberPermissions = (commandInfo.DefaultMemberPermissions ?? 0) | (commandInfo.Module.DefaultMemberPermissions ?? 0)
|
DefaultMemberPermissions = ((commandInfo.DefaultMemberPermissions ?? 0) | (commandInfo.Module.DefaultMemberPermissions ?? 0)).SanitizeGuildPermissions(),
|
||||||
}.Build();
|
}.Build();
|
||||||
|
|
||||||
if (commandInfo.Parameters.Count > SlashCommandBuilder.MaxOptionsCount)
|
if (commandInfo.Parameters.Count > SlashCommandBuilder.MaxOptionsCount)
|
||||||
@@ -69,14 +69,14 @@ namespace Discord.Interactions
|
|||||||
{
|
{
|
||||||
Name = commandInfo.Name,
|
Name = commandInfo.Name,
|
||||||
IsDefaultPermission = commandInfo.DefaultPermission,
|
IsDefaultPermission = commandInfo.DefaultPermission,
|
||||||
DefaultMemberPermissions = (commandInfo.DefaultMemberPermissions ?? 0) | (commandInfo.Module.DefaultMemberPermissions ?? 0),
|
DefaultMemberPermissions = ((commandInfo.DefaultMemberPermissions ?? 0) | (commandInfo.Module.DefaultMemberPermissions ?? 0)).SanitizeGuildPermissions(),
|
||||||
IsDMEnabled = commandInfo.IsEnabledInDm
|
IsDMEnabled = commandInfo.IsEnabledInDm
|
||||||
}.Build(),
|
}.Build(),
|
||||||
ApplicationCommandType.User => new UserCommandBuilder
|
ApplicationCommandType.User => new UserCommandBuilder
|
||||||
{
|
{
|
||||||
Name = commandInfo.Name,
|
Name = commandInfo.Name,
|
||||||
IsDefaultPermission = commandInfo.DefaultPermission,
|
IsDefaultPermission = commandInfo.DefaultPermission,
|
||||||
DefaultMemberPermissions = (commandInfo.DefaultMemberPermissions ?? 0) | (commandInfo.Module.DefaultMemberPermissions ?? 0),
|
DefaultMemberPermissions = ((commandInfo.DefaultMemberPermissions ?? 0) | (commandInfo.Module.DefaultMemberPermissions ?? 0)).SanitizeGuildPermissions(),
|
||||||
IsDMEnabled = commandInfo.IsEnabledInDm
|
IsDMEnabled = commandInfo.IsEnabledInDm
|
||||||
}.Build(),
|
}.Build(),
|
||||||
_ => throw new InvalidOperationException($"{commandInfo.CommandType} isn't a supported command type.")
|
_ => throw new InvalidOperationException($"{commandInfo.CommandType} isn't a supported command type.")
|
||||||
@@ -232,5 +232,8 @@ namespace Discord.Interactions
|
|||||||
|
|
||||||
return builder.Build();
|
return builder.Build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static GuildPermission? SanitizeGuildPermissions(this GuildPermission permissions) =>
|
||||||
|
permissions == 0 ? null : permissions;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user