From 2ca94dd37760ed2aed2c297e443c0653824af5da Mon Sep 17 00:00:00 2001 From: TSRBerry <20988865+TSRBerry@users.noreply.github.com> Date: Mon, 26 Jun 2023 07:47:57 +0200 Subject: [PATCH] macro: Allow users to target multiple members when invoking macros (#64) * macro: Use Greedy type annotation to optionally match multiple members * Apply black formatting --- robocop_ng/cogs/macro.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/robocop_ng/cogs/macro.py b/robocop_ng/cogs/macro.py index f34e752..413161c 100644 --- a/robocop_ng/cogs/macro.py +++ b/robocop_ng/cogs/macro.py @@ -2,7 +2,7 @@ from typing import Optional import discord from discord.ext import commands -from discord.ext.commands import Cog, Context, BucketType +from discord.ext.commands import Cog, Context, BucketType, Greedy from robocop_ng.helpers.checks import check_if_staff, check_if_staff_or_dm from robocop_ng.helpers.macros import ( @@ -24,14 +24,16 @@ class Macro(Cog): @commands.cooldown(3, 30, BucketType.member) @commands.command(aliases=["m"]) async def macro( - self, ctx: Context, key: str, target: Optional[discord.Member] = None + self, ctx: Context, key: str, targets: Greedy[discord.Member] = None ): await ctx.message.delete() if len(key) > 0: text = get_macro(self.bot, key) if text is not None: - if target is not None: - await ctx.send(f"{target.mention}:\n{text}") + if targets is not None: + await ctx.send( + f"{', '.join(target.mention for target in targets)}:\n{text}" + ) else: if ctx.message.reference is not None: await ctx.send(