Improved /user info command #119

This commit is contained in:
Sven Heidemann 2022-11-17 16:49:33 +01:00
parent 42d8a16d05
commit 63fe566044
3 changed files with 27 additions and 18 deletions

@ -1 +1 @@
Subproject commit bd8d3a5dad13e0fdcad79b767c032997b716b1a4
Subproject commit c8e3ac096317cfdafe809398a80cf659189d42a5

View File

@ -62,10 +62,14 @@ class UserGroup(DiscordCommandABC):
@user.command()
@commands.guild_only()
@CommandChecks.check_is_ready()
@CommandChecks.check_is_member_moderator()
async def info(self, ctx: Context, member: Optional[discord.Member] = None, *, wait: int = None):
self._logger.debug(__name__, f'Received command user-info {ctx}:{member},{wait}')
is_mod = self._permissions.is_member_moderator(ctx.author)
if member is not None and not is_mod:
await self._message_service.send_ctx_msg(ctx, self._t.transform('common.no_permission_message'))
return
if member is None or not isinstance(member, discord.Member):
member = ctx.author
@ -94,11 +98,13 @@ class UserGroup(DiscordCommandABC):
roles += f'{role.name}\n'
embed.add_field(name=self._t.transform('modules.base.user_info.fields.roles'), value=roles, inline=False)
if is_mod or member == ctx.author:
joins_string = ''
for join in joins:
joins_string += f'{self._date.transform(join.joined_on)}\n'
embed.add_field(name=self._t.transform('modules.base.user_info.fields.joins'), value=joins_string)
if is_mod or member == ctx.author:
lefts_string = ''
for join in joins:
if join.leaved_on is None:
@ -106,8 +112,12 @@ class UserGroup(DiscordCommandABC):
lefts_string = '/'
continue
lefts_string += f'{self._date.transform(join.leaved_on)}\n'
embed.add_field(name=self._t.transform('modules.base.user_info.fields.lefts'), value=lefts_string)
if is_mod or member == ctx.author:
embed.add_field(name=self._t.transform('modules.base.user_info.fields.warnings'), value=self._t.transform('common.not_implemented_yet'), inline=False)
await self._message_service.send_ctx_msg(ctx, embed, wait_before_delete=wait)
# send to interaction because of sensitive data
await self._message_service.send_interaction_msg(ctx.interaction, embed, wait_before_delete=wait)
self._logger.trace(__name__, f'Finished user-info command')

View File

@ -128,8 +128,7 @@ class PermissionService(PermissionServiceABC):
return member.guild.id in self._admins and member in self._admins[member.guild.id]
def is_member_moderator(self, member: discord.Member) -> bool:
return member.guild.id in self._moderators \
and member in self._moderators[member.guild.id] or self.is_member_admin(member)
return member.guild.id in self._moderators and member in self._moderators[member.guild.id] or self.is_member_admin(member)
def is_member_technician(self, member: discord.Member) -> bool:
return member in self._technicians