Make the webhook settings be respected by the code
This commit is contained in:
parent
4a21672a83
commit
7057c6aab9
1 changed files with 18 additions and 15 deletions
|
|
@ -1,4 +1,5 @@
|
||||||
import axios from "axios";
|
import axios from "axios";
|
||||||
|
import { config } from "../main";
|
||||||
import {
|
import {
|
||||||
change_index,
|
change_index,
|
||||||
commands,
|
commands,
|
||||||
|
|
@ -36,29 +37,31 @@ function next_command(_: string[]) {
|
||||||
|
|
||||||
reset_users();
|
reset_users();
|
||||||
|
|
||||||
axios.post(
|
if (config.discord.webhook.enabled) {
|
||||||
`https://ptb.discord.com/api/webhooks/916068083863539782/9k2b66SUIeY8hl5id7gdnZF6Abc8Fb1f5-RVlgbUJqirNmALkrrgrCWdsufcZ5Bn2a4i`,
|
axios.post(
|
||||||
|
config.discord.webhook.url,
|
||||||
{
|
{
|
||||||
content: correct_users.length > 0 ? `Users who got question ${question_index + 1} right:
|
content: correct_users.length > 0 ? `Users who got question ${question_index + 1} right:
|
||||||
\`\`\`
|
\`\`\`
|
||||||
${correct_users.join(", ")}
|
${correct_users.join(", ")}
|
||||||
\`\`\`` : `No one got question ${question_index + 1} right.`
|
\`\`\`` : `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);
|
// Check if the quiz has hit the end
|
||||||
return `${users_correct} players got the last question right. Quiz has ended. Kthxbai.`;
|
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);
|
change_index(question_index + 1);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue