From 5fb34b2fc1824da1506e36e927a0d3458aa545d4 Mon Sep 17 00:00:00 2001 From: Daniel Milnes Date: Tue, 5 May 2020 23:25:55 +0100 Subject: [PATCH 1/3] Rate limit `:latex` --- cdbot/cogs/maths.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/cdbot/cogs/maths.py b/cdbot/cogs/maths.py index 52faeb2b..f89950a2 100644 --- a/cdbot/cogs/maths.py +++ b/cdbot/cogs/maths.py @@ -8,7 +8,7 @@ import httpx from discord import Colour, Embed, File from discord.ext import tasks -from discord.ext.commands import Bot, Cog, Context, command +from discord.ext.commands import Bot, BucketType, Cog, Context, command from html2markdown import convert from cdbot.constants import Maths as constants @@ -119,6 +119,9 @@ async def on_message(self, message): await self.latex(message.channel, expression) @command() + @cooldown(1, 60, BucketType.user) + @cooldown(4, 60, BucketType.channel) + @cooldown(6, 3600, BucketType.guild) async def challenge(self, ctx: Context, number: int = 1): """Show the provided challenge number.""" challenge = await get_challenge(number) From 201bab06c39988566e83d278587f96cdca814fbf Mon Sep 17 00:00:00 2001 From: Daniel Milnes Date: Tue, 5 May 2020 23:29:44 +0100 Subject: [PATCH 2/3] Import countdown --- cdbot/cogs/maths.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cdbot/cogs/maths.py b/cdbot/cogs/maths.py index f89950a2..9a9ea45a 100644 --- a/cdbot/cogs/maths.py +++ b/cdbot/cogs/maths.py @@ -8,7 +8,7 @@ import httpx from discord import Colour, Embed, File from discord.ext import tasks -from discord.ext.commands import Bot, BucketType, Cog, Context, command +from discord.ext.commands import Bot, BucketType, Cog, Context, command, cooldown from html2markdown import convert from cdbot.constants import Maths as constants From e66809770744b557785b0bd323923ba1b842ef14 Mon Sep 17 00:00:00 2001 From: Daniel Milnes Date: Mon, 25 May 2020 13:27:20 +0100 Subject: [PATCH 3/3] Put the rate limit on the right function --- cdbot/cogs/maths.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cdbot/cogs/maths.py b/cdbot/cogs/maths.py index 6e246db3..75c18611 100644 --- a/cdbot/cogs/maths.py +++ b/cdbot/cogs/maths.py @@ -119,9 +119,6 @@ async def on_message(self, message): await self.latex(message.channel, expression) @command() - @cooldown(1, 60, BucketType.user) - @cooldown(4, 60, BucketType.channel) - @cooldown(6, 3600, BucketType.guild) async def challenge(self, ctx: Context, number: int = 1): """Show the provided challenge number.""" challenge = await get_challenge(number) @@ -146,6 +143,9 @@ async def challenge(self, ctx: Context, number: int = 1): return await ctx.send(embed=embed) @command() + @cooldown(1, 60, BucketType.user) + @cooldown(4, 60, BucketType.channel) + @cooldown(6, 3600, BucketType.guild) async def latex(self, ctx: Context, expression: str): """Render a LaTeX expression.""" channel = ctx.channel.id if type(ctx) is Context else ctx.id