From a3c801fd1af15d5372ebe9efad422fdcecc9efa3 Mon Sep 17 00:00:00 2001 From: Abheek Dhawan Date: Sun, 2 May 2021 04:07:24 +0000 Subject: [PATCH] Convert to CommonJS to easier reference JSON files --- .gitignore | 2 +- bot/{awesomescibo.mjs => awesomescibo.js} | 19 +++++++++---------- 2 files changed, 10 insertions(+), 11 deletions(-) rename bot/{awesomescibo.mjs => awesomescibo.js} (98%) diff --git a/.gitignore b/.gitignore index 7c3dd2f..fb11a82 100644 --- a/.gitignore +++ b/.gitignore @@ -8,5 +8,5 @@ bot/README.md .eslintrc .json .env -userScore/* +userScore config.json diff --git a/bot/awesomescibo.mjs b/bot/awesomescibo.js similarity index 98% rename from bot/awesomescibo.mjs rename to bot/awesomescibo.js index 8b310f1..32d16d0 100755 --- a/bot/awesomescibo.mjs +++ b/bot/awesomescibo.js @@ -1,17 +1,16 @@ #!/usr/bin/env node -import * as Discord from "discord.js"; -import { execSync } from "child_process"; +const Discord = require("discord.js"); +const execSync = require("child_process").execSync; const client = new Discord.Client({ partials: ["MESSAGE", "CHANNEL", "REACTION"], }); -import fetch from "node-fetch"; -import * as fs from "fs"; -import axios from "axios"; -import userScore from "./mongooseModels/mongooseUserScoreModel.js"; -import {} from "dotenv/config.js"; -import mongoose from "mongoose"; -import config from ('./config.json') +const fetch = require("node-fetch"); +const fs = require("fs"); +const axios = require("axios"); +const userScore = require("./mongooseModels/mongooseUserScoreModel.js"); +const mongoose = require("mongoose"); +const config = require("./config.json"); const helpMessage = "`do be helping`: display this help message\n`do be roundgen`: send a pdf round to the channel\n`do be roundgen dm`: dm a pdf round to you\n`do be scoring`: start a scoring session\n > `do be scoring (a/b)(4/10)`: add points to Team A or Team B\n > `do be scoring stop`: end scoring session and post final points\n > `do be servers`: send the number of servers this bot is a part of\n > `do be iss`: show the current location of the International Space Station\n`do be training`: send a quick practice problem (you **must** react to your answer, or the bot will yell at you)\n > subject options: astro, phys, chem, math, bio, ess, energy\n`do be top`: list cross-server top 10 players\n `do be about`: List people who contributed to this bot\n Source Code: https://github.com/ADawesomeguy/AwesomeSciBo (don't forget to star!)"; @@ -513,7 +512,7 @@ client.on("message", async (message) => { return; } - const formattedMessage = message.content.toLowerCase().replace(" ", ""); + const formattedMessage = message.content.toLowerCase().replace(/ /g, ""); if (formattedMessage.startsWith("dobe")) { // Bot prefix is "do be" switch (formattedMessage) {