diff --git a/app.js b/app.js index 9b345aa..42204ac 100644 --- a/app.js +++ b/app.js @@ -5,9 +5,7 @@ if (process.version.slice(1).split(".")[0] < 10) throw new Error("Node 10.0.0 or require("dotenv").config(); // turn fs.readdir into a promise -const { promisify } = require("util"); -const fs = require("fs"); -const readdir = promisify(fs.readdir); +const readdir = require("util").promisify(require("fs").readdir); // fancy loggings const logger = require("./utils/logger.js"); // start the client @@ -15,7 +13,7 @@ const client = require("./utils/client.js"); // initialize command loader const handler = require("./utils/handler.js"); -// registers stuff and logs in the bot +// registers stuff and connects the bot async function init() { // register commands and their info const commands = await readdir("./commands/"); diff --git a/commands/restart.js b/commands/restart.js index 098e195..b1ee552 100644 --- a/commands/restart.js +++ b/commands/restart.js @@ -10,6 +10,6 @@ exports.run = async (message) => { process.exit(1); }; -exports.aliases = ["reboot"]; +exports.aliases = ["reboot", "stop"]; exports.category = 7; exports.help = "Restarts me"; \ No newline at end of file diff --git a/commands/rps.js b/commands/rps.js index 6176c4a..bea6e69 100644 --- a/commands/rps.js +++ b/commands/rps.js @@ -1,8 +1,10 @@ +const misc = require("../utils/misc.js"); + exports.run = async (message, args) => { if (args.length === 0 || (args[0] !== "rock" && args[0] !== "paper" && args[0] !== "scissors")) return `${message.author.mention}, you need to choose whether you want to be rock, paper, or scissors!`; let emoji; let winOrLose; - const result = require("../utils/misc.js").random(["rock", "paper", "scissors"]); + const result = misc.random(["rock", "paper", "scissors"]); switch (result) { case "rock": emoji = "✊"; diff --git a/utils/misc.js b/utils/misc.js index 09a1042..0d3ab85 100644 --- a/utils/misc.js +++ b/utils/misc.js @@ -1,3 +1,6 @@ +const util = require("util"); +const client = require("./client.js"); + // random(array) to select a random entry in array exports.random = (array) => { return array[Math.floor(Math.random() * array.length)]; @@ -8,7 +11,7 @@ exports.clean = async (text) => { if (text && text.constructor.name == "Promise") text = await text; if (typeof text !== "string") - text = require("util").inspect(text, { depth: 1 }); + text = util.inspect(text, { depth: 1 }); text = text .replace(/`/g, `\`${String.fromCharCode(8203)}`) @@ -51,7 +54,7 @@ exports.getTweet = async (tweets, reply = false, isDownload = false) => { }; exports.getRandomMessage = async () => { - const messages = await require("./client.js").guilds.get("631290275456745502").channels.get("631290275888627713").getMessages(50); + const messages = await client.guilds.get("631290275456745502").channels.get("631290275888627713").getMessages(50); const randomMessage = this.random(messages); if (randomMessage.content.length > 144) return await this.getRandomMessage(); if (randomMessage.content.match(/<@!?\d+>/g)) return await this.getRandomMessage(); diff --git a/utils/twitter.js b/utils/twitter.js index 71bab87..e932a24 100644 --- a/utils/twitter.js +++ b/utils/twitter.js @@ -1,4 +1,5 @@ const Twit = require("twit"); +const database = require("../utils/database.js"); const T = new Twit({ consumer_key: process.env.TWITTER_KEY, consumer_secret: process.env.CONSUMER_SECRET, @@ -7,7 +8,7 @@ const T = new Twit({ }); exports.client = T; exports.active = false; -require("../utils/database.js").tweets.find({ enabled: true }, (error, docs) => { +database.tweets.find({ enabled: true }, (error, docs) => { if (error) throw error; exports.tweets = docs[0]; }); \ No newline at end of file