Merge pull request '0.3 - /user info für alle (#119)' (#122) from #119 into 0.3

Reviewed-on: sh-edraft.de/kd_discord_bot#122
Reviewed-by: Ebola-Chan <nick.jungmann@gmail.com>
Closes #119
This commit is contained in:
Sven Heidemann 2022-11-17 20:40:55 +01:00
commit 549b05087f
2 changed files with 26 additions and 17 deletions

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