From fe2771ba29c86370e41b6d76abba157a737f073c Mon Sep 17 00:00:00 2001 From: sgoudham Date: Wed, 3 Jun 2020 00:59:52 +0100 Subject: [PATCH] Got the restricted channels working --- EnsoBot.py | 12 +++++++++++- cogs/FunCommands.py | 10 +++++++++- cogs/WaifuImages.py | 9 +++++++++ cogs/__pycache__/FunCommands.cpython-36.pyc | Bin 3352 -> 3343 bytes cogs/__pycache__/WaifuImages.cpython-36.pyc | Bin 8232 -> 8395 bytes 5 files changed, 29 insertions(+), 2 deletions(-) diff --git a/EnsoBot.py b/EnsoBot.py index 5308e212..87c289f7 100644 --- a/EnsoBot.py +++ b/EnsoBot.py @@ -78,7 +78,17 @@ async def on_command_error(ctx, error): if isinstance(error, commands.CommandOnCooldown): message = await ctx.send(f'That command is on cooldown. Try again in {error.retry_after:,.2f} seconds.') - # Let the user read the message for 1.5 seconds + # Let the user read the message for 2.5 seconds + await asyncio.sleep(2.5) + # Delete the message + await message.delete() + +@client.event +async def on_command_error(ctx, error): + if isinstance(error, commands.CommandOnCooldown): + message = await ctx.send(f'That command is on cooldown. Try again in {error.retry_after:,.2f} seconds.') + + # Let the user read the message for 2.5 seconds await asyncio.sleep(2.5) # Delete the message await message.delete() diff --git a/cogs/FunCommands.py b/cogs/FunCommands.py index 0cb7936b..0b1748f9 100644 --- a/cogs/FunCommands.py +++ b/cogs/FunCommands.py @@ -1,4 +1,5 @@ import random +import asyncio from discord.ext import commands from discord.ext.commands import BucketType, cooldown @@ -12,7 +13,13 @@ class Fun(commands.Cog): @cooldown(1, 3, BucketType.channel) async def _8ball(self, ctx, *, question): channels = ["bot-commands"] - if str(ctx.channel) in channels: + if str(ctx.channel) not in channels: + message = await ctx.send("Sorry! I only work in #bot-commands!") + + # Let the user read the message for 2.5 seconds + await asyncio.sleep(2.5) + # Delete the message + await message.delete() responses = [ "Hamothy is preoccupied with catching a case", "The prophet Kate believes it will come true", @@ -69,6 +76,7 @@ class Fun(commands.Cog): "Hamothy has used his godlike like powers to align the stars for you, it must be true", "Gabriel appears out of thin air and smites you", "Yes yes yes!!!", + "No I don't care about your question, where is my podcast!??!?" ] await ctx.send(f'Question: {question}\nAnswer: {random.choice(responses)}') diff --git a/cogs/WaifuImages.py b/cogs/WaifuImages.py index b0d785ab..8c64b80d 100644 --- a/cogs/WaifuImages.py +++ b/cogs/WaifuImages.py @@ -1,4 +1,5 @@ import random +import asyncio import discord from discord.ext import commands from discord.ext.commands import BucketType, cooldown @@ -13,6 +14,14 @@ class Waifus(commands.Cog): @cooldown(1, 5, BucketType.channel) async def kakashi(self, ctx): channels = ["bot-commands"] + if str(ctx.channel) not in channels: + message = await ctx.send("Sorry! I only work in #bot-commands!") + + # Let the user read the message for 2.5 seconds + await asyncio.sleep(2.5) + # Delete the message + await message.delete() + if str(ctx.channel) in channels: kakashi1 = "https://cdn.discordapp.com/attachments/714671068941647933/717201077346238514/image0.jpg" kakashi2 = "https://cdn.discordapp.com/attachments/714671068941647933/717201077669331036/image1.jpg" diff --git a/cogs/__pycache__/FunCommands.cpython-36.pyc b/cogs/__pycache__/FunCommands.cpython-36.pyc index 154462c8cd385519c8a0f80aea738c649ba37af1..466e164303f1afa397f81ddc9aa62f279db7e553 100644 GIT binary patch delta 128 zcmbOs)i1?q%*)I5=+U*fi5oc&FiNdqU|>jLOlPcRE@7x)%wlY2tYOY(D_W7lH2E=O zjzGG3EelYXDaEpeX*NTO)#OAbX#s1$DxReL65Ztd+}y;xl;X{knO1TzvQ4(-KE%ck eG_Oc(GAqvv4jCX*le0*0@=_iLMw!Xac#Hsr+$0SE delta 152 zcmeB|njyt$%*)HQ@zJ%oSsOVIFiNdsU|>jLOkqlAs%0)=sA0@vY-X%s&SooGHTf}P zj!=qax_K=NP?#yjs)lJcLyGm}cqVCa8^0=^r2G=ysT zuy8Q)F->;lPMYk`%{6&3cQBg((2gSU$#;3gCkyj5a>xR?nw&*Kljra_FvhVk&%ClUsqdYN~C`)Hr*>pdfI@5U`Y{ zK9J2IRA^_+41w>lqW)X-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