Changed some requires
This commit is contained in:
parent
dd699b459e
commit
a7746cc865
5 changed files with 13 additions and 9 deletions
6
app.js
6
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();
|
require("dotenv").config();
|
||||||
|
|
||||||
// turn fs.readdir into a promise
|
// turn fs.readdir into a promise
|
||||||
const { promisify } = require("util");
|
const readdir = require("util").promisify(require("fs").readdir);
|
||||||
const fs = require("fs");
|
|
||||||
const readdir = promisify(fs.readdir);
|
|
||||||
// fancy loggings
|
// fancy loggings
|
||||||
const logger = require("./utils/logger.js");
|
const logger = require("./utils/logger.js");
|
||||||
// start the client
|
// start the client
|
||||||
|
@ -15,7 +13,7 @@ const client = require("./utils/client.js");
|
||||||
// initialize command loader
|
// initialize command loader
|
||||||
const handler = require("./utils/handler.js");
|
const handler = require("./utils/handler.js");
|
||||||
|
|
||||||
// registers stuff and logs in the bot
|
// registers stuff and connects the bot
|
||||||
async function init() {
|
async function init() {
|
||||||
// register commands and their info
|
// register commands and their info
|
||||||
const commands = await readdir("./commands/");
|
const commands = await readdir("./commands/");
|
||||||
|
|
|
@ -10,6 +10,6 @@ exports.run = async (message) => {
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
};
|
};
|
||||||
|
|
||||||
exports.aliases = ["reboot"];
|
exports.aliases = ["reboot", "stop"];
|
||||||
exports.category = 7;
|
exports.category = 7;
|
||||||
exports.help = "Restarts me";
|
exports.help = "Restarts me";
|
|
@ -1,8 +1,10 @@
|
||||||
|
const misc = require("../utils/misc.js");
|
||||||
|
|
||||||
exports.run = async (message, args) => {
|
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!`;
|
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 emoji;
|
||||||
let winOrLose;
|
let winOrLose;
|
||||||
const result = require("../utils/misc.js").random(["rock", "paper", "scissors"]);
|
const result = misc.random(["rock", "paper", "scissors"]);
|
||||||
switch (result) {
|
switch (result) {
|
||||||
case "rock":
|
case "rock":
|
||||||
emoji = "✊";
|
emoji = "✊";
|
||||||
|
|
|
@ -1,3 +1,6 @@
|
||||||
|
const util = require("util");
|
||||||
|
const client = require("./client.js");
|
||||||
|
|
||||||
// random(array) to select a random entry in array
|
// random(array) to select a random entry in array
|
||||||
exports.random = (array) => {
|
exports.random = (array) => {
|
||||||
return array[Math.floor(Math.random() * array.length)];
|
return array[Math.floor(Math.random() * array.length)];
|
||||||
|
@ -8,7 +11,7 @@ exports.clean = async (text) => {
|
||||||
if (text && text.constructor.name == "Promise")
|
if (text && text.constructor.name == "Promise")
|
||||||
text = await text;
|
text = await text;
|
||||||
if (typeof text !== "string")
|
if (typeof text !== "string")
|
||||||
text = require("util").inspect(text, { depth: 1 });
|
text = util.inspect(text, { depth: 1 });
|
||||||
|
|
||||||
text = text
|
text = text
|
||||||
.replace(/`/g, `\`${String.fromCharCode(8203)}`)
|
.replace(/`/g, `\`${String.fromCharCode(8203)}`)
|
||||||
|
@ -51,7 +54,7 @@ exports.getTweet = async (tweets, reply = false, isDownload = false) => {
|
||||||
};
|
};
|
||||||
|
|
||||||
exports.getRandomMessage = async () => {
|
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);
|
const randomMessage = this.random(messages);
|
||||||
if (randomMessage.content.length > 144) return await this.getRandomMessage();
|
if (randomMessage.content.length > 144) return await this.getRandomMessage();
|
||||||
if (randomMessage.content.match(/<@!?\d+>/g)) return await this.getRandomMessage();
|
if (randomMessage.content.match(/<@!?\d+>/g)) return await this.getRandomMessage();
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
const Twit = require("twit");
|
const Twit = require("twit");
|
||||||
|
const database = require("../utils/database.js");
|
||||||
const T = new Twit({
|
const T = new Twit({
|
||||||
consumer_key: process.env.TWITTER_KEY,
|
consumer_key: process.env.TWITTER_KEY,
|
||||||
consumer_secret: process.env.CONSUMER_SECRET,
|
consumer_secret: process.env.CONSUMER_SECRET,
|
||||||
|
@ -7,7 +8,7 @@ const T = new Twit({
|
||||||
});
|
});
|
||||||
exports.client = T;
|
exports.client = T;
|
||||||
exports.active = false;
|
exports.active = false;
|
||||||
require("../utils/database.js").tweets.find({ enabled: true }, (error, docs) => {
|
database.tweets.find({ enabled: true }, (error, docs) => {
|
||||||
if (error) throw error;
|
if (error) throw error;
|
||||||
exports.tweets = docs[0];
|
exports.tweets = docs[0];
|
||||||
});
|
});
|
Loading…
Add table
Add a link
Reference in a new issue