Fixed some issues
This commit is contained in:
@@ -62,6 +62,14 @@ class PlayerLink(commands.Cog):
|
||||
|
||||
channelid = ctx.channel.id
|
||||
authorid = ctx.author.id
|
||||
|
||||
dbLinker = PlayerDBLinker()
|
||||
if dbLinker.discordidused(authorid):
|
||||
await ctx.send(f"{ctx.author.mention}, your account is already linked!")
|
||||
dbLinker.close()
|
||||
return
|
||||
|
||||
|
||||
code = get_random_string(8)
|
||||
|
||||
|
||||
|
||||
77
cogs/quiz.py
77
cogs/quiz.py
@@ -12,43 +12,38 @@ class QuizQuestions(commands.Cog):
|
||||
def __init__(self, client):
|
||||
self.client = client
|
||||
|
||||
@commands.group(name="q&a",case_insensitive=True, invoke_without_command=True)
|
||||
@commands.group(name="questions",case_insensitive=True, invoke_without_command=True)
|
||||
@commands.check(checks.isModPlus)
|
||||
# /q&a add "What is ...." "Australia"
|
||||
async def questions(self, ctx, f, *args):
|
||||
if (f == "add"):
|
||||
if (len(args) == 2):
|
||||
await self.add_question(ctx, args[0], args[1])
|
||||
elif (len(args) == 3):
|
||||
await self.add_question(ctx, args[0], args[1], args[2])
|
||||
else:
|
||||
await ctx.send("Wrong amount of arguments")
|
||||
elif (f == "rm"):
|
||||
if (len(args) == 1):
|
||||
await self.rm_question(ctx, args[0])
|
||||
else:
|
||||
await ctx.send("Wrong amount of arguments")
|
||||
elif (f == "show"):
|
||||
if (len(args) == 0):
|
||||
await self.show_questions(ctx)
|
||||
else:
|
||||
await ctx.send("Wrong amount of arguments")
|
||||
async def questions(self, ctx, *args):
|
||||
pass
|
||||
|
||||
@questions.command(name="add")
|
||||
@commands.check(checks.isModPlus)
|
||||
async def add_question(self, ctx, q, a, reward=50):
|
||||
try:
|
||||
quizdb = QuizDB()
|
||||
q_id = quizdb.add_question(q, a, reward)
|
||||
await ctx.send("question id: " + str(q_id))
|
||||
embed = discord.Embed()
|
||||
embed.colour = discord.Colour.green()
|
||||
embed.add_field(name="Success", value=f"Added question with {q_id}", inline=False)
|
||||
await ctx.send(embed=embed)
|
||||
except:
|
||||
await ctx.send("Something went wrong")
|
||||
finally:
|
||||
quizdb.close()
|
||||
|
||||
|
||||
@questions.command(name="rm")
|
||||
@commands.check(checks.isModPlus)
|
||||
async def rm_question(self, ctx, id):
|
||||
try:
|
||||
quizdb = QuizDB()
|
||||
quizdb.rm_question(id)
|
||||
await ctx.send("question removed")
|
||||
embed = discord.Embed()
|
||||
embed.colour = discord.Colour.green()
|
||||
embed.add_field(name="Success", value=f"Question removed with id {id}", inline=False)
|
||||
await ctx.send(embed=embed)
|
||||
except QuestionNotFound:
|
||||
await ctx.send("No question found with id " + str(id))
|
||||
# except:
|
||||
@@ -56,17 +51,25 @@ class QuizQuestions(commands.Cog):
|
||||
finally:
|
||||
quizdb.close()
|
||||
|
||||
@questions.command(name="show")
|
||||
@commands.check(checks.isModPlus)
|
||||
async def show_questions(self, ctx):
|
||||
try:
|
||||
quizdb = QuizDB()
|
||||
questions = quizdb.get_questions()
|
||||
if len(questions) == 0:
|
||||
await ctx.send("No questions found")
|
||||
embed = discord.Embed()
|
||||
embed.colour = discord.Colour.red()
|
||||
embed.add_field(name="Questions", value=f"No questions found", inline=False)
|
||||
|
||||
await ctx.send(embed=embed)
|
||||
else:
|
||||
message = ""
|
||||
embed = discord.Embed()
|
||||
embed.set_author(name="Questions")
|
||||
embed.colour = discord.Colour.orange()
|
||||
for q in questions:
|
||||
message += f"id: {q[0]}, question: '{q[1]}', answer: '{q[2]}', reward: {q[3]}, used: {q[4]}\n"
|
||||
await ctx.send(message)
|
||||
embed.add_field(name=f"id: {q[0]}", value=f"Question: '{q[1]}'\nAnswer: '{q[2]}'\nReward: {q[3]}\nUsed: {q[4]}", inline=False)
|
||||
await ctx.send(embed=embed)
|
||||
except:
|
||||
await ctx.send("Something went wrong")
|
||||
finally:
|
||||
@@ -105,43 +108,41 @@ class Quiz(commands.Cog):
|
||||
self.increment_asked_count(question[0])
|
||||
|
||||
channel = self.client.get_channel(constants.QuizChannelID)
|
||||
answer_timer = Timer(1, 0)
|
||||
|
||||
embed = discord.Embed()
|
||||
#embed.set_author(name="Quiz")
|
||||
embed.colour = discord.Colour.orange()
|
||||
|
||||
embed.add_field(name="Question:", value=f"{question[1]}", inline=False)
|
||||
embed.add_field(name="Reward:", value=f"${question[3]}", inline=False)
|
||||
embed.add_field(name="Reward:", value=f"${question[3]} in game", inline=False)
|
||||
|
||||
await channel.send(embed=embed)
|
||||
message = await self.client.wait_for("message", check=lambda message: message.content.lower() == question[2].lower())
|
||||
|
||||
embed.add_field(name="Answer:", value=f"{question[2]}", inline=False)
|
||||
|
||||
if (message):
|
||||
self.give_reward(message.author.id, question[3])
|
||||
try:
|
||||
message = await self.client.wait_for("message", check=lambda message: message.content.lower() == question[2].lower(), timeout=60*10)
|
||||
|
||||
self.give_reward(message.author.id, question[3])
|
||||
playerdblinker = PlayerDBLinker()
|
||||
embed.colour = discord.Colour.green()
|
||||
if playerdblinker.discordidused(message.author.id):
|
||||
embed.add_field(name="Winner:", value=f"{message.author.mention} 🎉🎉", inline=False)
|
||||
#self.embed.add_field(name="Claim:", value=f"Claim your reward in Minecraft by using /redeem")
|
||||
embed.add_field(name="Claim:", value=f"Claim your reward in Minecraft when the server is online")
|
||||
embed.add_field(name="Claim:", value=f"Claim your reward in Minecraft by using /redeem")
|
||||
#embed.add_field(name="Claim:", value=f"Claim your reward in Minecraft when the server is online")
|
||||
await message.channel.send(embed=embed)
|
||||
else:
|
||||
|
||||
embed.add_field(name="Winner:", value=f"{message.author.mention} 🎉🎉", inline=False)
|
||||
#self.embed.add_field(name="Claim:", value=f"1. Link your account by using /link <MinecraftName> \n2. Claim your reward in Minecraft by using /redeem")
|
||||
embed.add_field(name="Claim:", value=f"Claim your reward in Minecraft when the server is online")
|
||||
embed.add_field(name="Claim:", value=f"1. Link your account by using /link <MinecraftName> \n2. Claim your reward in Minecraft by using /redeem")
|
||||
#embed.add_field(name="Claim:", value=f"Claim your reward in Minecraft when the server is online")
|
||||
await message.channel.send(embed=embed)
|
||||
playerdblinker.close()
|
||||
else:
|
||||
except asyncio.TimeoutError:
|
||||
await channel.send("Nobody found the correct answer!")
|
||||
embed.colour = discord.Colour.red()
|
||||
embed.add_field(name="Answer:", value=f"{question[2]}", inline=False)
|
||||
await channel.send(embed=embed)
|
||||
|
||||
|
||||
|
||||
def increment_asked_count(self, q_id):
|
||||
quizdb = QuizDB()
|
||||
quizdb.question_asked_increment(q_id)
|
||||
|
||||
@@ -20,4 +20,5 @@ modPlusRoles = [roleAdmin, roleMod, roleOwner]
|
||||
|
||||
# Channels
|
||||
ModLogs = 760807882899193867
|
||||
#QuizChannelID_dev = 774418250665951232
|
||||
QuizChannelID = 774418250665951232
|
||||
|
||||
Reference in New Issue
Block a user