From d3813ac9d97b117591c629e6a631f755c5d9894b Mon Sep 17 00:00:00 2001 From: sgoudham Date: Mon, 22 Jun 2020 01:48:56 +0100 Subject: [PATCH] Getting cooldowns working --- cogs/Embeds.py | 13 +++++++------ cogs/FunCommands.py | 11 +++++------ cogs/OwOText.py | 9 ++++----- 3 files changed, 16 insertions(+), 17 deletions(-) diff --git a/cogs/Embeds.py b/cogs/Embeds.py index 4ea3b5fb..64f72f1c 100644 --- a/cogs/Embeds.py +++ b/cogs/Embeds.py @@ -5,6 +5,7 @@ import random import discord from discord.ext import commands from discord.ext.commands import BucketType +from discord.ext.commands import cooldown import settings @@ -17,7 +18,7 @@ class Embeds(commands.Cog): # ~kiss command which allows users to kiss a person in the server @commands.command(aliases=["Kiss", "kiss"]) # Added a cooldown, only 1 instance of the command can be sent every second per user - @commands.cooldown(1, 1, BucketType.user) + @cooldown(1, 1, BucketType.user) async def kissing(self, ctx, target: discord.Member): # Surround with try/except to catch any exceptions that may occur @@ -63,7 +64,7 @@ class Embeds(commands.Cog): # ~kill command which allows users to kill a person in the server @commands.command(aliases=["Kill", "k"]) # Added a cooldown, only 1 instance of the command can be sent every second per user - @commands.cooldown(1, 1, BucketType.user) + @cooldown(1, 1, BucketType.user) async def kill(self, ctx, target: discord.Member): # Surround with try/except to catch any exceptions that may occur @@ -109,7 +110,7 @@ class Embeds(commands.Cog): # ~cuddle command which allows users to cuddle a person in the server @commands.command(aliases=["Cuddle"]) # Added a cooldown, only 1 instance of the command can be sent every second per user - @commands.cooldown(1, 1, BucketType.user) + @cooldown(1, 1, BucketType.user) async def cuddle(self, ctx, target: discord.Member): # Surround with try/except to catch any exceptions that may occur @@ -155,7 +156,7 @@ class Embeds(commands.Cog): # ~slap command which allows users to cuddle a person in the server @commands.command(aliases=["Slap"]) # Added a cooldown, only 1 instance of the command can be sent every second per user - @commands.cooldown(1, 1, BucketType.user) + @cooldown(1, 1, BucketType.user) async def slap(self, ctx, target: discord.Member): # Surround with try/except to catch any exceptions that may occur @@ -201,7 +202,7 @@ class Embeds(commands.Cog): # ~slap command which allows users to cuddle a person in the server @commands.command(aliases=["Pat"]) # Added a cooldown, only 1 instance of the command can be sent every second per user - @commands.cooldown(1, 1, BucketType.user) + @cooldown(1, 1, BucketType.user) async def pat(self, ctx, target: discord.Member): # Surround with try/except to catch any exceptions that may occur @@ -247,7 +248,7 @@ class Embeds(commands.Cog): # ~lemon command which allows users to hand people lemons to members in the user @commands.command(aliases=["lem", "Lemon", "Lem"]) # Added a cooldown, only 1 instance of the command can be sent every second per user - @commands.cooldown(1, 1, BucketType.user) + @cooldown(1, 1, BucketType.user) async def lemon(self, ctx, target: discord.Member): lemon_array = ["https://media.discordapp.net/attachments/669812887564320769/720093589056520202/lemon.gif", diff --git a/cogs/FunCommands.py b/cogs/FunCommands.py index 937fad83..e4d2ef13 100644 --- a/cogs/FunCommands.py +++ b/cogs/FunCommands.py @@ -3,7 +3,7 @@ import random import discord from discord.ext import commands -from discord.ext.commands import BucketType +from discord.ext.commands import BucketType, cooldown import settings from cogs.Embeds import error_function @@ -60,7 +60,7 @@ class Fun(commands.Cog): # ~compliment command for everyone to use to compliment someone @commands.command(aliases=['comp', 'Compliment', 'Comp']) # Added a cooldown, only 1 instance of the command can be sent every second per user - @commands.cooldown(1, 1, BucketType.user) + @cooldown(1, 1, BucketType.user) async def compliment(self, ctx, target: discord.Member): # Set up array of compliments to throw at people @@ -106,12 +106,11 @@ class Fun(commands.Cog): # Sending out a random compliment from the array "responses" await ctx.send(random.choice(responses)) - # await ctx.send(f"{target.mention} Your wedding will be wonderful, but the y is silent ") # ~8Ball command @commands.command(aliases=['8ball', '8Ball', ' 8Ball']) # Added a cooldown, only 1 instance of the command can be sent every second per user - @commands.cooldown(1, 1, BucketType.user) + @cooldown(1, 1, BucketType.user) async def _8ball(self, ctx, *, question): # Setting up the channels that the commands can be sent in @@ -147,7 +146,7 @@ class Fun(commands.Cog): # ~Lukas command that only Lukas can use @commands.command(aliases=['Lukas']) # Added a cooldown, only 1 instance of the command can be sent every second per user - @commands.cooldown(1, 1, BucketType.user) + @cooldown(1, 1, BucketType.user) @commands.has_any_role('Lukas (Server Booster)') async def lukas(self, ctx): @@ -167,7 +166,7 @@ class Fun(commands.Cog): # ~Flip command to allow for 50/50 chance decisions @commands.command(aliases=['Flip']) - @commands.cooldown(1, 1, BucketType.user) + @cooldown(1, 1, BucketType.user) async def flip(self, ctx): # Define 3 arrays that only have 2 strings stored in them diff --git a/cogs/OwOText.py b/cogs/OwOText.py index a0831a60..f5e5f88d 100644 --- a/cogs/OwOText.py +++ b/cogs/OwOText.py @@ -1,8 +1,9 @@ +import asyncio import random from discord.ext import commands # OwO Impowt da wibwawy ÙωÙ -from discord.ext.commands import BucketType +from discord.ext.commands import BucketType, cooldown from owotext import OwO # Defining an array of all the vowels in lowercase and uppercase @@ -44,7 +45,7 @@ class OwOText(commands.Cog): # ~owo command allows for text to be 'converted to OWO' @commands.command() - @commands.cooldown(1, 1, BucketType.user) + @cooldown(1, 1, BucketType.user) async def owo(self, ctx): if ctx.message.content.startswith("~owo"): msg = ctx.message.content.split("~owo ", 1) @@ -54,8 +55,7 @@ class OwOText(commands.Cog): await ctx.message.channel.send(owo) - -""" # Bot Event for handling cooldown error + # Bot Event for handling cooldown error @commands.Cog.listener() async def on_command_error(self, ctx, error): if isinstance(error, commands.CommandOnCooldown): @@ -65,7 +65,6 @@ class OwOText(commands.Cog): await asyncio.sleep(2.5) # Delete the message await message.delete() -""" def setup(bot):