forked from sh-edraft.de/sh_discord_bot
Improved /user info command #119
This commit is contained in:
parent
42d8a16d05
commit
63fe566044
@ -1 +1 @@
|
|||||||
Subproject commit bd8d3a5dad13e0fdcad79b767c032997b716b1a4
|
Subproject commit c8e3ac096317cfdafe809398a80cf659189d42a5
|
@ -62,10 +62,14 @@ class UserGroup(DiscordCommandABC):
|
|||||||
@user.command()
|
@user.command()
|
||||||
@commands.guild_only()
|
@commands.guild_only()
|
||||||
@CommandChecks.check_is_ready()
|
@CommandChecks.check_is_ready()
|
||||||
@CommandChecks.check_is_member_moderator()
|
|
||||||
async def info(self, ctx: Context, member: Optional[discord.Member] = None, *, wait: int = None):
|
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}')
|
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):
|
if member is None or not isinstance(member, discord.Member):
|
||||||
member = ctx.author
|
member = ctx.author
|
||||||
|
|
||||||
@ -94,11 +98,13 @@ class UserGroup(DiscordCommandABC):
|
|||||||
roles += f'{role.name}\n'
|
roles += f'{role.name}\n'
|
||||||
embed.add_field(name=self._t.transform('modules.base.user_info.fields.roles'), value=roles, inline=False)
|
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 = ''
|
joins_string = ''
|
||||||
for join in joins:
|
for join in joins:
|
||||||
joins_string += f'{self._date.transform(join.joined_on)}\n'
|
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)
|
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 = ''
|
lefts_string = ''
|
||||||
for join in joins:
|
for join in joins:
|
||||||
if join.leaved_on is None:
|
if join.leaved_on is None:
|
||||||
@ -106,8 +112,12 @@ class UserGroup(DiscordCommandABC):
|
|||||||
lefts_string = '/'
|
lefts_string = '/'
|
||||||
continue
|
continue
|
||||||
lefts_string += f'{self._date.transform(join.leaved_on)}\n'
|
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)
|
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)
|
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')
|
self._logger.trace(__name__, f'Finished user-info command')
|
||||||
|
@ -128,8 +128,7 @@ class PermissionService(PermissionServiceABC):
|
|||||||
return member.guild.id in self._admins and member in self._admins[member.guild.id]
|
return member.guild.id in self._admins and member in self._admins[member.guild.id]
|
||||||
|
|
||||||
def is_member_moderator(self, member: discord.Member) -> bool:
|
def is_member_moderator(self, member: discord.Member) -> bool:
|
||||||
return member.guild.id in self._moderators \
|
return member.guild.id in self._moderators and member in self._moderators[member.guild.id] or self.is_member_admin(member)
|
||||||
and member in self._moderators[member.guild.id] or self.is_member_admin(member)
|
|
||||||
|
|
||||||
def is_member_technician(self, member: discord.Member) -> bool:
|
def is_member_technician(self, member: discord.Member) -> bool:
|
||||||
return member in self._technicians
|
return member in self._technicians
|
||||||
|
Loading…
Reference in New Issue
Block a user