2021-06-07 21:15:09 +08:00
|
|
|
const MonkeyError = require("../handlers/error");
|
|
|
|
const { mongoDB } = require("../init/mongodb");
|
2021-06-09 06:54:30 +08:00
|
|
|
|
|
|
|
async function addCommand(command, arguments) {
|
2021-08-03 23:03:31 +08:00
|
|
|
return await mongoDB().collection("bot-commands").insertOne({
|
|
|
|
command,
|
|
|
|
arguments,
|
|
|
|
executed: false,
|
|
|
|
requestTimestamp: Date.now(),
|
|
|
|
});
|
2021-06-09 06:54:30 +08:00
|
|
|
}
|
|
|
|
|
2021-06-07 21:15:09 +08:00
|
|
|
class BotDAO {
|
2021-06-09 06:54:30 +08:00
|
|
|
static async updateDiscordRole(discordId, wpm) {
|
|
|
|
return await addCommand("updateRole", [discordId, wpm]);
|
2021-06-07 21:15:09 +08:00
|
|
|
}
|
2021-06-09 06:54:30 +08:00
|
|
|
|
2021-06-12 21:00:21 +08:00
|
|
|
static async linkDiscord(uid, discordId) {
|
|
|
|
return await addCommand("linkDiscord", [discordId, uid]);
|
|
|
|
}
|
|
|
|
|
2021-08-03 23:03:31 +08:00
|
|
|
// static async announceLbUpdate(discordId, pos, lb, wpm, raw, acc, con) {
|
|
|
|
// return await addCommand("sayLbUpdate", [
|
|
|
|
// discordId,
|
|
|
|
// pos,
|
|
|
|
// lb,
|
|
|
|
// wpm,
|
|
|
|
// raw,
|
|
|
|
// acc,
|
|
|
|
// con,
|
|
|
|
// ]);
|
|
|
|
// }
|
2021-06-09 06:54:30 +08:00
|
|
|
|
|
|
|
// this probably will be rewritten but keeping the old code just in case
|
|
|
|
// static async announceDailyLbResult(lbdata) {
|
|
|
|
// return await addCommand("announceDailyLbResult", [lbdata]);
|
|
|
|
// }
|
2021-06-07 21:15:09 +08:00
|
|
|
}
|
|
|
|
|
2021-06-09 06:54:30 +08:00
|
|
|
module.exports = BotDAO;
|