From dd4cd0eeb176ab09dffcb620e432675319de989c Mon Sep 17 00:00:00 2001 From: Michael H Date: Fri, 4 May 2018 02:16:24 -0400 Subject: [PATCH] provide an extra method for helping wor with embed_requested (#1558) --- redbot/core/context.py | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/redbot/core/context.py b/redbot/core/context.py index 10aae2e6e..83b35ec37 100644 --- a/redbot/core/context.py +++ b/redbot/core/context.py @@ -137,3 +137,32 @@ class RedContext(commands.Context): return await self.bot.embed_requested( self.channel, self.author, command=self.command ) + + async def maybe_send_embed(self, message: str) -> discord.Message: + """ + Simple helper to send a simple message to context + without manually checking ctx.embed_requested + This should only be used for simple messages. + + Parameters + ---------- + message: `str` + The string to send + + Returns + ------- + discord.Message: + the message which was sent + + Raises + ------ + discord.Forbidden + see `discord.abc.Messageable.send` + discord.HTTPException + see `discord.abc.Messageable.send` + """ + + if await self.embed_requested(): + return await self.send(embed=discord.Embed(description=message)) + else: + return await self.send(message)