0.3 #146

Merged
edraft merged 359 commits from 0.3 into master 2023-01-12 07:04:40 +01:00
Showing only changes of commit bf107f9a18 - Show all commits

View File

@ -168,9 +168,32 @@ class StatsGroup(DiscordCommandABC):
self._logger.trace(__name__, f'Started stats command form')
await ctx.interaction.response.send_modal(form)
except Exception as e:
self._logger.error(__name__, f'Cannot view statistic {name}', e)
self._logger.error(__name__, f'Cannot edit statistic {name}', e)
await self._message_service.send_ctx_msg(ctx, self._t.transform('modules.stats.edit.failed'))
@edit.autocomplete('name')
async def edit_autocomplete(self, interaction: discord.Interaction, current: str) -> TList[app_commands.Choice[str]]:
return [app_commands.Choice(name=f'{statistic.name}: {statistic.description}', value=statistic.name) for statistic in stats]
@stats.command()
@commands.guild_only()
async def remove(self, ctx: Context, name: str):
self._logger.debug(__name__, f'Received command stats remove {ctx}: {name}')
if not await self._client_utils.check_if_bot_is_ready_yet_and_respond(ctx):
return
if not self._permissions.is_member_technician(ctx.author):
await self._message_service.send_ctx_msg(ctx, self._t.transform('common.no_permission_message'))
self._logger.trace(__name__, f'Finished command stats remove')
return
try:
stats.remove(stats.where(lambda s: s.name == name).single())
self._logger.trace(__name__, f'Finished stats remove command')
except Exception as e:
self._logger.error(__name__, f'Cannot remove statistic {name}', e)
await self._message_service.send_ctx_msg(ctx, self._t.transform('modules.stats.edit.failed'))
@remove.autocomplete('name')
async def edit_autocomplete(self, interaction: discord.Interaction, current: str) -> TList[app_commands.Choice[str]]:
return [app_commands.Choice(name=f'{statistic.name}: {statistic.description}', value=statistic.name) for statistic in stats]