Compare commits
	
		
			3 Commits
		
	
	
		
			9ed66c2560
			...
			c7a925b997
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| c7a925b997 | |||
| 7fb6d22c3f | |||
| c5b5297058 | 
 Submodule kdb-bot/src/bot/config updated: 43ae9106e2...52d19fab6d
									
								
							| @@ -151,6 +151,11 @@ | |||||||
|         }, |         }, | ||||||
|         "footer": "" |         "footer": "" | ||||||
|       }, |       }, | ||||||
|  |       "presence": { | ||||||
|  |         "changed": "Presence wurde geändert.", | ||||||
|  |         "removed": "Presence wurde entfernt.", | ||||||
|  |         "max_char_count_exceeded": "Der Text darf nicht mehr als 128 Zeichen lang sein!" | ||||||
|  |       }, | ||||||
|       "user_info": { |       "user_info": { | ||||||
|         "fields": { |         "fields": { | ||||||
|           "id": "Id", |           "id": "Id", | ||||||
|   | |||||||
| @@ -11,6 +11,7 @@ from modules.base.command.afk_command import AFKCommand | |||||||
| from modules.base.command.help_command import HelpCommand | from modules.base.command.help_command import HelpCommand | ||||||
| from modules.base.command.info_command import InfoCommand | from modules.base.command.info_command import InfoCommand | ||||||
| from modules.base.command.ping_command import PingCommand | from modules.base.command.ping_command import PingCommand | ||||||
|  | from modules.base.command.presence_command import PresenceCommand | ||||||
| from modules.base.command.purge_command import PurgeCommand | from modules.base.command.purge_command import PurgeCommand | ||||||
| from modules.base.command.user_group import UserGroup | from modules.base.command.user_group import UserGroup | ||||||
| from modules.base.events.base_on_command_error_event import BaseOnCommandErrorEvent | from modules.base.events.base_on_command_error_event import BaseOnCommandErrorEvent | ||||||
| @@ -42,6 +43,7 @@ class BaseModule(ModuleABC): | |||||||
|         self._dc.add_command(HelpCommand) |         self._dc.add_command(HelpCommand) | ||||||
|         self._dc.add_command(InfoCommand) |         self._dc.add_command(InfoCommand) | ||||||
|         self._dc.add_command(PingCommand) |         self._dc.add_command(PingCommand) | ||||||
|  |         self._dc.add_command(PresenceCommand) | ||||||
|  |  | ||||||
|         self._dc.add_command(PurgeCommand) |         self._dc.add_command(PurgeCommand) | ||||||
|         self._dc.add_command(UserGroup) |         self._dc.add_command(UserGroup) | ||||||
|   | |||||||
							
								
								
									
										48
									
								
								kdb-bot/src/modules/base/command/presence_command.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										48
									
								
								kdb-bot/src/modules/base/command/presence_command.py
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,48 @@ | |||||||
|  | import discord | ||||||
|  | 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.message_service_abc import MessageServiceABC | ||||||
|  | from bot_core.helper.command_checks import CommandChecks | ||||||
|  | from bot_core.logging.command_logger import CommandLogger | ||||||
|  |  | ||||||
|  |  | ||||||
|  | class PresenceCommand(DiscordCommandABC): | ||||||
|  |  | ||||||
|  |     def __init__( | ||||||
|  |             self, | ||||||
|  |             logger: CommandLogger, | ||||||
|  |             message_service: MessageServiceABC, | ||||||
|  |             bot: DiscordBotServiceABC, | ||||||
|  |             translate: TranslatePipe, | ||||||
|  |     ): | ||||||
|  |         DiscordCommandABC.__init__(self) | ||||||
|  |  | ||||||
|  |         self._logger = logger | ||||||
|  |         self._message_service = message_service | ||||||
|  |         self._bot = bot | ||||||
|  |         self._t = translate | ||||||
|  |  | ||||||
|  |     @commands.hybrid_command() | ||||||
|  |     @commands.guild_only() | ||||||
|  |     @CommandChecks.check_is_ready() | ||||||
|  |     @CommandChecks.check_is_member_moderator() | ||||||
|  |     async def presence(self, ctx: Context, text: str = ''): | ||||||
|  |         self._logger.debug(__name__, f'Received command presence {ctx}') | ||||||
|  |  | ||||||
|  |         if text == '': | ||||||
|  |             await self._bot.change_presence(activity=None) | ||||||
|  |             await self._message_service.send_ctx_msg(ctx, self._t.transform('modules.base.presence.removed')) | ||||||
|  |             return | ||||||
|  |  | ||||||
|  |         if len(text) > 128: | ||||||
|  |             await self._message_service.send_ctx_msg(ctx, self._t.transform('modules.base.presence.max_char_count_exceeded')) | ||||||
|  |             return | ||||||
|  |  | ||||||
|  |         await self._bot.change_presence(activity=discord.Game(name=text)) | ||||||
|  |         await self._message_service.send_ctx_msg(ctx, self._t.transform('modules.base.presence.changed')) | ||||||
|  |  | ||||||
|  |         self._logger.trace(__name__, f'Finished presence command') | ||||||
		Reference in New Issue
	
	Block a user