Got the restricted channels working

testing
sgoudham 5 years ago
parent 11e4f4a007
commit fe2771ba29

@ -78,7 +78,17 @@ async def on_command_error(ctx, error):
if isinstance(error, commands.CommandOnCooldown): if isinstance(error, commands.CommandOnCooldown):
message = await ctx.send(f'That command is on cooldown. Try again in {error.retry_after:,.2f} seconds.') 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) await asyncio.sleep(2.5)
# Delete the message # Delete the message
await message.delete() await message.delete()

@ -1,4 +1,5 @@
import random import random
import asyncio
from discord.ext import commands from discord.ext import commands
from discord.ext.commands import BucketType, cooldown from discord.ext.commands import BucketType, cooldown
@ -12,7 +13,13 @@ class Fun(commands.Cog):
@cooldown(1, 3, BucketType.channel) @cooldown(1, 3, BucketType.channel)
async def _8ball(self, ctx, *, question): async def _8ball(self, ctx, *, question):
channels = ["bot-commands"] 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 = [ responses = [
"Hamothy is preoccupied with catching a case", "Hamothy is preoccupied with catching a case",
"The prophet Kate believes it will come true", "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", "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", "Gabriel appears out of thin air and smites you",
"Yes yes yes!!!", "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)}') await ctx.send(f'Question: {question}\nAnswer: {random.choice(responses)}')

@ -1,4 +1,5 @@
import random import random
import asyncio
import discord import discord
from discord.ext import commands from discord.ext import commands
from discord.ext.commands import BucketType, cooldown from discord.ext.commands import BucketType, cooldown
@ -13,6 +14,14 @@ class Waifus(commands.Cog):
@cooldown(1, 5, BucketType.channel) @cooldown(1, 5, BucketType.channel)
async def kakashi(self, ctx): async def kakashi(self, ctx):
channels = ["bot-commands"] 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: if str(ctx.channel) in channels:
kakashi1 = "https://cdn.discordapp.com/attachments/714671068941647933/717201077346238514/image0.jpg" kakashi1 = "https://cdn.discordapp.com/attachments/714671068941647933/717201077346238514/image0.jpg"
kakashi2 = "https://cdn.discordapp.com/attachments/714671068941647933/717201077669331036/image1.jpg" kakashi2 = "https://cdn.discordapp.com/attachments/714671068941647933/717201077669331036/image1.jpg"

Loading…
Cancel
Save