From a89a156f8eafe7f1c6753a5fb079b37306188929 Mon Sep 17 00:00:00 2001 From: Draper Date: Wed, 3 Jul 2019 20:26:22 +0100 Subject: [PATCH] [Context] Adds react_quietly method to context (#2834) * [Context] Adds react_quietly method to context This allows developers to emojis to command messages This is a modified version of tick() It accepts True/False for Tick/Cross emoji and in addition to that any other emoji the bot can see * Removed True/False support from react quietly * Stopped catching InvalidArgument on react_quietly so that is propagated to devs --- redbot/core/commands/context.py | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/redbot/core/commands/context.py b/redbot/core/commands/context.py index 32a3a2439..63bfe8707 100644 --- a/redbot/core/commands/context.py +++ b/redbot/core/commands/context.py @@ -1,6 +1,6 @@ import asyncio import contextlib -from typing import Iterable, List +from typing import Iterable, List, Union import discord from discord.ext import commands @@ -86,6 +86,22 @@ class Context(commands.Context): else: return True + async def react_quietly( + self, reaction: Union[discord.Emoji, discord.Reaction, discord.PartialEmoji, str] + ) -> bool: + """Adds a reaction to to the command message. + Returns + ------- + bool + :code:`True` if adding the reaction succeeded. + """ + try: + await self.message.add_reaction(reaction) + except discord.HTTPException: + return False + else: + return True + async def send_interactive( self, messages: Iterable[str], box_lang: str = None, timeout: int = 15 ) -> List[discord.Message]: