ソースを参照

Adding some basic usage logging to some commands

tags/2.0.0
Rocketsoup 2ヶ月前
コミット
41dd7deeda

+ 2
- 0
rocketbot/cogs/gamescog.py ファイルの表示

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

+ 4
- 0
rocketbot/cogs/generalcog.py ファイルの表示

87
 				'Warning issued',
87
 				'Warning issued',
88
 				ephemeral=True,
88
 				ephemeral=True,
89
 			)
89
 			)
90
+		self.log(interaction.guild, f'{interaction.user.name} used /test_warn')
90
 
91
 
91
 	@command(
92
 	@command(
92
 		description='Responds to the user with a greeting.',
93
 		description='Responds to the user with a greeting.',
100
 			f'Hey, {interaction.user.name}!',
101
 			f'Hey, {interaction.user.name}!',
101
 		 	ephemeral=True,
102
 		 	ephemeral=True,
102
 		)
103
 		)
104
+		self.log(interaction.guild, f'{interaction.user.name} used /hello')
103
 
105
 
104
 	@command(
106
 	@command(
105
 		description='Shuts down the bot.',
107
 		description='Shuts down the bot.',
113
 	async def shutdown(self, interaction: Interaction):
115
 	async def shutdown(self, interaction: Interaction):
114
 		"""Command handler"""
116
 		"""Command handler"""
115
 		await interaction.response.send_message('👋', ephemeral=True)
117
 		await interaction.response.send_message('👋', ephemeral=True)
118
+		self.log(interaction.guild, f'{interaction.user.name} used /shutdown')
116
 		await self.bot.close()
119
 		await self.bot.close()
117
 
120
 
118
 	@command(
121
 	@command(
164
 				content=f'{CONFIG["success_emoji"]} No messages found for {author.mention} '
167
 				content=f'{CONFIG["success_emoji"]} No messages found for {author.mention} '
165
 						'from the past {describe_timedelta(age)}.',
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
 		search: Optional[str]
224
 		search: Optional[str]
225
 			search terms
225
 			search terms
226
 		"""
226
 		"""
227
+		self.log(interaction.guild, f'{interaction.user.name} used /help {search}')
227
 		if search is None:
228
 		if search is None:
228
 			await self.__send_general_help(interaction)
229
 			await self.__send_general_help(interaction)
229
 			return
230
 			return

+ 5
- 3
rocketbot/cogsetting.py ファイルの表示

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

読み込み中…
キャンセル
保存