Changed some requires

This commit is contained in:
TheEssem 2020-02-19 16:46:50 -06:00
parent dd699b459e
commit a7746cc865
5 changed files with 13 additions and 9 deletions

6
app.js
View File

@ -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/");

View File

@ -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";

View File

@ -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 = "✊";

View File

@ -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();

View File

@ -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];
});