[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
This commit is contained in:
Draper 2019-07-03 20:26:22 +01:00 committed by Michael H
parent 0eb22c84ff
commit a89a156f8e

View File

@ -1,6 +1,6 @@
import asyncio import asyncio
import contextlib import contextlib
from typing import Iterable, List from typing import Iterable, List, Union
import discord import discord
from discord.ext import commands from discord.ext import commands
@ -86,6 +86,22 @@ class Context(commands.Context):
else: else:
return True 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( async def send_interactive(
self, messages: Iterable[str], box_lang: str = None, timeout: int = 15 self, messages: Iterable[str], box_lang: str = None, timeout: int = 15
) -> List[discord.Message]: ) -> List[discord.Message]: