diff options
| author | 2020-07-19 13:31:00 +0800 | |
|---|---|---|
| committer | 2020-07-19 13:31:00 +0800 | |
| commit | ced9117e848a9eb1e003576d4f355ba7aa220cd8 (patch) | |
| tree | 73f3bc501fbefb1183deb277aab0777783c39f2b /bot/cogs/reminders.py | |
| parent | Namespace Member and Role to avoid extra imports (diff) | |
Extract `send_denial` to a utility function
Diffstat (limited to '')
| -rw-r--r-- | bot/cogs/reminders.py | 21 |
1 files changed, 6 insertions, 15 deletions
diff --git a/bot/cogs/reminders.py b/bot/cogs/reminders.py index ae387f09a..f36b67f5a 100644 --- a/bot/cogs/reminders.py +++ b/bot/cogs/reminders.py @@ -12,10 +12,11 @@ from dateutil.relativedelta import relativedelta from discord.ext.commands import Cog, Context, Greedy, group from bot.bot import Bot -from bot.constants import Guild, Icons, MODERATION_ROLES, NEGATIVE_REPLIES, POSITIVE_REPLIES, STAFF_ROLES +from bot.constants import Guild, Icons, MODERATION_ROLES, POSITIVE_REPLIES, STAFF_ROLES from bot.converters import Duration from bot.pagination import LinePaginator from bot.utils.checks import without_role_check +from bot.utils.messages import send_denial from bot.utils.scheduling import Scheduler from bot.utils.time import humanize_delta @@ -103,16 +104,6 @@ class Reminders(Cog): await ctx.send(embed=embed) @staticmethod - async def _send_denial(ctx: Context, reason: str) -> None: - """Send an embed denying the user from creating a reminder.""" - embed = discord.Embed() - embed.colour = discord.Colour.red() - embed.title = random.choice(NEGATIVE_REPLIES) - embed.description = reason - - await ctx.send(embed=embed) - - @staticmethod async def allow_mentions(ctx: Context, mentions: t.List[Mentionable]) -> t.Tuple[bool, str]: """ Returns whether or not the list of mentions is allowed. @@ -220,7 +211,7 @@ class Reminders(Cog): # If they don't have permission to set a reminder in this channel if ctx.channel.id not in WHITELISTED_CHANNELS: - return await self._send_denial(ctx, "Sorry, you can't do that here!") + return await send_denial(ctx, "Sorry, you can't do that here!") # Get their current active reminders active_reminders = await self.bot.api_client.get( @@ -233,13 +224,13 @@ class Reminders(Cog): # Let's limit this, so we don't get 10 000 # reminders from kip or something like that :P if len(active_reminders) > MAXIMUM_REMINDERS: - return await self._send_denial(ctx, "You have too many active reminders!") + return await send_denial(ctx, "You have too many active reminders!") # Filter mentions to see if the user can mention members/roles if mentions: mentions_allowed, disallowed_mentions = await self.allow_mentions(ctx, mentions) if not mentions_allowed: - return await self._send_denial( + return await send_denial( ctx, f"You can't mention other {disallowed_mentions} in your reminder!" ) @@ -389,7 +380,7 @@ class Reminders(Cog): # Filter mentions to see if the user can mention members/roles mentions_allowed, disallowed_mentions = await self.allow_mentions(ctx, mentions) if not mentions_allowed: - return await self._send_denial( + return await send_denial( ctx, f"You can't mention other {disallowed_mentions} in your reminder!" ) |