Skip to content

Commit

Permalink
Merge pull request #222 from Bot-detector/develop
Browse files Browse the repository at this point in the history
release
  • Loading branch information
extreme4all authored Dec 30, 2023
2 parents 446b99a + 31d4946 commit 7750799
Showing 1 changed file with 17 additions and 6 deletions.
23 changes: 17 additions & 6 deletions src/cogs/rsn_linking_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,20 @@ def _batch(self, iterable, n=1) -> list:
for ndx in range(0, l, n):
yield iterable[ndx : min(ndx + n, l)]

async def send_pm(self, ctx: discord.Context, *args, **kwargs):
"""Handles sending a PM to a context author. Will tell user to check PMs, and reply with an error message
if failed due to disabled PMs.
:param ctx: Context to use
:param args: Passed to PM .send()
:param kwargs: Passed to PM .send()
"""
try:
await ctx.author.send(*args, **kwargs)
await ctx.reply("Please check your PMs.")
except discord.Forbidden:
await ctx.reply("This command requires that your PMs be enabled. Please enable your PMs, then try again.")

async def verified_msg(self, name: str) -> discord.Embed:
embed = discord.Embed(title=f"{name}'s Status:", color=0x00FF00)
embed.add_field(name="Verified:", value=f"{name} is Verified.", inline=False)
Expand Down Expand Up @@ -152,8 +166,7 @@ async def link(self, ctx: Context, *, name: str):
code = linked_user.get("Code")
# send user via pm the random code
embed = await self.link_msg(name, code)
await ctx.author.send(embed=embed)
await ctx.reply("Please check your pm")
await self.send_pm(ctx, embed=embed)
return

# generate random code
Expand All @@ -166,8 +179,7 @@ async def link(self, ctx: Context, *, name: str):

# send user via pm the random code
embed = await self.link_msg(name, code)
await ctx.author.send(embed=embed)
await ctx.reply("Please check your pm")
await self.send_pm(ctx, embed=embed)
return

@commands.hybrid_command(name="verify")
Expand Down Expand Up @@ -206,8 +218,7 @@ async def verify(self, ctx: Context, name: str):
code = linked_user.get("Code")
# send user via pm the random code
embed = await self.link_msg(name, code)
await ctx.author.send(embed=embed)
await ctx.reply("Please check your pm")
await self.send_pm(ctx, embed=embed)
return
else:
embed = await self.unverified_msg(name)
Expand Down

0 comments on commit 7750799

Please sign in to comment.