diff --git a/src/commands/next.ts b/src/commands/next.ts index db9e96a..6ca7b72 100644 --- a/src/commands/next.ts +++ b/src/commands/next.ts @@ -1,4 +1,5 @@ import axios from "axios"; +import { config } from "../main"; import { change_index, commands, @@ -36,29 +37,31 @@ function next_command(_: string[]) { reset_users(); - axios.post( - `https://ptb.discord.com/api/webhooks/916068083863539782/9k2b66SUIeY8hl5id7gdnZF6Abc8Fb1f5-RVlgbUJqirNmALkrrgrCWdsufcZ5Bn2a4i`, + if (config.discord.webhook.enabled) { + axios.post( + config.discord.webhook.url, { content: correct_users.length > 0 ? `Users who got question ${question_index + 1} right: \`\`\` ${correct_users.join(", ")} \`\`\`` : `No one got question ${question_index + 1} right.` } - ) - - // Check if the quiz has hit the end - if (question_index == questions.length - 1) { - - // Send message in Discord for record-keeping - axios.post( - `https://ptb.discord.com/api/webhooks/916068083863539782/9k2b66SUIeY8hl5id7gdnZF6Abc8Fb1f5-RVlgbUJqirNmALkrrgrCWdsufcZ5Bn2a4i`, - { - content: `\`\`\`json\n${JSON.stringify(user_right_count, null, "\t")}\`\`\`` - } ); - change_index(-1); - return `${users_correct} players got the last question right. Quiz has ended. Kthxbai.`; + // Check if the quiz has hit the end + if (question_index == questions.length - 1) { + + // Send message in Discord for record-keeping + axios.post( + config.discord.webhook.url, + { + content: `\`\`\`json\n${JSON.stringify(user_right_count, null, "\t")}\`\`\`` + } + ); + + change_index(-1); + return `${users_correct} players got the last question right. Quiz has ended. Kthxbai.`; + }; }; change_index(question_index + 1);