Untitled
unknown
plain_text
2 years ago
1.3 kB
17
Indexable
validation_response = "You gave wrong answer. No more attempts left"
attempts = 3
question = (
"{extra}What is Slash Commands? Give answer in 10 seconds. Remaining attempts: {attempts}"
"\nA. Bot\nB. Human"
)
respond_interaction(
interaction,
content=question.format(
attempts=attempts,
extra=""
)
)
def is_correct(answer):
return answer in ["Bot", "bot"]
async def check_response(*args):
global validation_response, attempts
def check(event):
return event.author_id == user.id and event.channel_id == channel.id
event = await wait_for("message", timeout=10, check=check)
if not event:
validation_response = "You have been timed out"
break_loop()
attempts -= 1
correct = is_correct(event.message.content)
if correct:
validation_response = "You gave correct answer"
delete_message(event.channel_id, event.message.id)
break_loop()
else:
delete_message(event.channel_id, event.message.id)
respond_interaction(
interaction,
content=question.format(
attempts=attempts,
extra="❌ Wrong answer. "
)
)
loop(3, check_response)Editor is loading...
Leave a Comment