mirror of
https://github.com/monkeytypegame/monkeytype.git
synced 2024-11-10 17:04:49 +08:00
updated bot dao, removed bot file that is not needed anymore
This commit is contained in:
parent
ed01fcac53
commit
70e66f7ef2
2 changed files with 34 additions and 38 deletions
|
@ -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;
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
Loading…
Reference in a new issue