Added shutdown command
This commit is contained in:
		| @@ -47,6 +47,6 @@ class RestartCommand(DiscordCommandABC): | ||||
|  | ||||
|         self._config.add_configuration('IS_RESTART', 'true') | ||||
|         await self._message_service.send_ctx_msg(ctx, self._t.transform('modules.admin.restart_message')) | ||||
|         await self._bot.logout() | ||||
|         await self._bot.stop_async() | ||||
|  | ||||
|         self._logger.trace(__name__, f'Finished restart command') | ||||
|   | ||||
							
								
								
									
										51
									
								
								src/modules/admin/command/shutdown_command.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										51
									
								
								src/modules/admin/command/shutdown_command.py
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,51 @@ | ||||
| from cpl_core.configuration import ConfigurationABC | ||||
| from cpl_core.logging import LoggerABC | ||||
| from cpl_discord.command import DiscordCommandABC | ||||
| from cpl_discord.service import DiscordBotServiceABC | ||||
| from cpl_translation import TranslatePipe | ||||
| from discord.ext import commands | ||||
| from discord.ext.commands import Context | ||||
|  | ||||
| from bot_core.abc.client_utils_service_abc import ClientUtilsServiceABC | ||||
| from bot_core.abc.message_service_abc import MessageServiceABC | ||||
| from modules.permission.abc.permission_service_abc import PermissionServiceABC | ||||
|  | ||||
|  | ||||
| class ShutdownCommand(DiscordCommandABC): | ||||
|  | ||||
|     def __init__( | ||||
|             self, | ||||
|             logger: LoggerABC, | ||||
|             config: ConfigurationABC, | ||||
|             message_service: MessageServiceABC, | ||||
|             bot: DiscordBotServiceABC, | ||||
|             client_utils: ClientUtilsServiceABC, | ||||
|             translate: TranslatePipe, | ||||
|             permissions: PermissionServiceABC, | ||||
|     ): | ||||
|         DiscordCommandABC.__init__(self) | ||||
|  | ||||
|         self._logger = logger | ||||
|         self._config = config | ||||
|         self._message_service = message_service | ||||
|         self._bot = bot | ||||
|         self._client_utils = client_utils | ||||
|         self._t = translate | ||||
|         self._permissions = permissions | ||||
|  | ||||
|         self._logger.trace(__name__, f'Loaded command service: {type(self).__name__}') | ||||
|  | ||||
|     @commands.command() | ||||
|     async def shutdown(self, ctx: Context): | ||||
|         self._logger.debug(__name__, f'Received command shutdown {ctx}') | ||||
|         self._client_utils.received_command(ctx.guild.id) | ||||
|  | ||||
|         if not self._permissions.is_member_moderator(ctx.author): | ||||
|             await self._message_service.send_ctx_msg(ctx, self._t.transform('common.no_permission_message')) | ||||
|             self._logger.trace(__name__, f'Finished shutdown command') | ||||
|             return | ||||
|  | ||||
|         await self._message_service.send_ctx_msg(ctx, self._t.transform('modules.admin.shutdown_message')) | ||||
|         await self._bot.stop_async() | ||||
|  | ||||
|         self._logger.trace(__name__, f'Finished shutdown command') | ||||
		Reference in New Issue
	
	Block a user