aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar TizzySaurus <[email protected]>2021-10-17 12:21:09 +0100
committerGravatar Izan <[email protected]>2021-10-17 12:30:09 +0100
commita7bb17c3e475594ac2e52a4958f382fe9d26b036 (patch)
tree21aafa060e7248f260b2f1585dbf923fe29fe83c
parentMerge pull request #889 from python-discord/fix-pascal-triangle-image (diff)
Fix bugs in `.issue` command & add aliases
- Now requires at least one issue/PR - No longer continues to send issues/PRs when there's too many listed in the invocation - Added plural aliases (`.issues` and `.prs`)
-rw-r--r--bot/exts/utilities/issues.py19
1 files changed, 14 insertions, 5 deletions
diff --git a/bot/exts/utilities/issues.py b/bot/exts/utilities/issues.py
index 8a7ebed0..36655e1b 100644
--- a/bot/exts/utilities/issues.py
+++ b/bot/exts/utilities/issues.py
@@ -185,7 +185,7 @@ class Issues(commands.Cog):
return resp
@whitelist_override(channels=WHITELISTED_CHANNELS, categories=WHITELISTED_CATEGORIES)
- @commands.command(aliases=("pr",))
+ @commands.command(aliases=("issues", "pr", "prs"))
async def issue(
self,
ctx: commands.Context,
@@ -197,14 +197,23 @@ class Issues(commands.Cog):
# Remove duplicates
numbers = set(numbers)
- if len(numbers) > MAXIMUM_ISSUES:
- embed = discord.Embed(
+ err_message = None
+ if not numbers:
+ err_message = "You must have at least one issue/PR!"
+
+ elif len(numbers) > MAXIMUM_ISSUES:
+ err_message = f"Too many issues/PRs! (maximum of {MAXIMUM_ISSUES})"
+
+ # If there's an error with command invocation then send an error embed
+ if err_message is not None:
+ err_embed = discord.Embed(
title=random.choice(ERROR_REPLIES),
color=Colours.soft_red,
- description=f"Too many issues/PRs! (maximum of {MAXIMUM_ISSUES})"
+ description=err_message
)
- await ctx.send(embed=embed)
+ await ctx.send(embed=err_embed)
await invoke_help_command(ctx)
+ return
results = [await self.fetch_issues(number, repository, user) for number in numbers]
await ctx.send(embed=self.format_embed(results, user, repository))