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 { config } from "../main";
|
||||
import {
|
||||
change_index,
|
||||
commands,
|
||||
|
|
@ -36,22 +37,23 @@ function next_command(_: string[]) {
|
|||
|
||||
reset_users();
|
||||
|
||||
if (config.discord.webhook.enabled) {
|
||||
axios.post(
|
||||
`https://ptb.discord.com/api/webhooks/916068083863539782/9k2b66SUIeY8hl5id7gdnZF6Abc8Fb1f5-RVlgbUJqirNmALkrrgrCWdsufcZ5Bn2a4i`,
|
||||
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`,
|
||||
config.discord.webhook.url,
|
||||
{
|
||||
content: `\`\`\`json\n${JSON.stringify(user_right_count, null, "\t")}\`\`\``
|
||||
}
|
||||
|
|
@ -60,6 +62,7 @@ ${correct_users.join(", ")}
|
|||
change_index(-1);
|
||||
return `${users_correct} players got the last question right. Quiz has ended. Kthxbai.`;
|
||||
};
|
||||
};
|
||||
|
||||
change_index(question_index + 1);
|
||||
return `${users_correct} players got that question right. Changed to the next question!`;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue