diff --git a/src/EllieBot/Modules/Permissions/GlobalPermissions/GlobalPermissionCommands.cs b/src/EllieBot/Modules/Permissions/GlobalPermissions/GlobalPermissionCommands.cs
index 2647cd8..1e919e0 100644
--- a/src/EllieBot/Modules/Permissions/GlobalPermissions/GlobalPermissionCommands.cs
+++ b/src/EllieBot/Modules/Permissions/GlobalPermissions/GlobalPermissionCommands.cs
@@ -73,5 +73,38 @@ public partial class Permissions
await Response().Confirm(strs.gcmd_remove(Format.Bold(cmd.Name))).SendAsync();
}
+
+ [Cmd]
+ [OwnerOnly]
+ public async Task DmModule(ModuleOrExpr module)
+ {
+ var moduleName = module.Name.ToLowerInvariant();
+
+ var added = _service.ToggleModule(moduleName, true);
+
+ if (added)
+ {
+ await Response().Confirm(strs.dmmod_add(Format.Bold(module.Name))).SendAsync();
+ return;
+ }
+
+ await Response().Confirm(strs.dmmod_remove(Format.Bold(module.Name))).SendAsync();
+ }
+
+ [Cmd]
+ [OwnerOnly]
+ public async Task DmCommand(CommandOrExprInfo cmd)
+ {
+ var commandName = cmd.Name.ToLowerInvariant();
+ var added = _service.ToggleCommand(commandName, true);
+
+ if (added)
+ {
+ await Response().Confirm(strs.dmcmd_add(Format.Bold(cmd.Name))).SendAsync();
+ return;
+ }
+
+ await Response().Confirm(strs.dmcmd_remove(Format.Bold(cmd.Name))).SendAsync();
+ }
}
}
\ No newline at end of file
diff --git a/src/EllieBot/Modules/Permissions/GlobalPermissions/GlobalPermissionService.cs b/src/EllieBot/Modules/Permissions/GlobalPermissions/GlobalPermissionService.cs
index 42ad5d7..1047eaf 100644
--- a/src/EllieBot/Modules/Permissions/GlobalPermissions/GlobalPermissionService.cs
+++ b/src/EllieBot/Modules/Permissions/GlobalPermissions/GlobalPermissionService.cs
@@ -24,10 +24,19 @@ public class GlobalPermissionService : IExecPreCommand, IEService
var settings = _bss.Data;
var commandName = command.Name.ToLowerInvariant();
- if (commandName != "resetglobalperms"
- && (settings.Blocked.Commands.Contains(commandName)
- || settings.Blocked.Modules.Contains(moduleName.ToLowerInvariant())))
- return Task.FromResult(true);
+ if (commandName != "resetglobalperms")
+ {
+ if (settings.Blocked.Commands.Contains(commandName)
+ || settings.Blocked.Modules.Contains(moduleName.ToLowerInvariant()))
+ return Task.FromResult(true);
+
+ if (ctx.Guild is null)
+ {
+ if (settings.DmBlocked.Commands.Contains(commandName)
+ || settings.DmBlocked.Modules.Contains(moduleName.ToLowerInvariant()))
+ return Task.FromResult(true);
+ }
+ }
return Task.FromResult(false);
}
@@ -37,13 +46,30 @@ public class GlobalPermissionService : IExecPreCommand, IEService
///
/// Lowercase module name
/// Whether the module is added
- public bool ToggleModule(string moduleName)
+ public bool ToggleModule(string moduleName, bool priv = false)
{
var added = false;
_bss.ModifyConfig(bs =>
{
+ if (priv)
+ {
+ if (bs.DmBlocked.Modules.Add(moduleName))
+ {
+ added = true;
+ }
+ else
+ {
+ bs.DmBlocked.Modules.Remove(moduleName);
+ added = false;
+ }
+
+ return;
+ }
+
if (bs.Blocked.Modules.Add(moduleName))
+ {
added = true;
+ }
else
{
bs.Blocked.Modules.Remove(moduleName);
@@ -59,13 +85,30 @@ public class GlobalPermissionService : IExecPreCommand, IEService
///
/// Lowercase command name
/// Whether the command is added
- public bool ToggleCommand(string commandName)
+ public bool ToggleCommand(string commandName, bool priv = false)
{
var added = false;
_bss.ModifyConfig(bs =>
{
+ if (priv)
+ {
+ if (bs.Blocked.Commands.Add(commandName))
+ {
+ added = true;
+ }
+ else
+ {
+ bs.Blocked.Commands.Remove(commandName);
+ added = false;
+ }
+
+ return;
+ }
+
if (bs.Blocked.Commands.Add(commandName))
+ {
added = true;
+ }
else
{
bs.Blocked.Commands.Remove(commandName);
diff --git a/src/EllieBot/_common/Configs/BotConfig.cs b/src/EllieBot/_common/Configs/BotConfig.cs
index 1f691ed..e5ebc80 100644
--- a/src/EllieBot/_common/Configs/BotConfig.cs
+++ b/src/EllieBot/_common/Configs/BotConfig.cs
@@ -12,7 +12,7 @@ namespace EllieBot.Common.Configs;
public sealed partial class BotConfig : ICloneable
{
[Comment("""DO NOT CHANGE""")]
- public int Version { get; set; } = 8;
+ public int Version { get; set; } = 9;
[Comment("""
Most commands, when executed, have a small colored line
@@ -81,6 +81,9 @@ public sealed partial class BotConfig : ICloneable
[Comment("""List of modules and commands completely blocked on the bot""")]
public BlockedConfig Blocked { get; set; }
+ [Comment("""List of modules and commands blocked from usage in DMs on the bot""")]
+ public BlockedConfig DmBlocked { get; set; } = new();
+
[Comment("""Which string will be used to recognize the commands""")]
public string Prefix { get; set; }
diff --git a/src/EllieBot/_common/Settings/BotConfigService.cs b/src/EllieBot/_common/Settings/BotConfigService.cs
index 5e98049..5dae2e9 100644
--- a/src/EllieBot/_common/Settings/BotConfigService.cs
+++ b/src/EllieBot/_common/Settings/BotConfigService.cs
@@ -70,10 +70,10 @@ public sealed class BotConfigService : ConfigServiceBase
c.IgnoreOtherBots = true;
});
- if(data.Version < 8)
+ if(data.Version < 9)
ModifyConfig(c =>
{
- c.Version = 8;
+ c.Version = 9;
});
}
}
\ No newline at end of file
diff --git a/src/EllieBot/data/aliases.yml b/src/EllieBot/data/aliases.yml
index a635a75..3581b99 100644
--- a/src/EllieBot/data/aliases.yml
+++ b/src/EllieBot/data/aliases.yml
@@ -1039,6 +1039,12 @@ gamevoicechannel:
- gvc
shoplistadd:
- shoplistadd
+dmcommand:
+ - dmcommand
+ - dmcmd
+dmmodule:
+ - dmmodule
+ - dmmod
globalcommand:
- globalcommand
- gcmd
diff --git a/src/EllieBot/data/bot.yml b/src/EllieBot/data/bot.yml
index e15bbc1..80af2f2 100644
--- a/src/EllieBot/data/bot.yml
+++ b/src/EllieBot/data/bot.yml
@@ -1,5 +1,5 @@
# DO NOT CHANGE
-version: 8
+version: 9
# Most commands, when executed, have a small colored line
# next to the response. The color depends whether the command
# is completed, errored or in progress (pending)
@@ -78,6 +78,10 @@ helpText: |-
blocked:
commands: []
modules: []
+# List of modules and commands blocked from usage in DMs on the bot
+dmBlocked:
+ commands: []
+ modules: []
# Which string will be used to recognize the commands
prefix: .
# Whether the bot will rotate through all specified statuses.
diff --git a/src/EllieBot/data/strings/responses/responses.en-US.json b/src/EllieBot/data/strings/responses/responses.en-US.json
index a15504d..72cc0c5 100644
--- a/src/EllieBot/data/strings/responses/responses.en-US.json
+++ b/src/EllieBot/data/strings/responses/responses.en-US.json
@@ -758,6 +758,10 @@
"gcmd_remove": "Command {0} has been enabled on all servers.",
"gmod_add": "Module {0} has been disabled on all servers.",
"gmod_remove": "Module {0} has been enabled on all servers.",
+ "dmmod_add": "Module {0} has been disabled in bot DMs.",
+ "dmmod_remove": "Module {0} has been enabled in bot DMs.",
+ "dmcmd_add": "Command {0} has been disabled in bot DMs.",
+ "dmcmd_remove": "Command {0} has been enabled in bot DMs.",
"lgp_none": "No blocked commands or modules.",
"cant_read_or_send": "You can't read from or send messages to that channel.",
"quotes_notfound": "No quotes found matching the quote ID specified.",