Add a reset vote command
This commit is contained in:
parent
f95063274f
commit
cda0544c0a
1 changed files with 26 additions and 0 deletions
26
src/commands/reset.ts
Normal file
26
src/commands/reset.ts
Normal file
|
|
@ -0,0 +1,26 @@
|
||||||
|
import { user_answers, commands, question_index, questions } from "../main";
|
||||||
|
|
||||||
|
|
||||||
|
function reset_command(args: string[]) {
|
||||||
|
|
||||||
|
if (question_index < 0) {
|
||||||
|
return `Cannot reset a user's answer for a question when the quiz hasn't begun`;
|
||||||
|
};
|
||||||
|
|
||||||
|
if (questions[question_index].can_change) {
|
||||||
|
return `${args[0]} can change their own answer by answering again.`;
|
||||||
|
};
|
||||||
|
|
||||||
|
if (args.length == 0) {
|
||||||
|
return `Missing argument: User`;
|
||||||
|
};
|
||||||
|
|
||||||
|
let user = args[0].startsWith("@") ? args[0].slice(1) : args[0];
|
||||||
|
|
||||||
|
delete user_answers[user];
|
||||||
|
|
||||||
|
return `The answer for @${user} has been removed`;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
commands["!reset"] = reset_command;
|
||||||
Loading…
Add table
Add a link
Reference in a new issue