Started creating config file system
This commit is contained in:
14
cogs/quiz.py
14
cogs/quiz.py
@@ -1,6 +1,5 @@
|
||||
import discord
|
||||
from discord.ext import commands
|
||||
from data import constants
|
||||
import asyncio
|
||||
import threading
|
||||
import random
|
||||
@@ -143,11 +142,10 @@ class QuizQuestions(commands.Cog):
|
||||
class Quiz(commands.Cog):
|
||||
def __init__(self, client):
|
||||
self.client = client
|
||||
#self.interval = (1, 4)
|
||||
self.interval = (5*60, 20*60)
|
||||
self.auto = False
|
||||
self.timeout = 10*60
|
||||
|
||||
self.quiz_config = self.client.config["quiz"]
|
||||
self.interval = (int(self.quiz_config["interval_start"]) * 60, int(self.quiz_config["interval_end"]) * 60)
|
||||
self.timeout = int(self.quiz_config["timeout"])*60
|
||||
|
||||
@commands.group(name="quiz",case_insensitive=True, invoke_without_command=True)
|
||||
@commands.check(checks.isModPlus)
|
||||
@@ -218,7 +216,7 @@ class Quiz(commands.Cog):
|
||||
ranges = {10: 50, 25: 75, 50: 100, 75: 125, 100: 150}
|
||||
range = random.choice(list(ranges))
|
||||
random_number = random.randint(1, range)
|
||||
channel = self.client.get_channel(constants.QuizChannelID)
|
||||
channel = self.client.get_channel(self.quiz_config["channel"])
|
||||
await channel.send(embed=self.create_question_embed(f"Guess the number from 1 to {range}", ranges[range]))
|
||||
await channel.edit(slowmode_delay=1)
|
||||
try:
|
||||
@@ -238,7 +236,7 @@ class Quiz(commands.Cog):
|
||||
async def ask_question(self):
|
||||
question = self.get_random_question()
|
||||
self.increment_asked_count(question[0])
|
||||
channel = self.client.get_channel(constants.QuizChannelID)
|
||||
channel = self.client.get_channel(self.quiz_config["channel"])
|
||||
await channel.send(embed=self.create_question_embed(question[1], question[3]))
|
||||
try:
|
||||
message = await self.client.wait_for("message", check=lambda message: message.content.lower() == question[2].lower(), timeout=self.timeout)
|
||||
@@ -255,7 +253,7 @@ class Quiz(commands.Cog):
|
||||
async def start_word_game(self):
|
||||
word = self.get_random_word()
|
||||
self.increment_asked_word(int(word["id"]))
|
||||
channel = self.client.get_channel(constants.QuizChannelID)
|
||||
channel = self.client.get_channel(self.quiz_config["channel"])
|
||||
shaken_word = self.shake_word(word["word"].lower())
|
||||
await channel.send(embed=self.create_question_embed(f"Find the word from: {shaken_word}", word['reward']))
|
||||
try:
|
||||
|
||||
Reference in New Issue
Block a user