Переглянути джерело

Adding some basic usage logging to some commands

tags/2.0.0
Rocketsoup 2 місяці тому
джерело
коміт
41dd7deeda

+ 2
- 0
rocketbot/cogs/gamescog.py Переглянути файл

@@ -56,6 +56,7 @@ class GamesCog(BaseCog, name="Games"):
56 56
 		text += f'\n\n-# Users who rolled {result} also liked {listed_items(list(others))}'
57 57
 
58 58
 		await interaction.response.send_message(text, ephemeral=not share)
59
+		self.log(interaction.guild, f'{interaction.user.name} used /roll {sides} {share}')
59 60
 
60 61
 	@command(
61 62
 		description='Creates a really terrible Minesweeper puzzle.'
@@ -138,6 +139,7 @@ class GamesCog(BaseCog, name="Games"):
138 139
 			view=_MinesweeperLayout(text),
139 140
 			ephemeral=True,
140 141
 		)
142
+		self.log(interaction.guild, f'{interaction.user.name} used /minesweeper')
141 143
 
142 144
 class _MinesweeperLayout(LayoutView):
143 145
 	def __init__(self, text_content: str):

+ 4
- 0
rocketbot/cogs/generalcog.py Переглянути файл

@@ -87,6 +87,7 @@ class GeneralCog(BaseCog, name='General'):
87 87
 				'Warning issued',
88 88
 				ephemeral=True,
89 89
 			)
90
+		self.log(interaction.guild, f'{interaction.user.name} used /test_warn')
90 91
 
91 92
 	@command(
92 93
 		description='Responds to the user with a greeting.',
@@ -100,6 +101,7 @@ class GeneralCog(BaseCog, name='General'):
100 101
 			f'Hey, {interaction.user.name}!',
101 102
 		 	ephemeral=True,
102 103
 		)
104
+		self.log(interaction.guild, f'{interaction.user.name} used /hello')
103 105
 
104 106
 	@command(
105 107
 		description='Shuts down the bot.',
@@ -113,6 +115,7 @@ class GeneralCog(BaseCog, name='General'):
113 115
 	async def shutdown(self, interaction: Interaction):
114 116
 		"""Command handler"""
115 117
 		await interaction.response.send_message('👋', ephemeral=True)
118
+		self.log(interaction.guild, f'{interaction.user.name} used /shutdown')
116 119
 		await self.bot.close()
117 120
 
118 121
 	@command(
@@ -164,3 +167,4 @@ class GeneralCog(BaseCog, name='General'):
164 167
 				content=f'{CONFIG["success_emoji"]} No messages found for {author.mention} '
165 168
 						'from the past {describe_timedelta(age)}.',
166 169
 			)
170
+		self.log(interaction.guild, f'{interaction.user.name} used /delete_messages {author.id} {age}')

+ 1
- 0
rocketbot/cogs/helpcog.py Переглянути файл

@@ -224,6 +224,7 @@ class HelpCog(BaseCog, name='Help'):
224 224
 		search: Optional[str]
225 225
 			search terms
226 226
 		"""
227
+		self.log(interaction.guild, f'{interaction.user.name} used /help {search}')
227 228
 		if search is None:
228 229
 			await self.__send_general_help(interaction)
229 230
 			return

+ 5
- 3
rocketbot/cogsetting.py Переглянути файл

@@ -147,6 +147,7 @@ class CogSetting:
147 147
 		async def getter(interaction: Interaction) -> None:
148 148
 			key = f'{cog.__class__.__name__}.{setting.name}'
149 149
 			value = setting.to_native_value(Storage.get_config_value(interaction.guild, key))
150
+			cog.log(interaction.guild, f'{interaction.user.name} used /get setting_name')
150 151
 			if value is None:
151 152
 				value = setting.to_native_value(cog.get_cog_default(setting.name))
152 153
 				await interaction.response.send_message(
@@ -179,6 +180,7 @@ class CogSetting:
179 180
 		if cog.config_prefix is not None:
180 181
 			setting_name = f'{cog.config_prefix}_{setting_name}'
181 182
 		async def setter_general(interaction: Interaction, new_value) -> None:
183
+			cog.log(interaction.guild, f'{interaction.user.name} used /set setting_name {new_value}')
182 184
 			try:
183 185
 				setting.validate_value(new_value)
184 186
 			except ValueError as ve:
@@ -194,7 +196,6 @@ class CogSetting:
194 196
 				ephemeral=True
195 197
 			)
196 198
 			await cog.on_setting_updated(interaction.guild, setting)
197
-			cog.log(interaction.guild, f'{interaction.user.name} set {key} to {new_value}')
198 199
 
199 200
 		setter: CommandCallback = setter_general
200 201
 		if self.datatype is int:
@@ -273,7 +274,7 @@ class CogSetting:
273 274
 				ephemeral=True
274 275
 			)
275 276
 			await cog.on_setting_updated(interaction.guild, setting)
276
-			cog.log(interaction.guild, f'{interaction.user.name} enabled {cog.__class__.__name__}')
277
+			cog.log(interaction.guild, f'{interaction.user.name} used /enable {cog.__class__.__name__}')
277 278
 
278 279
 		bot_log(None, cog.__class__, f"Creating command: /enable {cog.config_prefix}")
279 280
 		command = Command(
@@ -299,7 +300,7 @@ class CogSetting:
299 300
 				ephemeral=True
300 301
 			)
301 302
 			await cog.on_setting_updated(interaction.guild, setting)
302
-			cog.log(interaction.guild, f'{interaction.user.name} disabled {cog.__class__.__name__}')
303
+			cog.log(interaction.guild, f'{interaction.user.name} used /disable {cog.__class__.__name__}')
303 304
 
304 305
 		bot_log(None, cog.__class__, f"Creating command: /disable {cog.config_prefix}")
305 306
 		command = Command(
@@ -385,6 +386,7 @@ class CogSetting:
385 386
 		from rocketbot.cogs.basecog import BaseCog
386 387
 		async def show_all(interaction: Interaction) -> None:
387 388
 			try:
389
+				bot_log(interaction.guild, None, f'{interaction.user.name} used /get all')
388 390
 				guild = interaction.guild
389 391
 				if guild is None:
390 392
 					await interaction.response.send_message(

Завантаження…
Відмінити
Зберегти