Skip to content

Commit

Permalink
!complement separated into two
Browse files Browse the repository at this point in the history
  • Loading branch information
Ereiarrus committed Feb 4, 2024
1 parent 8ffda43 commit c88295f
Showing 1 changed file with 23 additions and 9 deletions.
32 changes: 23 additions & 9 deletions src/complements_bot/bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,19 @@ async def complement(self, ctx: commands.Context) -> None:
The user of this command is allowed to prepend an optional '@' to the user's name with no change to the
behaviour of the command.
"""
to_send = await self.complement_h(ctx)
if to_send:
await ctx.channel.send(to_send)
custom_log(
f"In {ctx.channel.name} at {ctx.message.timestamp}, {ctx.message.author.name} "
f"was complemented (by command) with: {to_send}",
ComplementsBot.SHOULD_LOG
)

async def complement_h(self, ctx: commands.Context) -> Optional[str]:
"""
helper for complement()
"""

who: str = self.isolate_args(ctx.message.content)
if len(who) > 0:
Expand Down Expand Up @@ -315,15 +328,16 @@ async def complement(self, ctx: commands.Context) -> None:
if is_user_ignored or not cmd_complement_enabled:
return

comp_msg, exists = await self.complement_msg(
who, ctx.channel.name, await database.is_cmd_complement_muted(userid=channel_id))
if exists:
await ctx.channel.send(comp_msg)
custom_log(
f"In channel {ctx.channel.name}, at {ctx.message.timestamp}, {ctx.message.author.name} "
f"was complemented (by command) with: {comp_msg}",
ComplementsBot.SHOULD_LOG
)
comp_msg: Optional[str]
comp_msg: bool
comp_msg, complement_exists = await self.complement_msg(
who,
ctx.channel.name,
await database.is_cmd_complement_muted(userid=channel_id)
)
if complement_exists:
comp_msg = None if not complement_exists else comp_msg
return comp_msg

@commands.command()
async def compunignoreme(self, ctx: commands.Context) -> None:
Expand Down

0 comments on commit c88295f

Please sign in to comment.