updated bot dao, removed bot file that is not needed anymore

This commit is contained in:
Jack 2021-06-08 23:54:30 +01:00
parent ed01fcac53
commit 70e66f7ef2
2 changed files with 34 additions and 38 deletions

View file

@ -1,11 +1,38 @@
const MonkeyError = require("../handlers/error");
const { mongoDB } = require("../init/mongodb");
class BotDAO {
static async addCommand(command, arguments) {
return await mongoDB()
.collection("bot-commands")
.insertOne({ command, arguments, executed: false, requestTimestamp: Date.now() });
}
async function addCommand(command, arguments) {
return await mongoDB()
.collection("bot-commands")
.insertOne({
command,
arguments,
executed: false,
requestTimestamp: Date.now(),
});
}
module.exports = BotDAO;
class BotDAO {
static async updateDiscordRole(discordId, wpm) {
return await addCommand("updateRole", [discordId, wpm]);
}
static async announceLbUpdate(discordId, pos, lb, wpm, raw, acc, con) {
return await addCommand("sayLbUpdate", [
discordId,
pos,
lb,
wpm,
raw,
acc,
con,
]);
}
// this probably will be rewritten but keeping the old code just in case
// static async announceDailyLbResult(lbdata) {
// return await addCommand("announceDailyLbResult", [lbdata]);
// }
}
module.exports = BotDAO;

View file

@ -1,31 +0,0 @@
function updateDiscordRole(discordId, wpm) {
newBotCommand = new BotCommand({
command: "updateRole",
arguments: [discordId, wpm],
executed: false,
requestTimestamp: Date.now(),
});
newBotCommand.save();
}
async function announceLbUpdate(discordId, pos, lb, wpm, raw, acc, con) {
newBotCommand = new BotCommand({
command: "sayLbUpdate",
arguments: [discordId, pos, lb, wpm, raw, acc, con],
executed: false,
requestTimestamp: Date.now(),
});
newBotCommand.save();
}
async function announceDailyLbResult(lbdata) {
newBotCommand = new BotCommand({
command: "announceDailyLbResult",
arguments: [lbdata],
executed: false,
requestTimestamp: Date.now(),
});
newBotCommand.save();
}