aboutsummaryrefslogtreecommitdiffstats
path: root/bot
diff options
context:
space:
mode:
authorGravatar RohanJnr <[email protected]>2019-10-19 23:27:35 +0530
committerGravatar RohanJnr <[email protected]>2019-10-19 23:27:35 +0530
commite63cc06bd8287467a6eaffd00360fc6b75ea4169 (patch)
tree067e348bc268fd220b3c9984526920bf9c457503 /bot
parentMade some language corrections in the json file and also made seperate functi... (diff)
added a cool down per channel to the quiz command
Diffstat (limited to 'bot')
-rw-r--r--bot/seasons/evergreen/trivia_quiz.py8
1 files changed, 6 insertions, 2 deletions
diff --git a/bot/seasons/evergreen/trivia_quiz.py b/bot/seasons/evergreen/trivia_quiz.py
index efc3cd98..2398cb40 100644
--- a/bot/seasons/evergreen/trivia_quiz.py
+++ b/bot/seasons/evergreen/trivia_quiz.py
@@ -6,6 +6,8 @@ from pathlib import Path
import discord
from discord.ext import commands
+from discord.ext.commands import cooldown
+from discord.ext.commands.cooldowns import BucketType
from fuzzywuzzy import fuzz
from bot.constants import Roles
@@ -45,6 +47,7 @@ class TriviaQuiz(commands.Cog):
questions = json.load(json_data)
return questions
+ @cooldown(1, 20, BucketType.channel)
@commands.group(name="quiz", aliases=["trivia"], invoke_without_command=True)
async def quiz_game(self, ctx: commands.Context, category: str = "general") -> None:
"""
@@ -177,7 +180,7 @@ class TriviaQuiz(commands.Cog):
await asyncio.sleep(2)
@staticmethod
- def make_start_embed():
+ def make_start_embed() -> discord.Embed:
"""Generate a starting/introduction embed for the quiz."""
start_embed = discord.Embed(colour=discord.Colour.red())
start_embed.title = "Quiz game Starting!!"
@@ -188,7 +191,8 @@ class TriviaQuiz(commands.Cog):
)
return start_embed
- async def stop_quiz(self, author, channel):
+ async def stop_quiz(self, author: discord.Member, channel: discord.TextChannel) -> None:
+ """Stop the quiz."""
# Check if the author is the game starter or a moderator.
if (
author == self.game_owners[channel.id]