diff --git a/commands/eval.js b/commands/eval.js index 0a9f1e9..9d1751b 100644 --- a/commands/eval.js +++ b/commands/eval.js @@ -1,7 +1,7 @@ const { clean } = require("../utils/misc.js"); exports.run = async (message, args) => { - if (message.author.id !== "198198681982205953") return `${message.author.mention}, only the bot owner can use eval!`; + if (message.author.id !== process.env.OWNER) return `${message.author.mention}, only the bot owner can use eval!`; const code = args.join(" "); try { const evaled = eval(code); diff --git a/commands/exec.js b/commands/exec.js index d380799..2f16df8 100644 --- a/commands/exec.js +++ b/commands/exec.js @@ -3,7 +3,7 @@ const util = require("util"); const exec = util.promisify(require("child_process").exec); exports.run = async (message, args) => { - if (message.author.id !== "198198681982205953") return `${message.author.mention}, only the bot owner can use exec!`; + if (message.author.id !== process.env.OWNER) return `${message.author.mention}, only the bot owner can use exec!`; const code = args.join(" "); try { const execed = await exec(code); diff --git a/commands/prefix.js b/commands/prefix.js index 14af3f9..1afa4f1 100644 --- a/commands/prefix.js +++ b/commands/prefix.js @@ -3,7 +3,7 @@ const database = require("../utils/database.js"); exports.run = async (message, args) => { const guild = (await database.guilds.find({ id: message.channel.guild.id }).exec())[0]; if (args.length !== 0) { - if (!message.member.permission.has("administrator") && message.member.id !== "198198681982205953") return `${message.author.mention}, you need to be an administrator to change the bot prefix!`; + if (!message.member.permission.has("administrator") && message.member.id !== process.env.OWNER) return `${message.author.mention}, you need to be an administrator to change the bot prefix!`; guild.set("prefix", args[0]); await guild.save(); return `The prefix has been changed to ${args[0]}.`; diff --git a/commands/spin.js b/commands/spin.js new file mode 100644 index 0000000..65354be --- /dev/null +++ b/commands/spin.js @@ -0,0 +1,21 @@ +const gm = require("gm").subClass({ + imageMagick: true +}); +const gmToBuffer = require("../utils/gmbuffer.js"); + +exports.run = async (message) => { + const image = await require("../utils/imagedetect.js")(message); + if (image === undefined) return `${message.author.mention}, you need to provide an image to spin!`; + const processMessage = await message.channel.createMessage(" Processing... This might take a while"); + const command = gm(image.data).out("-duplicate", "29").scale("256x256>").scale("256x256<").out("-alpha", "on").background("transparent").virtualPixel("background").out("-distort", "SRT", "'%[fx:360*t/n]'").set("delay", "5").set("dispose", "Background").out("-loop", "0"); + const resultBuffer = await gmToBuffer(command, "gif"); + // xc:none -fill white -draw circle 128,128 128,0 + // .out("-layers", "composite") + await processMessage.delete(); + return message.channel.createMessage("", { + file: resultBuffer, + name: "spin.gif" + }); +}; + +exports.aliases = ["rotate"]; \ No newline at end of file diff --git a/commands/stats.js b/commands/stats.js index ba431fb..687edaa 100644 --- a/commands/stats.js +++ b/commands/stats.js @@ -37,4 +37,6 @@ exports.run = async (message) => { } }; return message.channel.createMessage(embed); -}; \ No newline at end of file +}; + +exports.aliases = ["status", "stat"]; \ No newline at end of file diff --git a/commands/tweet.js b/commands/tweet.js new file mode 100644 index 0000000..4682f62 --- /dev/null +++ b/commands/tweet.js @@ -0,0 +1,9 @@ +const twitter = require("../utils/twitter.js"); + +exports.run = async (message, args) => { + if (message.author.id !== process.env.OWNER) return `${message.author.mention}, only the bot owner can tweet!`; + if (args.length === 0) return `${message.author.mention}, you need to provide some text to tweet!`; + const info = await twitter.client.post("statuses/update", { status: args.join(" ") }); + if (info.resp.statusCode !== 200) return `Something happened when trying to post this tweet: ${info.resp.statusCode} ${info.resp.statusMessage}`; + return `${message.author.mention}, a tweet with id ${info.data.id_str} has been posted with status code ${info.resp.statusCode} ${info.resp.statusMessage}.`; +}; \ No newline at end of file diff --git a/commands/userinfo.js b/commands/userinfo.js index c4f2f3b..300243d 100644 --- a/commands/userinfo.js +++ b/commands/userinfo.js @@ -38,7 +38,7 @@ exports.run = async (message, args) => { }, { "name": "🎮 **Playing:**", - "value": member.activities ? member.activities[0].name : "Nothing" + "value": member.game ? member.game.name : "Nothing" } ] } diff --git a/events/messageCreate.js b/events/messageCreate.js index 7eaa0ec..e2438ef 100644 --- a/events/messageCreate.js +++ b/events/messageCreate.js @@ -75,9 +75,9 @@ module.exports = async (message) => { await client.createMessage(generalChannel.id, message.content); } } - const odyMessages = ["Nope!", "No jojo gif here", "sorry ody, this gif is illegal", "get owned"]; // || (message.attachments && message.attachments[0].filename === "1561668913236-3.gif") if (message.channel.guild.id === "322114245632327703" && (message.content.match(/https?:\/\/(media|cdn)\.discordapp\.(net|com)\/attachments\/596766080014221373\/606176845871972383\/1561668913236-3.gif/))) { + const odyMessages = ["Nope!", "No jojo gif here", "sorry ody, this gif is illegal", "get owned"]; await message.delete("anti-jojo mechanism"); await client.createMessage(message.channel.id, misc.random(odyMessages)); } diff --git a/events/ready.js b/events/ready.js index 4087d87..32dc707 100644 --- a/events/ready.js +++ b/events/ready.js @@ -3,6 +3,7 @@ const database = require("../utils/database.js"); const logger = require("../utils/logger.js"); const messages = require("../messages.json"); const misc = require("../utils/misc.js"); +const twitter = process.env.TWITTER === "true" ? require("../utils/twitter.js") : null; // run when ready module.exports = async () => { @@ -47,5 +48,29 @@ module.exports = async () => { setTimeout(activityChanger, 900000); })(); + // tweet stuff + if (twitter !== null) { + (async function tweet() { + const tweetContent = await misc.getTweet(twitter); + const info = await twitter.client.post("statuses/update", { status: tweetContent }); + logger.log(`Tweet with id ${info.data.id_str} has been tweeted with status code ${info.resp.statusCode} ${info.resp.statusMessage}`); + setTimeout(tweet, 1800000); + })(); + const stream = twitter.client.stream("statuses/filter", { + track: `@${process.env.HANDLE}` + }); + stream.on("tweet", async (tweet) => { + if (tweet.user.screen_name !== "esmBot_") { + const tweetContent = await misc.getTweet(twitter, true); + const payload = { + status: `@${tweet.user.screen_name} ${tweetContent}`, + in_reply_to_status_id: tweet.id_str + }; + const info = await twitter.client.post("statuses/update", payload); + logger.log(`Reply with id ${info.data.id_str} has been tweeted with status code ${info.resp.statusCode} ${info.resp.statusMessage}`); + } + }); + } + logger.log("info", `Successfully started ${client.user.username}#${client.user.discriminator} with ${client.users.size} users in ${client.guilds.size} servers.`); }; diff --git a/package-lock.json b/package-lock.json index 86a441b..5c504e2 100644 --- a/package-lock.json +++ b/package-lock.json @@ -25,9 +25,9 @@ } }, "@types/node": { - "version": "12.12.5", - "resolved": "https://registry.npmjs.org/@types/node/-/node-12.12.5.tgz", - "integrity": "sha512-KEjODidV4XYUlJBF3XdjSH5FWoMCtO0utnhtdLf1AgeuZLOrRbvmU/gaRCVg7ZaQDjVf3l84egiY0mRNe5xE4A==" + "version": "12.12.7", + "resolved": "https://registry.npmjs.org/@types/node/-/node-12.12.7.tgz", + "integrity": "sha512-E6Zn0rffhgd130zbCbAr/JdXfXkoOUFAKNs/rF8qnafSJ8KYaA/j3oz7dcwal+lYjLA7xvdd5J4wdYpCTlP8+w==" }, "abort-controller": { "version": "3.0.0", @@ -61,7 +61,6 @@ "version": "6.10.0", "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.10.0.tgz", "integrity": "sha512-nffhOpkymDECQyR0mnsUtoCE8RlX38G0rYP+wgLWFyZuUyuuojSSvi/+euOiQBIn63whYwYVIIH1TvE3tu4OEg==", - "dev": true, "requires": { "fast-deep-equal": "^2.0.1", "fast-json-stable-stringify": "^2.0.0", @@ -155,6 +154,19 @@ "resolved": "https://registry.npmjs.org/arrify/-/arrify-2.0.1.tgz", "integrity": "sha512-3duEwti880xqi4eAMN8AyR4a0ByT90zoYdLlevfrvU43vb0YZwZVfxOgxWrLXXXpyugL0hNZc9G6BiB5B3nUug==" }, + "asn1": { + "version": "0.2.4", + "resolved": "https://registry.npmjs.org/asn1/-/asn1-0.2.4.tgz", + "integrity": "sha512-jxwzQpLQjSmWXgwaCZE9Nz+glAG01yF1QnWgbhGwHI5A6FRIEY6IVqtHhIepHqI7/kyEyQEagBC5mBEFlIYvdg==", + "requires": { + "safer-buffer": "~2.1.0" + } + }, + "assert-plus": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/assert-plus/-/assert-plus-1.0.0.tgz", + "integrity": "sha1-8S4PPF13sLHN2RRpQuTpbB5N1SU=" + }, "astral-regex": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/astral-regex/-/astral-regex-1.0.0.tgz", @@ -179,6 +191,16 @@ "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", "integrity": "sha1-x57Zf380y48robyXkLzDZkdLS3k=" }, + "aws-sign2": { + "version": "0.7.0", + "resolved": "https://registry.npmjs.org/aws-sign2/-/aws-sign2-0.7.0.tgz", + "integrity": "sha1-tG6JCTSpWR8tL2+G1+ap8bP+dqg=" + }, + "aws4": { + "version": "1.8.0", + "resolved": "https://registry.npmjs.org/aws4/-/aws4-1.8.0.tgz", + "integrity": "sha512-ReZxvNHIOv88FlT7rxcXIIC0fPt4KZqZbOlivyWtXLt8ESx84zd3kMC6iK5jVeS2qt+g7ftS7ye4fi06X5rtRQ==" + }, "balanced-match": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz", @@ -190,6 +212,21 @@ "resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.3.1.tgz", "integrity": "sha512-mLQ4i2QO1ytvGWFWmcngKO//JXAQueZvwEKtjgQFM4jIK0kU+ytMfplL8j+n5mspOfjHwoAg+9yhb7BwAHm36g==" }, + "bcrypt-pbkdf": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/bcrypt-pbkdf/-/bcrypt-pbkdf-1.0.2.tgz", + "integrity": "sha1-pDAdOJtqQ/m2f/PKEaP2Y342Dp4=", + "requires": { + "tweetnacl": "^0.14.3" + }, + "dependencies": { + "tweetnacl": { + "version": "0.14.5", + "resolved": "https://registry.npmjs.org/tweetnacl/-/tweetnacl-0.14.5.tgz", + "integrity": "sha1-WuaBd/GS1EViadEIr6k/+HQ/T2Q=" + } + } + }, "bignumber.js": { "version": "7.2.1", "resolved": "https://registry.npmjs.org/bignumber.js/-/bignumber.js-7.2.1.tgz", @@ -262,9 +299,18 @@ } }, "bson": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/bson/-/bson-1.1.1.tgz", - "integrity": "sha512-jCGVYLoYMHDkOsbwJZBCqwMHyH4c+wzgI9hG7Z6SZJRXWr+x58pdIbm2i9a/jFGCkRJqRUr8eoI7lDWa0hTkxg==" + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/bson/-/bson-1.1.3.tgz", + "integrity": "sha512-TdiJxMVnodVS7r0BdL42y/pqC9cL2iKynVwA0Ho3qbsQYr428veL3l7BQyuqiw+Q5SqqoT0m4srSY/BlZ9AxXg==" + }, + "buffer": { + "version": "5.4.3", + "resolved": "https://registry.npmjs.org/buffer/-/buffer-5.4.3.tgz", + "integrity": "sha512-zvj65TkFeIt3i6aj5bIvJDzjjQQGs4o/sNoezg1F1kYap9Nu2jcUdpwzRSJTHMMzG0H7bZkn4rNQpImhuxWX2A==", + "requires": { + "base64-js": "^1.0.2", + "ieee754": "^1.1.4" + } }, "buffer-alloc": { "version": "1.2.0", @@ -314,6 +360,11 @@ "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-5.3.1.tgz", "integrity": "sha512-L28STB170nwWS63UjtlEOE3dldQApaJXZkOI1uMFfzf3rRuPegHaHesyee+YxQ+W6SvRDQV6UrdOdRiR153wJg==" }, + "caseless": { + "version": "0.12.0", + "resolved": "https://registry.npmjs.org/caseless/-/caseless-0.12.0.tgz", + "integrity": "sha1-G2gcIf+EAzyCZUMJBolCDRhxUdw=" + }, "chalk": { "version": "2.4.2", "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz", @@ -519,6 +570,14 @@ "resolved": "https://registry.npmjs.org/css-what/-/css-what-2.1.3.tgz", "integrity": "sha512-a+EPoD+uZiNfh+5fxw2nO9QwFa6nJe2Or35fGY6Ipw1R3R4AGz1d1TEZrCegvw2YTmZ0jXirGYlzxxpYSHwpEg==" }, + "dashdash": { + "version": "1.14.1", + "resolved": "https://registry.npmjs.org/dashdash/-/dashdash-1.14.1.tgz", + "integrity": "sha1-hTz6D3y+L+1d4gMmuN1YEDX24vA=", + "requires": { + "assert-plus": "^1.0.0" + } + }, "dblapi.js": { "version": "2.3.0", "resolved": "https://registry.npmjs.org/dblapi.js/-/dblapi.js-2.3.0.tgz", @@ -631,6 +690,15 @@ "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-8.2.0.tgz", "integrity": "sha512-8sJ78ElpbDJBHNeBzUbUVLsqKdccaa/BXF1uPTw3GrvQTBgrQrtObr2mUrE38vzYd8cEv+m/JBfDLioYcfXoaw==" }, + "ecc-jsbn": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/ecc-jsbn/-/ecc-jsbn-0.1.2.tgz", + "integrity": "sha1-OoOpBOVDUyh4dMVkt1SThoSamMk=", + "requires": { + "jsbn": "~0.1.0", + "safer-buffer": "^2.1.0" + } + }, "ecdsa-sig-formatter": { "version": "1.0.11", "resolved": "https://registry.npmjs.org/ecdsa-sig-formatter/-/ecdsa-sig-formatter-1.0.11.tgz", @@ -671,8 +739,9 @@ "integrity": "sha512-zoB603vQReOFvTg5xMl9I1P2PnHsHQQKTEowsKKD7nseUfJq6UWzK+4YtlWUO1nhiQUxe6XMkk+JleSZD1NZFA==" }, "eris": { - "version": "github:abalabahaha/eris#152784360098beb27c1847bff1807615fa2cc185", - "from": "github:abalabahaha/eris#dev", + "version": "0.11.0", + "resolved": "https://registry.npmjs.org/eris/-/eris-0.11.0.tgz", + "integrity": "sha512-fPLQj1BuOb4b5jQFAhoxLMjkmgFq53o9H8Q78dFXIUBVX9k2AbKO93MzstMfZi4UqaSI2Oz52RaM9kAsr7eJNg==", "requires": { "opusscript": "^0.0.4", "tweetnacl": "^1.0.0", @@ -901,17 +970,20 @@ } } }, + "extsprintf": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/extsprintf/-/extsprintf-1.3.0.tgz", + "integrity": "sha1-lpGEQOMEGnpBT4xS48V06zw+HgU=" + }, "fast-deep-equal": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-2.0.1.tgz", - "integrity": "sha1-ewUhjd+WZ79/Nwv3/bLLFf3Qqkk=", - "dev": true + "integrity": "sha1-ewUhjd+WZ79/Nwv3/bLLFf3Qqkk=" }, "fast-json-stable-stringify": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.0.0.tgz", - "integrity": "sha1-1RQsDK7msRifh9OnYREGT4bIu/I=", - "dev": true + "integrity": "sha1-1RQsDK7msRifh9OnYREGT4bIu/I=" }, "fast-levenshtein": { "version": "2.0.6", @@ -987,6 +1059,11 @@ "integrity": "sha512-R+H8IZclI8AAkSBRQJLVOsxwAoHd6WC40b4QTNWIjzAa6BXOBfQcM587MXDTVPeYaopFNWHUFLx7eNmHDSxMWg==", "dev": true }, + "forever-agent": { + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/forever-agent/-/forever-agent-0.6.1.tgz", + "integrity": "sha1-+8cfDEGt6zf5bFd60e1C2P2sypE=" + }, "form-data": { "version": "2.5.1", "resolved": "https://registry.npmjs.org/form-data/-/form-data-2.5.1.tgz", @@ -1113,6 +1190,14 @@ "resolved": "https://registry.npmjs.org/get-stdin/-/get-stdin-5.0.1.tgz", "integrity": "sha1-Ei4WFZHiH/TFJTAwVpPyDmOTo5g=" }, + "getpass": { + "version": "0.1.7", + "resolved": "https://registry.npmjs.org/getpass/-/getpass-0.1.7.tgz", + "integrity": "sha1-Xv+OPmhNVprkyysSgmBOi6YhSfo=", + "requires": { + "assert-plus": "^1.0.0" + } + }, "github-from-package": { "version": "0.0.0", "resolved": "https://registry.npmjs.org/github-from-package/-/github-from-package-0.0.0.tgz", @@ -1215,6 +1300,20 @@ "mime": "^2.2.0" } }, + "har-schema": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/har-schema/-/har-schema-2.0.0.tgz", + "integrity": "sha1-qUwiJOvKwEeCoNkDVSHyRzW37JI=" + }, + "har-validator": { + "version": "5.1.3", + "resolved": "https://registry.npmjs.org/har-validator/-/har-validator-5.1.3.tgz", + "integrity": "sha512-sNvOCzEQNr/qrvJgc3UG/kD4QtlHycrzwS+6mfTrrSq97BvaYcPZZI1ZSqGSPR73Cxn4LKTD4PttRwfU7jWq5g==", + "requires": { + "ajv": "^6.5.5", + "har-schema": "^2.0.0" + } + }, "has-flag": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", @@ -1239,6 +1338,16 @@ "readable-stream": "^3.1.1" } }, + "http-signature": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/http-signature/-/http-signature-1.2.0.tgz", + "integrity": "sha1-muzZJRFHcvPZW2WmCruPfBj7rOE=", + "requires": { + "assert-plus": "^1.0.0", + "jsprim": "^1.2.2", + "sshpk": "^1.7.0" + } + }, "https-proxy-agent": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-3.0.1.tgz", @@ -1257,6 +1366,11 @@ "safer-buffer": ">= 2.1.2 < 3" } }, + "ieee754": { + "version": "1.1.13", + "resolved": "https://registry.npmjs.org/ieee754/-/ieee754-1.1.13.tgz", + "integrity": "sha512-4vf7I2LYV/HaWerSo3XmlMkp5eZ83i+/CDluXi/IGTs/O1sejBNhTtnxzmRZfvOUqj7lZjqHkeTvpgSFDlWZTg==" + }, "ignore": { "version": "4.0.6", "resolved": "https://registry.npmjs.org/ignore/-/ignore-4.0.6.tgz", @@ -1358,6 +1472,11 @@ "resolved": "https://registry.npmjs.org/is-stream/-/is-stream-1.1.0.tgz", "integrity": "sha1-EtSj3U5o4Lec6428hBc66A2RykQ=" }, + "is-typedarray": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-typedarray/-/is-typedarray-1.0.0.tgz", + "integrity": "sha1-5HnICFjfDBsR3dppQPlgEfzaSpo=" + }, "isarray": { "version": "2.0.5", "resolved": "https://registry.npmjs.org/isarray/-/isarray-2.0.5.tgz", @@ -1368,6 +1487,11 @@ "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", "integrity": "sha1-6PvzdNxVb/iUehDcsFctYz8s+hA=" }, + "isstream": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/isstream/-/isstream-0.1.2.tgz", + "integrity": "sha1-R+Y/evVa+m+S4VAOaQ64uFKcCZo=" + }, "js-tokens": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz", @@ -1384,6 +1508,11 @@ "esprima": "^4.0.0" } }, + "jsbn": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/jsbn/-/jsbn-0.1.1.tgz", + "integrity": "sha1-peZUwuWi3rXyAdls77yoDA7y9RM=" + }, "json-bigint": { "version": "0.3.0", "resolved": "https://registry.npmjs.org/json-bigint/-/json-bigint-0.3.0.tgz", @@ -1392,11 +1521,15 @@ "bignumber.js": "^7.0.0" } }, + "json-schema": { + "version": "0.2.3", + "resolved": "https://registry.npmjs.org/json-schema/-/json-schema-0.2.3.tgz", + "integrity": "sha1-tIDIkuWaLwWVTOcnvT8qTogvnhM=" + }, "json-schema-traverse": { "version": "0.4.1", "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz", - "integrity": "sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==", - "dev": true + "integrity": "sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==" }, "json-stable-stringify-without-jsonify": { "version": "1.0.1", @@ -1404,6 +1537,22 @@ "integrity": "sha1-nbe1lJatPzz+8wp1FC0tkwrXJlE=", "dev": true }, + "json-stringify-safe": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz", + "integrity": "sha1-Epai1Y/UXxmg9s4B1lcB4sc1tus=" + }, + "jsprim": { + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/jsprim/-/jsprim-1.4.1.tgz", + "integrity": "sha1-MT5mvB5cwG5Di8G3SZwuXFastqI=", + "requires": { + "assert-plus": "1.0.0", + "extsprintf": "1.3.0", + "json-schema": "0.2.3", + "verror": "1.10.0" + } + }, "jsqr": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/jsqr/-/jsqr-1.2.0.tgz", @@ -1505,16 +1654,16 @@ "integrity": "sha512-LRxmNwziLPT828z+4YkNzloCFC2YM4wrB99k+AV5ZbEyfGNWfG8SO1FUXLmLDBSo89NrJZ4DIWeLjy1CHGhMGA==" }, "mime-db": { - "version": "1.40.0", - "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.40.0.tgz", - "integrity": "sha512-jYdeOMPy9vnxEqFRRo6ZvTZ8d9oPb+k18PKoYNYUe2stVEBPPwsln/qWzdbmaIvnhZ9v2P+CuecK+fpUfsV2mA==" + "version": "1.42.0", + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.42.0.tgz", + "integrity": "sha512-UbfJCR4UAVRNgMpfImz05smAXK7+c+ZntjaA26ANtkXLlOe947Aag5zdIcKQULAiF9Cq4WxBi9jUs5zkA84bYQ==" }, "mime-types": { - "version": "2.1.24", - "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.24.tgz", - "integrity": "sha512-WaFHS3MCl5fapm3oLxU4eYDw77IQM2ACcxQ9RIxfaC3ooc6PFuBMGZZsYpvoXS5D5QTWPieo1jjLdAm3TBP3cQ==", + "version": "2.1.25", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.25.tgz", + "integrity": "sha512-5KhStqB5xpTAeGqKBAMgwaYMnQik7teQN4IAzC7npDv6kzeU6prfkR67bc87J1kWMPGkoaZSq1npmexMgkmEVg==", "requires": { - "mime-db": "1.40.0" + "mime-db": "1.42.0" } }, "mimic-response": { @@ -1583,9 +1732,9 @@ } }, "mongoose": { - "version": "5.7.7", - "resolved": "https://registry.npmjs.org/mongoose/-/mongoose-5.7.7.tgz", - "integrity": "sha512-FU59waB4LKBa9KOnqBUcCcMIVRc09TFo1F8nMxrzSiIWATaJpjxxSSH5FBVUDxQfNdJLfg9uFHxaTxhhwjsZOQ==", + "version": "5.7.10", + "resolved": "https://registry.npmjs.org/mongoose/-/mongoose-5.7.10.tgz", + "integrity": "sha512-KpQosHPXmlNJKZbiP19mtmC0icaziRlB+xZ14R8q7jY7+OgbbynLD9VWSFb1CyzJX5ebdkVSGmay9HXn341hTA==", "requires": { "bson": "~1.1.1", "kareem": "2.3.1", @@ -1752,6 +1901,11 @@ "resolved": "https://registry.npmjs.org/number-is-nan/-/number-is-nan-1.0.1.tgz", "integrity": "sha1-CXtgK1NCKlIsGvuHkDGDNpQaAR0=" }, + "oauth-sign": { + "version": "0.9.0", + "resolved": "https://registry.npmjs.org/oauth-sign/-/oauth-sign-0.9.0.tgz", + "integrity": "sha512-fexhUFFPTGV8ybAtSIGbV6gOkSv8UtRbDBnAyLQw4QPKkgNlsH2ByPGtMUqdWkos6YCRmAqViwgZrJc/mRDzZQ==" + }, "object-assign": { "version": "4.1.1", "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", @@ -1905,6 +2059,11 @@ "integrity": "sha1-QRyttXTFoUDTpLGRDUDYDMn0C0A=", "dev": true }, + "performance-now": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/performance-now/-/performance-now-2.1.0.tgz", + "integrity": "sha1-Ywn04OX6kT7BxpMHrjZLSzd8nns=" + }, "pngjs": { "version": "3.4.0", "resolved": "https://registry.npmjs.org/pngjs/-/pngjs-3.4.0.tgz", @@ -1981,17 +2140,22 @@ "resolved": "https://registry.npmjs.org/pseudomap/-/pseudomap-1.0.2.tgz", "integrity": "sha1-8FKijacOYYkX7wqKw0wa5aaChrM=" }, + "psl": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/psl/-/psl-1.4.0.tgz", + "integrity": "sha512-HZzqCGPecFLyoRj5HLfuDSKYTJkAfB5thKBIkRHtGjWwY7p1dAyveIbXIq4tO0KYfDF2tHqPUgY9SDnGm00uFw==" + }, "punycode": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.1.1.tgz", - "integrity": "sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A==", - "dev": true + "integrity": "sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A==" }, "qrcode": { - "version": "1.4.3", - "resolved": "https://registry.npmjs.org/qrcode/-/qrcode-1.4.3.tgz", - "integrity": "sha512-a2T3TwrzIW6Zbfe+h4mI9awWgLmW9OyyUQzF5ra0EAKCcXscHEKMrBPGku+jIlNh9YkwgjVOsf25HdU6+TJ2tw==", + "version": "1.4.4", + "resolved": "https://registry.npmjs.org/qrcode/-/qrcode-1.4.4.tgz", + "integrity": "sha512-oLzEC5+NKFou9P0bMj5+v6Z40evexeE29Z9cummZXZ9QXyMr3lphkURzxjXgPJC5azpxcshoDWV1xE46z+/c3Q==", "requires": { + "buffer": "^5.4.3", "buffer-alloc": "^1.2.0", "buffer-from": "^1.1.1", "dijkstrajs": "^1.0.1", @@ -2099,6 +2263,50 @@ "integrity": "sha512-lv0M6+TkDVniA3aD1Eg0DVpfU/booSu7Eev3TDO/mZKHBfVjgCGTV4t4buppESEYDtkArYFOxTJWv6S5C+iaNw==", "dev": true }, + "request": { + "version": "2.88.0", + "resolved": "https://registry.npmjs.org/request/-/request-2.88.0.tgz", + "integrity": "sha512-NAqBSrijGLZdM0WZNsInLJpkJokL72XYjUpnB0iwsRgxh7dB6COrHnTBNwN0E+lHDAJzu7kLAkDeY08z2/A0hg==", + "requires": { + "aws-sign2": "~0.7.0", + "aws4": "^1.8.0", + "caseless": "~0.12.0", + "combined-stream": "~1.0.6", + "extend": "~3.0.2", + "forever-agent": "~0.6.1", + "form-data": "~2.3.2", + "har-validator": "~5.1.0", + "http-signature": "~1.2.0", + "is-typedarray": "~1.0.0", + "isstream": "~0.1.2", + "json-stringify-safe": "~5.0.1", + "mime-types": "~2.1.19", + "oauth-sign": "~0.9.0", + "performance-now": "^2.1.0", + "qs": "~6.5.2", + "safe-buffer": "^5.1.2", + "tough-cookie": "~2.4.3", + "tunnel-agent": "^0.6.0", + "uuid": "^3.3.2" + }, + "dependencies": { + "form-data": { + "version": "2.3.3", + "resolved": "https://registry.npmjs.org/form-data/-/form-data-2.3.3.tgz", + "integrity": "sha512-1lLKB2Mu3aGP1Q/2eCOx0fNbRMe7XdwktwOruhfqqd0rIJWwN4Dh+E3hrPSlDCXnSR7UtZ1N38rVXm+6+MEhJQ==", + "requires": { + "asynckit": "^0.4.0", + "combined-stream": "^1.0.6", + "mime-types": "^2.1.12" + } + }, + "qs": { + "version": "6.5.2", + "resolved": "https://registry.npmjs.org/qs/-/qs-6.5.2.tgz", + "integrity": "sha512-N5ZAX4/LxJmF+7wN74pUD6qAh9/wnvdQcjq9TZjevvXzSUo7bfmw91saqMjzGS2xq91/odN2dW/WOl7qQHNDGA==" + } + } + }, "require-directory": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz", @@ -2185,8 +2393,7 @@ "safer-buffer": { "version": "2.1.2", "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", - "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==", - "dev": true + "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==" }, "saslprep": { "version": "1.0.3", @@ -2319,6 +2526,29 @@ "integrity": "sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw=", "dev": true }, + "sshpk": { + "version": "1.16.1", + "resolved": "https://registry.npmjs.org/sshpk/-/sshpk-1.16.1.tgz", + "integrity": "sha512-HXXqVUq7+pcKeLqqZj6mHFUMvXtOJt1uoUx09pFW6011inTMxqI8BA8PM95myrIyyKwdnzjdFjLiE6KBPVtJIg==", + "requires": { + "asn1": "~0.2.3", + "assert-plus": "^1.0.0", + "bcrypt-pbkdf": "^1.0.0", + "dashdash": "^1.12.0", + "ecc-jsbn": "~0.1.1", + "getpass": "^0.1.1", + "jsbn": "~0.1.0", + "safer-buffer": "^2.0.2", + "tweetnacl": "~0.14.0" + }, + "dependencies": { + "tweetnacl": { + "version": "0.14.5", + "resolved": "https://registry.npmjs.org/tweetnacl/-/tweetnacl-0.14.5.tgz", + "integrity": "sha1-WuaBd/GS1EViadEIr6k/+HQ/T2Q=" + } + } + }, "stack-trace": { "version": "0.0.10", "resolved": "https://registry.npmjs.org/stack-trace/-/stack-trace-0.0.10.tgz", @@ -2509,6 +2739,22 @@ "resolved": "https://registry.npmjs.org/to-buffer/-/to-buffer-1.1.1.tgz", "integrity": "sha512-lx9B5iv7msuFYE3dytT+KE5tap+rNYw+K4jVkb9R/asAb+pbBSM17jtunHplhBe6RRJdZx3Pn2Jph24O32mOVg==" }, + "tough-cookie": { + "version": "2.4.3", + "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-2.4.3.tgz", + "integrity": "sha512-Q5srk/4vDM54WJsJio3XNn6K2sCG+CQ8G5Wz6bZhRZoAe/+TxjWB/GlFAnYEbkYVlON9FMk/fE3h2RLpPXo4lQ==", + "requires": { + "psl": "^1.1.24", + "punycode": "^1.4.1" + }, + "dependencies": { + "punycode": { + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/punycode/-/punycode-1.4.1.tgz", + "integrity": "sha1-wNWmOycYgArY4esPpSachN1BhF4=" + } + } + }, "triple-beam": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/triple-beam/-/triple-beam-1.3.0.tgz", @@ -2534,6 +2780,23 @@ "integrity": "sha512-kcoMoKTPYnoeS50tzoqjPY3Uv9axeuuFAZY9M/9zFnhoVvRfxz9K29IMPD7jGmt2c8SW7i3gT9WqDl2+nV7p4A==", "optional": true }, + "twit": { + "version": "2.2.11", + "resolved": "https://registry.npmjs.org/twit/-/twit-2.2.11.tgz", + "integrity": "sha512-BkdwvZGRVoUTcEBp0zuocuqfih4LB+kEFUWkWJOVBg6pAE9Ebv9vmsYTTrfXleZGf45Bj5H3A1/O9YhF2uSYNg==", + "requires": { + "bluebird": "^3.1.5", + "mime": "^1.3.4", + "request": "^2.68.0" + }, + "dependencies": { + "mime": { + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/mime/-/mime-1.6.0.tgz", + "integrity": "sha512-x0Vn8spI+wuJ1O6S7gnbaQg8Pxh4NNHb7KSINmEWKiPE4RKOplvijn+NkmYmmRgP68mc70j2EbeTFRsrswaQeg==" + } + } + }, "type-check": { "version": "0.3.2", "resolved": "https://registry.npmjs.org/type-check/-/type-check-0.3.2.tgz", @@ -2547,7 +2810,6 @@ "version": "4.2.2", "resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.2.2.tgz", "integrity": "sha512-KY9Frmirql91X2Qgjry0Wd4Y+YTdrdZheS8TFwvkbLWf/G5KNJDCh6pKL5OZctEW4+0Baa5idK2ZQuELRwPznQ==", - "dev": true, "requires": { "punycode": "^2.1.0" } @@ -2572,6 +2834,16 @@ "resolved": "https://registry.npmjs.org/uws/-/uws-10.148.2.tgz", "integrity": "sha1-8BZSoLS7lByxi7emJI14D9AVAkU=" }, + "verror": { + "version": "1.10.0", + "resolved": "https://registry.npmjs.org/verror/-/verror-1.10.0.tgz", + "integrity": "sha1-OhBcoXBTr1XW4nDB+CiGguGNpAA=", + "requires": { + "assert-plus": "^1.0.0", + "core-util-is": "1.0.2", + "extsprintf": "^1.2.0" + } + }, "which": { "version": "1.3.1", "resolved": "https://registry.npmjs.org/which/-/which-1.3.1.tgz", diff --git a/package.json b/package.json index 18877e2..c71b519 100644 --- a/package.json +++ b/package.json @@ -20,7 +20,7 @@ "cowsay": "^1.4.0", "dblapi.js": "^2.3.0", "dotenv": "^8.2.0", - "eris": "github:abalabahaha/eris#dev", + "eris": "^0.11.0", "erlpack": "github:discordapp/erlpack", "eventemitter3": "^3.1.2", "file-type": "^10.9.0", @@ -29,12 +29,13 @@ "jsqr": "^1.2.0", "moment": "^2.24.0", "moment-duration-format": "^2.3.2", - "mongoose": "^5.7.7", + "mongoose": "^5.7.10", "node-fetch": "^2.6.0", "node-opus": "^0.3.3", - "qrcode": "^1.4.3", + "qrcode": "^1.4.4", "retrotext": "github:TheEssem/retrotext", "sharp": "^0.22.1", + "twit": "^2.2.11", "uws": "^10.148.1", "winston": "^3.2.1", "zlib-sync": "^0.1.6" diff --git a/readme.md b/readme.md index d1d6928..14c8c87 100644 --- a/readme.md +++ b/readme.md @@ -2,17 +2,17 @@ [![esmBot Support](https://discordapp.com/api/guilds/592399417676529688/embed.png)](https://discord.gg/vfFM7YT) ![GitHub license](https://img.shields.io/github/license/TheEssem/esmBot-rewrite.svg) -esmBot is an entertainment-focused Discord bot made using [Eris](https://abal.moe/Eris/) with soundboard and image manipulation commands. +esmBot is an entertainment-focused Discord bot made using [Eris](https://abal.moe/Eris/) with soundboard, utility, and image manipulation commands. ## Usage You can invite the bot to your server using this link: https://discordapp.com/oauth2/authorize?client_id=515571942418546689&scope=bot&permissions=70642766 A command list can be found [here](https://essem.space/esmBot/commands.html?dev=true). -If you want to run it locally, you should install ImageMagick and FFmpeg: +If you want to run it locally, you should install ImageMagick, FFmpeg, and MongoDB: ```shell -sudo apt-get install imagemagick ffmpeg +sudo apt-get install imagemagick ffmpeg mongodb ``` After that, you should install the rest of the dependencies using npm: @@ -21,8 +21,9 @@ After that, you should install the rest of the dependencies using npm: npm install ``` -Finally, fill in the info inside `config.json` and run `app.js`. -If you want to run this on Windows, I highly recommend using Windows Subsystem for Linux. +Finally, fill in the info inside `.env.example`, rename it to `.env`, and run `app.js`. + +If you want to run this on Windows, I highly recommend using Windows Subsystem for Linux. I personally used the [Ubuntu](https://www.microsoft.com/store/productId/9NBLGGH4MSV6) distro for testing, however other distros might work as well. ## Credits Icon by [Stellio](https://twitter.com/MeloncholySteel). diff --git a/utils/misc.js b/utils/misc.js index 69dc699..a59129c 100644 --- a/utils/misc.js +++ b/utils/misc.js @@ -19,11 +19,36 @@ exports.clean = async (text) => { .replace(process.env.GOOGLE, "") .replace(process.env.CSE, "") .replace(process.env.DBL, "") - .replace(process.env.MONGO, ""); + .replace(process.env.MONGO, "") + .replace(process.env.TWITTER_KEY, "") + .replace(process.env.CONSUMER_SECRET, "") + .replace(process.env.ACCESS_TOKEN, "") + .replace(process.env.ACCESS_SECRET, ""); return text; }; +// get random tweet to post +exports.getTweet = async (twitter, reply = false) => { + const randomTweet = this.random(reply ? twitter.tweets.replies : twitter.tweets.tweets); + if (randomTweet.match("{{message}}")) { + const randomMessage = await this.getRandomMessage(); + return randomTweet.replace("{{message}}", randomMessage); + } else { + return randomTweet.replace("{{media}}", this.random(twitter.tweets.media)) + .replace("{{games}}", this.random(twitter.tweets.games)) + .replace("{{phrases}}", this.random(twitter.tweets.phrases)); + } +}; + +exports.getRandomMessage = async () => { + const messages = await require("./client.js").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(); + return randomMessage.content; +}; + // regexEscape(string) to escape characters in a string for use in a regex exports.regexEscape = (string) => { return string.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"); // $& means the whole matched string diff --git a/utils/twitter.js b/utils/twitter.js new file mode 100644 index 0000000..1a9b287 --- /dev/null +++ b/utils/twitter.js @@ -0,0 +1,12 @@ +const Twit = require("twit"); +const tweets = require("../tweets.json"); +const T = new Twit({ + consumer_key: process.env.TWITTER_KEY, + consumer_secret: process.env.CONSUMER_SECRET, + access_token: process.env.ACCESS_TOKEN, + access_token_secret: process.env.ACCESS_SECRET +}); +module.exports = { + client: T, + tweets: tweets +}; \ No newline at end of file