diff --git a/Bot/Config/CrossBotConfig.cs b/Bot/Config/CrossBotConfig.cs index f878628..934c591 100644 --- a/Bot/Config/CrossBotConfig.cs +++ b/Bot/Config/CrossBotConfig.cs @@ -32,6 +32,9 @@ public sealed record CrossBotConfig : SwitchConnectionConfig public List LoggingChannels { get; set; } = new(); + // Should we ignore all permissions for commands and allow inter-bot talk? This should only be used for debug/apps that layer on top of the acnh bot through discord. + public bool IgnoreAllPermissions { get; set; } = false; + #endregion #region Features diff --git a/Discord/Globals.cs b/Discord/Globals.cs index 058c918..a7c3147 100644 --- a/Discord/Globals.cs +++ b/Discord/Globals.cs @@ -24,7 +24,7 @@ public sealed class RequireQueueRoleAttribute : PreconditionAttribute public override Task CheckPermissionsAsync(ICommandContext context, CommandInfo command, IServiceProvider services) { var mgr = Globals.Bot.Config; - if (mgr.CanUseSudo(context.User.Id) || Globals.Self.Owner == context.User.Id) + if (mgr.CanUseSudo(context.User.Id) || Globals.Self.Owner == context.User.Id || mgr.IgnoreAllPermissions) return Task.FromResult(PreconditionResult.FromSuccess()); // Check if this user is a Guild User, which is the only context where roles exist diff --git a/Discord/RequireSudoAttribute.cs b/Discord/RequireSudoAttribute.cs index 4f6fcd7..fa5e35f 100644 --- a/Discord/RequireSudoAttribute.cs +++ b/Discord/RequireSudoAttribute.cs @@ -11,7 +11,7 @@ public sealed class RequireSudoAttribute : PreconditionAttribute public override Task CheckPermissionsAsync(ICommandContext context, CommandInfo command, IServiceProvider services) { var mgr = Globals.Bot.Config; - if (mgr.CanUseSudo(context.User.Id) || context.User.Id == Globals.Self.Owner) + if (mgr.CanUseSudo(context.User.Id) || context.User.Id == Globals.Self.Owner || mgr.IgnoreAllPermissions) return Task.FromResult(PreconditionResult.FromSuccess()); // Check if this user is a Guild User, which is the only context where roles exist diff --git a/Discord/SysCord.cs b/Discord/SysCord.cs index 8914848..f5c602a 100644 --- a/Discord/SysCord.cs +++ b/Discord/SysCord.cs @@ -173,7 +173,7 @@ private async Task HandleMessageAsync(SocketMessage arg) return; // We don't want the bot to respond to itself or other bots. - if (msg.Author.Id == _client.CurrentUser.Id || msg.Author.IsBot) + if (msg.Author.Id == _client.CurrentUser.Id || (!Bot.Config.IgnoreAllPermissions && msg.Author.IsBot)) return; // Create a number to track where the prefix ends and the command begins @@ -233,15 +233,18 @@ private async Task TryHandleCommandAsync(SocketUserMessage msg, int pos) // Check Permission var mgr = Bot.Config; - if (!mgr.CanUseCommandUser(msg.Author.Id)) + if (!Bot.Config.IgnoreAllPermissions) { - await msg.Channel.SendMessageAsync("You are not permitted to use this command.").ConfigureAwait(false); - return true; - } - if (!mgr.CanUseCommandChannel(msg.Channel.Id) && msg.Author.Id != Owner) - { - await msg.Channel.SendMessageAsync("You can't use that command here.").ConfigureAwait(false); - return true; + if (!mgr.CanUseCommandUser(msg.Author.Id)) + { + await msg.Channel.SendMessageAsync("You are not permitted to use this command.").ConfigureAwait(false); + return true; + } + if (!mgr.CanUseCommandChannel(msg.Channel.Id) && msg.Author.Id != Owner) + { + await msg.Channel.SendMessageAsync("You can't use that command here.").ConfigureAwait(false); + return true; + } } // Execute the command. (result does not indicate a return value,