From 3fa2034c25cb45b9f1d302ab71d739cae3daa1aa Mon Sep 17 00:00:00 2001 From: David Schultz Date: Fri, 5 Feb 2021 18:32:00 -0600 Subject: [PATCH] add 'delserver' command (#297) --- src/core_modules/admin.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/core_modules/admin.py b/src/core_modules/admin.py index 5008952d..dca8938c 100644 --- a/src/core_modules/admin.py +++ b/src/core_modules/admin.py @@ -151,6 +151,27 @@ class Module(ModuleManager.BaseModule): return event["stdout"].write("Added server '%s'" % alias) + @utils.hook("received.command.delserver") + @utils.kwarg("help", "Delete a server") + @utils.kwarg("pemission", "delserver") + @utils.spec("!word") + def del_server(self, event): + alias = event["spec"][0] + sid = self.bot.database.servers.by_alias(alias) + if sid == None: + event["stderr"].write("Server '%s' does not exist" % alias) + return + if self._server_from_alias(alias): + event["stderr"].write("You must disconnect from %s before deleting it" % alias) + return + try: + self.bot.database.servers.delete(sid) + except Exception as e: + event["stderr"].write("Failed to delete server") + self.log.error("failed to add server \"%s\"", [alias], exc_info=True) + return + event["stderr"].write("Server '%s' has been deleted" % alias) + @utils.hook("received.command.editserver") @utils.kwarg("help", "Edit server details") @utils.kwarg("permission", "editserver")