diff --git a/.gitattributes b/.gitattributes old mode 100644 new mode 100755 diff --git a/.gitignore b/.gitignore old mode 100644 new mode 100755 diff --git a/.vscode/Snippets.code-snippets b/.vscode/Snippets.code-snippets old mode 100644 new mode 100755 diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100755 index 0000000..942c739 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "editor.lineNumbers": "off" +} \ No newline at end of file diff --git a/DiscordEvents/ShortlinkMessage.js b/DiscordEvents/ShortlinkMessage.js new file mode 100755 index 0000000..67bdc29 --- /dev/null +++ b/DiscordEvents/ShortlinkMessage.js @@ -0,0 +1,21 @@ +const { log, db } = require("../utils/index"); +const { ShortLinks } = require("../utils"); +const { table } = require("quick.db"); +const Servers = new table("servers"); +const Users = new table("users"); +const Backend = new table("backend"); + +module.exports = { + name: "message", + run: async (client, Message) => { + if (Message.author.bot) return; + let Server = Servers.get(Message.guild.id); + let Enabled; + if (Server === null) { + Enabled = db.defaults.server.Shortlinks; + } else { + Enabled = Server.Shortlinks; + } + ShortLinks(Enabled, Message); + } +}; diff --git a/DiscordEvents/SourceFynnderMessage.js b/DiscordEvents/SourceFynnderMessage.js new file mode 100755 index 0000000..b7c6576 --- /dev/null +++ b/DiscordEvents/SourceFynnderMessage.js @@ -0,0 +1,21 @@ +const { log, db } = require("../utils/index"); +const { SourceFynnder } = require("../utils"); +const { table } = require("quick.db"); +const Servers = new table("servers"); +const Users = new table("users"); +const Backend = new table("backend"); + +module.exports = { + name: "message", + run: async (client, Message) => { + if (Message.author.bot) return; + let Server = Servers.get(Message.guild.id); + let Enabled; + if (Server === null) { + Enabled = db.defaults.server.SourceFynnder; + } else { + Enabled = Server.SourceFynnder; + } + SourceFynnder(Enabled, Message); + } +}; diff --git a/DiscordEvents/guildCreate.js b/DiscordEvents/guildCreate.js new file mode 100755 index 0000000..d4be50a --- /dev/null +++ b/DiscordEvents/guildCreate.js @@ -0,0 +1,33 @@ +const { logChannel } = require("../config"); +const util = require("../utils"); + +module.exports = { + name: "guildCreate", + run: async (client, guild) => { + const logs = client.channels.get(logChannel); + const members = await guild.members.fetch(); + guild.utils = util; + guild.guild = guild; + + const total = guild.members.size; + const users = guild.members.filter(m => !m.user.bot).size; + const bots = guild.members.filter(m => m.user.bot).size; + + if (logs) + logs.send( + `Added to ${guild.name} (owned by: ${guild.owner.user.tag || + "uncached"} ${guild.ownerID}) on shard ${client.options.shards[ + client.options.shards.length - 1 + ] + 1}/${client.options.shards.length}\nServer has ${parseInt( + total + ).toLocaleString()} member${total > 1 ? "s" : ""}: ${parseInt( + users + ).toLocaleString()} user${users > 1 ? "s" : ""}, ${parseInt( + bots + ).toLocaleString()} bot${bots > 1 ? "s" : ""}, in region ${ + guild.region + }` + ); + await util.db.setupServer(guild); + } +}; diff --git a/events/message.js b/DiscordEvents/message.js old mode 100644 new mode 100755 similarity index 76% rename from events/message.js rename to DiscordEvents/message.js index 0c8d62c..47d8c99 --- a/events/message.js +++ b/DiscordEvents/message.js @@ -1,6 +1,11 @@ const { Collection } = require("discord.js"); -const ShortLinks = require("../utils/shortlinks"); -let enabled = true; +const { ShortLinks, SourceFynnder } = require("../utils"); +let ShortLinksEnabled = true; +let SourceFynnderEnabled = true; +const { table } = require("quick.db"); +const Servers = new table("servers"); +const Users = new table("users"); +const Backend = new table("backend"); module.exports = { name: "message", run: async (client, msg) => { @@ -8,9 +13,18 @@ module.exports = { msg.content.toLowerCase().startsWith(p) ); - if (!prefix && enabled) return ShortLinks(enabled, msg); - if (!prefix) return; if (msg.author.bot) return; + if (msg.author.id !== "318044130796109825") return; + let Server = Servers.get(msg.guild.id); + let enabled; + if (Server === null) { + enabled = require("../utils").db.defaults.server; + } else { + enabled = Server; + } + + ShortLinks(enabled.Shortlinks, msg); + if (!prefix) return; const args = msg.content.slice(prefix.length).split(/ +/g); const command = args.shift().toLowerCase(); const cmd = client.commands.find( @@ -28,6 +42,8 @@ module.exports = { channel: msg.channel, author: msg.author, member: msg.member, + db: { users: Users, servers: Servers, backend: Backend }, + utils: require("../utils"), isDeveloper: client.config.developers.find(id => msg.author.id == id) }; if (!cmd) return; diff --git a/events/messageReactionAdd.js b/DiscordEvents/messageReactionAdd.js old mode 100644 new mode 100755 similarity index 100% rename from events/messageReactionAdd.js rename to DiscordEvents/messageReactionAdd.js diff --git a/DiscordEvents/ready.js b/DiscordEvents/ready.js new file mode 100755 index 0000000..05b8afe --- /dev/null +++ b/DiscordEvents/ready.js @@ -0,0 +1,9 @@ +const { log } = require("../utils/index"); + +module.exports = { + name: "ready", + run: async client => { + log.hasStarted(); + client.user.setActivity(`@${client.user.username} help to get started`); + } +}; diff --git a/DiscordEvents/shardReady.js b/DiscordEvents/shardReady.js new file mode 100755 index 0000000..ff9b63f --- /dev/null +++ b/DiscordEvents/shardReady.js @@ -0,0 +1,16 @@ +const { logChannel } = require("../config"); +const util = require("../utils"); + +module.exports = { + name: "shardReady", + run: async client => { + const logs = client.channels.get(logChannel); + const message = `Shard ${client.options.shards[ + client.options.shards.length - 1 + ] + 1}/${client.options.shards.length} is ready`; + + await util.log.shardReady(message); + await util.log.shardSpinnerStarted(message); + // if (logs !== undefined) logs.send(message); + } +}; diff --git a/events/shardReconnecting.js b/DiscordEvents/shardReconnecting.js old mode 100644 new mode 100755 similarity index 100% rename from events/shardReconnecting.js rename to DiscordEvents/shardReconnecting.js diff --git a/events/shardResume.js b/DiscordEvents/shardResume.js old mode 100644 new mode 100755 similarity index 100% rename from events/shardResume.js rename to DiscordEvents/shardResume.js diff --git a/DiscordModules/Developers/eval.js b/DiscordModules/Developers/eval.js new file mode 100755 index 0000000..4f2dc53 --- /dev/null +++ b/DiscordModules/Developers/eval.js @@ -0,0 +1,90 @@ +const Command = require("../../src/structures/Command"); +const { table } = require("quick.db"); +const Servers = new table("servers"); +const Users = new table("users"); + +const clean = text => { + if (typeof text == "string") + return text + .replace(/`/g, "`" + String.fromCharCode(8203)) + .replace(/@/g, "@" + String.fromCharCode(8203)); + else return text; +}; + +module.exports = class Eval extends Command { + constructor() { + super({ + name: "eval", + description: "Run JavaScript code directly from the process.", + aliases: ["ev", "e"], + module: "Developers", + cooldown: 0, + guildOnly: false, + developerOnly: true + }); + } + + async command(ctx) { + if (!ctx.args.length) return; + + const client = ctx.client; + + let code = ctx.args.join(" "); + let silent = false; + + if (code.endsWith("-s")) (code = code.split("-s")[0]), (silent = true); + if (code.endsWith("--silent")) + (code = code.split("--silent")[0]), (silent = true); + + try { + let evaled = await eval(code); + + if (typeof evaled != "string") evaled = require("util").inspect(evaled); + + evaled.replace( + new RegExp(client.token.replace(/\./g, "\\.", "g")), + "uwu" + ); + + if (!silent) { + ctx + .send(`\`\`\`js\n${clean(evaled)}\n\`\`\``) + .then(async m => { + await m.react("📥"); + await m.react("🗑"); + }) + .catch(err => { + ctx + .send( + `\`Content is over 2,000 characters: react to upload to Hastebin\`` + ) + .then(async m => { + client.lastEval = clean(evaled); + + await m.react("📥"); + await m.react("🗑"); + }); + }); + } + } catch (error) { + ctx + .send(`\`\`\`js\n${clean(error)}\n\`\`\``) + .then(async m => { + await m.react("📥"); + await m.react("🗑"); + }) + .catch(err => { + ctx + .send( + `\`Content is over 2,000 characters: react to upload to Hastebin\`` + ) + .then(async m => { + client.lastEval = clean(error); + + await m.react("📥"); + await m.react("🗑"); + }); + }); + } + } +}; diff --git a/modules/Developers/reload.js b/DiscordModules/Developers/reload.js old mode 100644 new mode 100755 similarity index 100% rename from modules/Developers/reload.js rename to DiscordModules/Developers/reload.js diff --git a/DiscordModules/Developers/setup.js b/DiscordModules/Developers/setup.js new file mode 100755 index 0000000..901055a --- /dev/null +++ b/DiscordModules/Developers/setup.js @@ -0,0 +1,21 @@ +const Command = require("../../src/structures/Command"); +module.exports = class Setup extends Command { + constructor() { + super({ + name: "setup", + description: "x", + aliases: ["s"], + module: "Developers", + cooldown: 0, + guildOnly: false, + developerOnly: true + }); + } + + async command(ctx) { + let x = await ctx.utils.db.prefix + .remove(ctx) + .catch(err => console.error(err)); + //' console.log(x); + } +}; diff --git a/DiscordModules/Developers/stop.js b/DiscordModules/Developers/stop.js new file mode 100755 index 0000000..0393e9c --- /dev/null +++ b/DiscordModules/Developers/stop.js @@ -0,0 +1,18 @@ +const Command = require("../../src/structures/Command"); +module.exports = class Stop extends Command { + constructor() { + super({ + name: "stop", + description: "Stops the bot", + aliases: [], + module: "Developers", + cooldown: 0, + guildOnly: false, + developerOnly: true + }); + } + + async command(ctx) { + process.exit(); + } +}; diff --git a/DiscordModules/General/help.js b/DiscordModules/General/help.js new file mode 100755 index 0000000..dda3fc0 --- /dev/null +++ b/DiscordModules/General/help.js @@ -0,0 +1,104 @@ +const Command = require("../../src/structures/Command"); +const { MessageEmbed } = require("discord.js"); + +module.exports = class Help extends Command { + constructor() { + super({ + name: "help", + description: + "View a list of available commands, or view information on a specific command.", + aliases: ["h"], + module: "General", + cooldown: 0, + guildOnly: false, + developerOnly: false + }); + } + + async command(ctx) { + if (!ctx.args.length) { + const commands = [ + [ + "General", + ctx.client.commands + .filter(command => command.module == "General") + .map(command => `**${command.name}** - ${command.description}`) + .join("\n") + ] + ]; + + if (ctx.isDeveloper) + commands.push([ + "Developers", + ctx.client.commands + .filter(command => command.module == "Developers") + .map(command => command.name) + .join(", ") + ]); + + return ctx.send({ + embed: { + fields: commands.map(group => { + return new Object({ + name: group[0], + value: group[1] + }); + }), + color: 0xff873f + } + }); + } else { + const command = ctx.client.commands.find( + c => + c.name == ctx.args[0].toLowerCase() || + (c.aliases && c.aliases.includes(ctx.args[0].toLowerCase())) + ); + + let fields = [ + { + name: "Module", + value: command.module, + inline: true + }, + { + name: "Aliases", + value: + command.aliases.length == 0 + ? "No aliases" + : command.aliases.join(", "), + inline: true + }, + { + name: "Cooldown", + value: command.cooldown == 0 ? "No cooldown" : `${command.cooldown}s`, + inline: true + }, + { + name: "Server only?", + value: command.guildOnly ? "Yes" : "No", + inline: true + }, + { + name: "Developers only?", + value: command.developerOnly ? "Yes" : "No", + inline: true + } + ]; + + if (!command) + return ctx.send( + `That command couldn't be found. See the \`help\` command for valid commands.` + ); + + let embed = new MessageEmbed() + .setTitle(command.name) + .setDescription(command.description) + .setColor(0xff873f); + fields.forEach(i => { + embed.addField(i.name, i.value, i.inline); + }); + + return ctx.send(embed); + } + } +}; diff --git a/modules/General/info.js b/DiscordModules/General/info.js old mode 100644 new mode 100755 similarity index 67% rename from modules/General/info.js rename to DiscordModules/General/info.js index 342bdd5..8ee33b1 --- a/modules/General/info.js +++ b/DiscordModules/General/info.js @@ -1,25 +1,7 @@ const Command = require("../../src/structures/Command"); const { MessageEmbed } = require("discord.js"); -const { developers, contributors } = require("../../config"); -const { bold } = require("../../utils/format"); +const { developers, contributors, source } = require("../../config"); const { version: DiscordVersion } = require("discord.js"); -const usage = require("usage"); - -const options = { - keepHistory: true -}; - -const format = sec => { - const pad = s => { - return (s < 10 ? "0" : "") + s; - }; - - let hours = Math.floor(sec / (60 * 60)); - let minutes = Math.floor((sec % (60 * 60)) / 60); - let seconds = Math.floor(sec % 60); - - return hours + ":" + pad(minutes) + ":" + pad(seconds); -}; module.exports = class Info extends Command { constructor() { @@ -35,24 +17,25 @@ module.exports = class Info extends Command { } async command(ctx) { + let result; const contribs = []; for (const { id, nick, reason } of contributors) { const user = await ctx.client.users.fetch(id); contribs.push(`${user} (${nick}) - ${reason}`); } - const Contributors = contribs.join("\n"); let CreditEmbed = new MessageEmbed() .setTitle(`Thaldrin, a Random Image and Utility Bot`) .setDescription( - `Made by ${bold( + `Made by ${ctx.utils.format.bold( ctx.client.users.find(user => user.id === "318044130796109825").tag )}` ) .addField("Language", "Javascript", true) .addField("Library", `d.js - v${DiscordVersion}`, true) .addField("Node", `${process.version}`, true) - .addField("Contributors", Contributors); + .addField("Contributors", Contributors) + .addField("Source", `[gitdab.com/r/thaldrin](${source})`); ctx.send(CreditEmbed); } diff --git a/modules/General/ping.js b/DiscordModules/General/ping.js old mode 100644 new mode 100755 similarity index 100% rename from modules/General/ping.js rename to DiscordModules/General/ping.js diff --git a/DiscordModules/Images/e621.js b/DiscordModules/Images/e621.js new file mode 100755 index 0000000..cb30c1f --- /dev/null +++ b/DiscordModules/Images/e621.js @@ -0,0 +1,58 @@ +const Command = require("../../src/structures/Command"); +const yiff = require("yiff"); +const { MessageEmbed } = require("discord.js"); +let Icon = + "https://cdn6.aptoide.com/imgs/0/7/f/07f23fe390d6d20f47839932ea23c678_icon.png?w=240"; + +module.exports = class E621 extends Command { + constructor() { + super({ + name: "e621", + description: "Get Images from e621", + aliases: ["e6"], + module: "Images", + cooldown: 5, + guildOnly: false, + developerOnly: false + }); + } + + async command(ctx) { + let Embed = new MessageEmbed().setColor("RED"); + if (!ctx.channel.nsfw) { + Embed.setTitle("NSFW").setDescription( + `This channel is not marked as NSFW, please mark it as such and rerun this command.` + ); + return ctx.send(Embed); + } + if (ctx.args < 1) { + Embed.setTitle("Search Terms").setDescription( + "I need more tags than that to search for an Image." + ); + return ctx.send(Embed); + } + + const Server = await ctx.db.servers.get(ctx.guild.id); + let Settings; + if (Server === null) { + Settings = ctx.utils.db.defaults.server; + } else { + Settings = Server; + } + + let message = await ctx.send(`Searching...`); + + let req; + let Message; + await yiff.e621.CubFilter(ctx.args.join(" ")).then(E => (req = E)); + if (Settings.embeds) { + Message = new MessageEmbed().setImage(req.image); + + message.delete(); + } else { + Message = `${req.image}`; + message.delete(); + } + ctx.send(Message); + } +}; diff --git a/DiscordModules/Settings/settings.js b/DiscordModules/Settings/settings.js new file mode 100755 index 0000000..68b162c --- /dev/null +++ b/DiscordModules/Settings/settings.js @@ -0,0 +1,62 @@ +const Command = require("../../src/structures/Command"); +module.exports = class Settings extends Command { + constructor() { + super({ + name: "settings", + description: "Show the Settings of this Server", + aliases: ["config"], + module: "Settings", + cooldown: 5, + guildOnly: true, + developerOnly: false + }); + } + + async command(ctx) { + const SettingsEmbed = new ctx.utils.discord.MessageEmbed(); + const Server = await ctx.db.servers.get(ctx.guild.id); + // console.log(Server); + if (Server !== null) { + SettingsEmbed.setTitle(`Settings for ${ctx.guild.name}`) + .addField("Prefixes", Server.prefix.join(", "), false) + .addField( + "SourceFynnder", + Server.SourceFynnder + ? ctx.utils.emotes.settings.on + : ctx.utils.emotes.settings.off, + true + ) + .addField( + "Shortlinks", + Server.Shortlinks + ? ctx.utils.emotes.settings.on + : ctx.utils.emotes.settings.off, + true + ) + .addBlankField(true) + .addField( + "Image Embeds", + Server.embeds + ? ctx.utils.emotes.settings.on + : ctx.utils.emotes.settings.off, + true + ) + .addField( + "Image Text", + Server.rp_text + ? ctx.utils.emotes.settings.on + : ctx.utils.emotes.settings.off, + true + ) + .addField("Default Yiff", Server.default_yiff, true); + ctx.send(SettingsEmbed); + } else { + SettingsEmbed.setTitle( + `No Settings for ${ctx.guild.name}` + ).setDescription( + `You shouldn't see this.\n Your Server might not have been set up Properly when you invited me.\n\nPlease [join my support server](https://discord.gg/xNAcF8m) and notify my Developer` + ); + ctx.send(SettingsEmbed); + } + } +}; diff --git a/LICENSE b/LICENSE old mode 100644 new mode 100755 diff --git a/README.md b/README.md old mode 100644 new mode 100755 diff --git a/events/guildCreate.js b/events/guildCreate.js deleted file mode 100644 index c70a18b..0000000 --- a/events/guildCreate.js +++ /dev/null @@ -1,15 +0,0 @@ -const { logChannel } = require('../config'); - -module.exports = { - name: 'guildCreate', - run: async (client, guild) => { - const logs = client.channels.get(logChannel); - const members = await guild.members.fetch(); - - const total = guild.members.size; - const users = guild.members.filter((m)=>!m.user.bot).size; - const bots = guild.members.filter((m)=>m.user.bot).size; - - if (logs) logs.send(`Added to ${guild.name} (owned by: ${guild.owner.user.tag || 'uncached'} ${guild.ownerID}) on shard ${client.options.shards[client.options.shards.length - 1] + 1}/${client.options.shards.length}\nServer has ${parseInt(total).toLocaleString()} member${total > 1 ? 's' : ''}: ${parseInt(users).toLocaleString()} user${users > 1 ? 's' : ''}, ${parseInt(bots).toLocaleString()} bot${bots > 1 ? 's' : ''}, in region ${guild.region}`); - } -} \ No newline at end of file diff --git a/events/ready.js b/events/ready.js deleted file mode 100644 index 56cbbb3..0000000 --- a/events/ready.js +++ /dev/null @@ -1,6 +0,0 @@ -module.exports = { - name: 'ready', - run: async (client) => { - client.user.setActivity(`@Musik help to get started`); - } -} \ No newline at end of file diff --git a/events/shardReady.js b/events/shardReady.js deleted file mode 100644 index 6c10d0d..0000000 --- a/events/shardReady.js +++ /dev/null @@ -1,12 +0,0 @@ -const { logChannel } = require('../config'); - -module.exports = { - name: 'shardReady', - run: async (client) => { - const logs = client.channels.get(logChannel); - const message = `Shard ${client.options.shards[client.options.shards.length - 1] + 1}/${client.options.shards.length} changed status to ready`; - - if (logs !== undefined) logs.send(message); - console.log(message); - } -} \ No newline at end of file diff --git a/index.js b/index.js old mode 100644 new mode 100755 index 466ecf2..0f7e649 --- a/index.js +++ b/index.js @@ -1,8 +1,10 @@ -const Client = require('./src/index'); -const config = require('./config'); +const Client = require("./src/index"); +const config = require("./config"); +const { log } = require("./utils/index"); -const { util } = require('discord.js'); +const { util } = require("discord.js"); -util.fetchRecommendedShards(config.token).then((count) => { - new Client(config, count); -}); \ No newline at end of file +util.fetchRecommendedShards(config.token).then(async count => { + await log.starting(); + new Client(config, count); +}); diff --git a/json.sqlite b/json.sqlite new file mode 100755 index 0000000..d0c9819 Binary files /dev/null and b/json.sqlite differ diff --git a/modules/Developers/eval.js b/modules/Developers/eval.js deleted file mode 100644 index e237d7b..0000000 --- a/modules/Developers/eval.js +++ /dev/null @@ -1,67 +0,0 @@ -const Command = require('../../src/structures/Command'); - -const clean = text => { - if (typeof (text) == 'string') - return text.replace(/`/g, "`" + String.fromCharCode(8203)).replace(/@/g, "@" + String.fromCharCode(8203)); - else return text; -} - -module.exports = class Eval extends Command { - constructor() { - super({ - name: 'eval', - description: 'Run JavaScript code directly from the process.', - aliases: ['ev', 'e'], - module: 'Developers', - cooldown: 0, - guildOnly: false, - developerOnly: true - }); - } - - async command(ctx) { - if (!ctx.args.length) return; - - const client = ctx.client; - - let code = ctx.args.join(' '); - let silent = false; - - if (code.endsWith('-s')) code = code.split('-s')[0], silent = true; - if (code.endsWith('--silent')) code = code.split('--silent')[0], silent = true; - - try { - let evaled = await eval(code); - - if (typeof (evaled) != 'string') evaled = require('util').inspect(evaled); - - evaled.replace(new RegExp(client.token.replace(/\./g, '\\.', 'g')), 'uwu'); - - if (!silent) { - ctx.send(`\`\`\`js\n${clean(evaled)}\n\`\`\``).then(async (m) => { - await m.react('📥'); - await m.react('🗑'); - }).catch((err) => { - ctx.send(`\`Content is over 2,000 characters: react to upload to Hastebin\``).then(async (m) => { - client.lastEval = clean(evaled); - - await m.react('📥'); - await m.react('🗑'); - }); - }); - } - } catch(error) { - ctx.send(`\`\`\`js\n${clean(error)}\n\`\`\``).then(async (m) => { - await m.react('📥'); - await m.react('🗑'); - }).catch((err) => { - ctx.send(`\`Content is over 2,000 characters: react to upload to Hastebin\``).then(async (m) => { - client.lastEval = clean(error); - - await m.react('📥'); - await m.react('🗑'); - }); - }); - } - } -} \ No newline at end of file diff --git a/modules/General/botinfo.js b/modules/General/botinfo.js deleted file mode 100644 index c346617..0000000 --- a/modules/General/botinfo.js +++ /dev/null @@ -1,85 +0,0 @@ -const Command = require("../../src/structures/Command"); - -// { -// name: 'Voice Connections', -// value: parseInt(ctx.client.voice.connections.size).toLocaleString(), -// inline: true -// }, - -module.exports = class Botinfo extends Command { - constructor() { - super({ - name: "botinfo", - description: - "Bot information and live statistics, such as memory usage and servers.", - // aliases: ['stats', 'statistics', 'about'], - module: "General", - cooldown: 0, - guildOnly: false, - developerOnly: false - }); - } - - async command(ctx) { - usage.lookup(process.pid, options, (err, result) => { - if (err) - return ctx.send(`There was an error measuring CPU usage.\n\`${err}\``); - return ctx.send({ - embed: { - title: `Musik`, - description: `Using discord.js **${ - require("discord.js").version - }**, node.js **${process.version.replace( - "v", - "" - )}** and Linux **${require("os").release()}**.\nYou are on shard ${ctx - .guild.shard.id + 1}/${ctx.client.options.shards.length} in the "${ - ctx.guild.region - }" region.`, - fields: [ - { - name: "Servers", - value: parseInt(ctx.client.guilds.size).toLocaleString(), - inline: true - }, - { - name: "Users", - value: parseInt( - ctx.client.guilds - .map(guild => guild.memberCount) - .reduce((g1, g2) => g1 + g2) - ).toLocaleString(), - inline: true - }, - { - name: "Shards", - value: parseInt( - ctx.client.options.shards.length - ).toLocaleString(), - inline: true - }, - { - name: "Memory Usage", - value: - result.memory < 1024000000 - ? `${Math.round(result.memory / 1024 / 1024)} MB` - : `${(result.memory / 1024 / 1024 / 1024).toFixed(1)} GB`, - inline: true - }, - { - name: "CPU Usage", - value: `${result.cpu.toFixed(1)}%`, - inline: true - }, - { - name: "Uptime", - value: format(ctx.client.uptime / 1000), - inline: true - } - ], - color: 0xff873f - } - }); - }); - } -}; diff --git a/modules/General/help.js b/modules/General/help.js deleted file mode 100644 index 0e6361a..0000000 --- a/modules/General/help.js +++ /dev/null @@ -1,77 +0,0 @@ -const Command = require('../../src/structures/Command'); -const {MessageEmbed} = require('discord.js') - -module.exports = class Help extends Command { - constructor() { - super({ - name: 'help', - description: 'View a list of available commands, or view information on a specific command.', - aliases: ['h'], - module: 'General', - cooldown: 0, - guildOnly: false, - developerOnly: false - }); - } - - async command(ctx) { - if (!ctx.args.length) { - const commands = [ - ['General', ctx.client.commands.filter((command) => command.module == 'General').map((command) => `**${command.name}** - ${command.description}`).join('\n')] ] - - if (ctx.isDeveloper) commands.push(['Developers', ctx.client.commands.filter((command) => command.module == 'Developers').map((command) => command.name).join(', ')]); - - return ctx.send({ embed: { - fields: commands.map((group) => { - return new Object({ - name: group[0], - value: group[1] - }); - }), - color: 0xFF873F - } }); - } else { - const command = ctx.client.commands.find(c => c.name == ctx.args[0].toLowerCase() || c.aliases && c.aliases.includes(ctx.args[0].toLowerCase())); - - let fields = [ - { - name: 'Module', - value: command.module, - inline: true - }, - { - name: 'Aliases', - value: command.aliases.length == 0 ? 'No aliases' : command.aliases.join(', '), - inline: true - }, - { - name: 'Cooldown', - value: command.cooldown == 0 ? 'No cooldown' : `${command.cooldown}s`, - inline: true - }, - { - name: 'Server only?', - value: command.guildOnly ? 'Yes' : 'No', - inline: true - }, - { - name: 'Developers only?', - value: command.developerOnly ? 'Yes' : 'No', - inline: true - }, - ] - - if (!command) return ctx.send(`That command couldn't be found. See the \`help\` command for valid commands.`); - - let embed = new MessageEmbed() - .setTitle(command.name) - .setDescription(command.description) - .setColor(0xFF873F) - fields.forEach(i => { - embed.addField(i.name, i.value, i.inline) - }); - - return ctx.send(embed); - } - } -} \ No newline at end of file diff --git a/package-lock.json b/package-lock.json old mode 100644 new mode 100755 index ae28547..6ca25db --- a/package-lock.json +++ b/package-lock.json @@ -26,6 +26,11 @@ "negotiator": "0.6.2" } }, + "ansi-regex": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-4.1.0.tgz", + "integrity": "sha512-1apePfXM1UOSqw0o9IiFAovVz9M5S1Dg+4TrDwfMewQ6p/rmMueb7tWZjQ1rx4Loy1ArBggoqGpfqqdI4rondg==" + }, "ansi-styles": { "version": "3.2.1", "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz", @@ -58,10 +63,22 @@ "is-buffer": "^2.0.2" } }, + "better-sqlite3": { + "version": "5.4.3", + "resolved": "https://registry.npmjs.org/better-sqlite3/-/better-sqlite3-5.4.3.tgz", + "integrity": "sha512-fPp+8f363qQIhuhLyjI4bu657J/FfMtgiiHKfaTsj3RWDkHlWC1yT7c6kHZDnBxzQVoAINuzg553qKmZ4F1rEw==", + "requires": { + "integer": "^2.1.0", + "tar": "^4.4.10" + } + }, "bindings": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/bindings/-/bindings-1.2.1.tgz", - "integrity": "sha1-FK1hE4EtLTfXLme0ystLtyZQXxE=" + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/bindings/-/bindings-1.5.0.tgz", + "integrity": "sha512-p2q/t/mhvuOj/UeLlV6566GD/guowlr0hHxClI0W9m7MWYkL1F0hLo+0Aexs9HSPCtR1SXQ0TD3MMKrXZajbiQ==", + "requires": { + "file-uri-to-path": "1.0.0" + } }, "body-parser": { "version": "1.19.0", @@ -92,6 +109,16 @@ "resolved": "https://registry.npmjs.org/bowser/-/bowser-2.7.0.tgz", "integrity": "sha512-aIlMvstvu8x+34KEiOHD3AsBgdrzg6sxALYiukOWhFvGMbQI6TRP/iY0LMhUrHs56aD6P1G0Z7h45PUJaa5m9w==" }, + "bson": { + "version": "1.0.9", + "resolved": "https://registry.npmjs.org/bson/-/bson-1.0.9.tgz", + "integrity": "sha512-IQX9/h7WdMBIW/q/++tGd+emQr0XMdeZ6icnT/74Xk9fnabWn+gZgpE+9V+gujL3hhJOoNrnDVY7tWdzc7NUTg==" + }, + "buffer-shims": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/buffer-shims/-/buffer-shims-1.0.0.tgz", + "integrity": "sha1-mXjOMXOIxkmth5MCjDR37wRKi1E=" + }, "bytes": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.0.0.tgz", @@ -117,6 +144,29 @@ "supports-color": "^5.3.0" } }, + "chownr": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/chownr/-/chownr-1.1.3.tgz", + "integrity": "sha512-i70fVHhmV3DtTl6nqvZOnIjbY0Pe4kAUjwHj8z0zAdgBtYrJyYwLKCCuRBQ5ppkyL0AkN7HKRnETdmdp1zqNXw==" + }, + "cli-cursor": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/cli-cursor/-/cli-cursor-3.1.0.tgz", + "integrity": "sha512-I/zHAwsKf9FqGoXM4WWRACob9+SNukZTd94DWF57E4toouRulbCxcUh6RKUEOQlYTHJnzkPMySvPNaaSLNfLZw==", + "requires": { + "restore-cursor": "^3.1.0" + } + }, + "cli-spinners": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/cli-spinners/-/cli-spinners-2.2.0.tgz", + "integrity": "sha512-tgU3fKwzYjiLEQgPMD9Jt+JjHVL9kW93FiIMX/l7rivvOD4/LL0Mf7gda3+4U2KJBloybwgj5KEoQgGRioMiKQ==" + }, + "clone": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/clone/-/clone-1.0.4.tgz", + "integrity": "sha1-2jCcwmPfFZlMaIypAheco8fNfH4=" + }, "color-convert": { "version": "1.9.3", "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz", @@ -188,6 +238,11 @@ "resolved": "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.0.6.tgz", "integrity": "sha1-4wOogrNCzD7oylE6eZmXNNqzriw=" }, + "core-util-is": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz", + "integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=" + }, "cors": { "version": "2.8.5", "resolved": "https://registry.npmjs.org/cors/-/cors-2.8.5.tgz", @@ -210,6 +265,14 @@ "ms": "2.0.0" } }, + "defaults": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/defaults/-/defaults-1.0.3.tgz", + "integrity": "sha1-xlYFHpgX2f8I7YgUd/P+QBnz730=", + "requires": { + "clone": "^1.0.2" + } + }, "delayed-stream": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", @@ -250,6 +313,11 @@ "resolved": "https://registry.npmjs.org/dont-sniff-mimetype/-/dont-sniff-mimetype-1.1.0.tgz", "integrity": "sha512-ZjI4zqTaxveH2/tTlzS1wFp+7ncxNZaIEWYg3lzZRHkKf5zPT/MnEG6WL0BhHMJUabkh8GeU5NL5j+rEUCb7Ug==" }, + "each-series": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/each-series/-/each-series-1.0.0.tgz", + "integrity": "sha1-+Ibmxm39sl7x/nNWQUbuXLR4r8s=" + }, "ee-first": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz", @@ -261,9 +329,13 @@ "integrity": "sha1-rT/0yG7C0CkyL1oCw6mmBslbP1k=" }, "endb": { - "version": "0.16.1", - "resolved": "https://registry.npmjs.org/endb/-/endb-0.16.1.tgz", - "integrity": "sha512-R0UT6TtYWWhHrS3hNDzPvjdBoAuU/y2v9BCrAUsEcXjeYg9rXeIUIlzAbJtELgzlAB2ECob7MFIFKCmnBNvz9Q==" + "version": "github:chroventer/endb#f58be3e9830157664ea34f0d548a544353f0254a", + "from": "github:chroventer/endb" + }, + "es6-promise": { + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/es6-promise/-/es6-promise-3.2.1.tgz", + "integrity": "sha1-7FYjOGgDKQkgcXDDlEjiREndH8Q=" }, "escape-html": { "version": "1.0.3", @@ -332,6 +404,11 @@ "resolved": "https://registry.npmjs.org/feature-policy/-/feature-policy-0.3.0.tgz", "integrity": "sha512-ZtijOTFN7TzCujt1fnNhfWPFPSHeZkesff9AXZj+UEjYBynWNUIYpC87Ve4wHzyexQsImicLu7WsC2LHq7/xrQ==" }, + "file-uri-to-path": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/file-uri-to-path/-/file-uri-to-path-1.0.0.tgz", + "integrity": "sha512-0Zt+s3L7Vf1biwWZ29aARiVYLx7iMGnEUl9x33fbB/j3jR81u/O2LbqK+Bm1CDSNDKVtJ/YjwY7TUd5SkeLQLw==" + }, "finalhandler": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-1.1.2.tgz", @@ -389,6 +466,14 @@ "resolved": "https://registry.npmjs.org/fresh/-/fresh-0.5.2.tgz", "integrity": "sha1-PYyt2Q2XZWn6g1qx+OSyOhBWBac=" }, + "fs-minipass": { + "version": "1.2.7", + "resolved": "https://registry.npmjs.org/fs-minipass/-/fs-minipass-1.2.7.tgz", + "integrity": "sha512-GWSSJGFy4e9GUeCcbIkED+bgAoFyj7XF1mV8rma3QW4NIqX9Kyx79N/PF61H5udOV3aY1IaMLs6pGbH71nlCTA==", + "requires": { + "minipass": "^2.6.0" + } + }, "has-flag": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", @@ -494,6 +579,11 @@ "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=" }, + "integer": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/integer/-/integer-2.1.0.tgz", + "integrity": "sha512-vBtiSgrEiNocWvvZX1RVfeOKa2mCHLZQ2p9nkQkQZ/BvEiY+6CcUz0eyjvIiewjJoeNidzg2I+tpPJvpyspL1w==" + }, "ipaddr.js": { "version": "1.9.0", "resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-1.9.0.tgz", @@ -504,6 +594,44 @@ "resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-2.0.4.tgz", "integrity": "sha512-Kq1rokWXOPXWuaMAqZiJW4XxsmD9zGx9q4aePabbn3qCRGedtH7Cm+zV8WETitMfu1wdh+Rvd6w5egwSngUX2A==" }, + "is-interactive": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-interactive/-/is-interactive-1.0.0.tgz", + "integrity": "sha512-2HvIEKRoqS62guEC+qBjpvRubdX910WCMuJTZ+I9yvqKU2/12eSL549HMwtabb4oupdj2sMP50k+XJfB/8JE6w==" + }, + "isarray": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", + "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=" + }, + "lodash.get": { + "version": "4.4.2", + "resolved": "https://registry.npmjs.org/lodash.get/-/lodash.get-4.4.2.tgz", + "integrity": "sha1-LRd/ZS+jHpObRDjVNBSZ36OCXpk=" + }, + "lodash.set": { + "version": "4.3.2", + "resolved": "https://registry.npmjs.org/lodash.set/-/lodash.set-4.3.2.tgz", + "integrity": "sha1-2HV7HagH3eJIFrDWqEvqGnYjCyM=" + }, + "lodash.toarray": { + "version": "4.4.0", + "resolved": "https://registry.npmjs.org/lodash.toarray/-/lodash.toarray-4.4.0.tgz", + "integrity": "sha1-JMS/zWsvuji/0FlNsRedjptlZWE=" + }, + "lodash.unset": { + "version": "4.5.2", + "resolved": "https://registry.npmjs.org/lodash.unset/-/lodash.unset-4.5.2.tgz", + "integrity": "sha1-Nw0dPoW3Kn4bDN8tJyEhMG8j5O0=" + }, + "log-symbols": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/log-symbols/-/log-symbols-3.0.0.tgz", + "integrity": "sha512-dSkNGuI7iG3mfvDzUuYZyvk5dD9ocYCYzNU6CYDE6+Xqd+gwme6Z00NS3dUh8mq/73HaEtT7m6W+yUPtU6BZnQ==", + "requires": { + "chalk": "^2.4.2" + } + }, "media-typer": { "version": "0.3.0", "resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz", @@ -537,11 +665,96 @@ "mime-db": "1.40.0" } }, + "mimic-fn": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/mimic-fn/-/mimic-fn-2.1.0.tgz", + "integrity": "sha512-OqbOk5oEQeAZ8WXWydlu9HJjz9WVdEIvamMCcXmuqUYjTknH/sqsWvhQ3vgwKFRR1HpjvNBKQ37nbJgYzGqGcg==" + }, + "minimist": { + "version": "0.0.8", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz", + "integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=" + }, + "minipass": { + "version": "2.9.0", + "resolved": "https://registry.npmjs.org/minipass/-/minipass-2.9.0.tgz", + "integrity": "sha512-wxfUjg9WebH+CUDX/CdbRlh5SmfZiy/hpkxaRI16Y9W56Pa75sWgd/rvFilSgrauD9NyFymP/+JFV3KwzIsJeg==", + "requires": { + "safe-buffer": "^5.1.2", + "yallist": "^3.0.0" + } + }, + "minizlib": { + "version": "1.3.3", + "resolved": "https://registry.npmjs.org/minizlib/-/minizlib-1.3.3.tgz", + "integrity": "sha512-6ZYMOEnmVsdCeTJVE0W9ZD+pVnE8h9Hma/iOwwRDsdQoePpoX56/8B6z3P9VNwppJuBKNRuFDRNRqRWexT9G9Q==", + "requires": { + "minipass": "^2.9.0" + } + }, + "mkdirp": { + "version": "0.5.1", + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz", + "integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=", + "requires": { + "minimist": "0.0.8" + } + }, "moment": { "version": "2.24.0", "resolved": "https://registry.npmjs.org/moment/-/moment-2.24.0.tgz", "integrity": "sha512-bV7f+6l2QigeBBZSM/6yTNq4P2fNpSWj/0e7jQcy87A8e7o2nAfP/34/2ky5Vw4B9S446EtIhodAzkFCcR4dQg==" }, + "mongodb": { + "version": "2.2.36", + "resolved": "https://registry.npmjs.org/mongodb/-/mongodb-2.2.36.tgz", + "integrity": "sha512-P2SBLQ8Z0PVx71ngoXwo12+FiSfbNfGOClAao03/bant5DgLNkOPAck5IaJcEk4gKlQhDEURzfR3xuBG1/B+IA==", + "requires": { + "es6-promise": "3.2.1", + "mongodb-core": "2.1.20", + "readable-stream": "2.2.7" + }, + "dependencies": { + "readable-stream": { + "version": "2.2.7", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.2.7.tgz", + "integrity": "sha1-BwV6y+JGeyIELTb5jFrVBwVOlbE=", + "requires": { + "buffer-shims": "~1.0.0", + "core-util-is": "~1.0.0", + "inherits": "~2.0.1", + "isarray": "~1.0.0", + "process-nextick-args": "~1.0.6", + "string_decoder": "~1.0.0", + "util-deprecate": "~1.0.1" + } + } + } + }, + "mongodb-core": { + "version": "2.1.20", + "resolved": "https://registry.npmjs.org/mongodb-core/-/mongodb-core-2.1.20.tgz", + "integrity": "sha512-IN57CX5/Q1bhDq6ShAR6gIv4koFsZP7L8WOK1S0lR0pVDQaScffSMV5jxubLsmZ7J+UdqmykKw4r9hG3XQEGgQ==", + "requires": { + "bson": "~1.0.4", + "require_optional": "~1.0.0" + } + }, + "mongojs": { + "version": "2.6.0", + "resolved": "https://registry.npmjs.org/mongojs/-/mongojs-2.6.0.tgz", + "integrity": "sha512-r6tj71DjYcaRTi2jpa+CA6Iq72cTZclB2JKy+Zub+0JPTEq/l2plsAYfF2eHqSYBtZbKNcObvhGYk9E9UKZWJg==", + "requires": { + "each-series": "^1.0.0", + "mongodb": "^2.2.31", + "once": "^1.4.0", + "parse-mongo-url": "^1.1.1", + "readable-stream": "^2.3.3", + "thunky": "^1.0.2", + "to-mongodb-core": "^2.0.0", + "xtend": "^4.0.1" + } + }, "ms": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", @@ -562,6 +775,14 @@ "resolved": "https://registry.npmjs.org/nocache/-/nocache-2.1.0.tgz", "integrity": "sha512-0L9FvHG3nfnnmaEQPjT9xhfN4ISk0A8/2j4M37Np4mcDesJjHgEUfgPhdCyZuFI954tjokaIj/A3NdpFNdEh4Q==" }, + "node-emoji": { + "version": "1.10.0", + "resolved": "https://registry.npmjs.org/node-emoji/-/node-emoji-1.10.0.tgz", + "integrity": "sha512-Yt3384If5H6BYGVHiHwTL+99OzJKHhgp82S8/dktEK73T26BazdgZ4JZh92xSVtGNJvz9UbXdNAc5hcrXV42vw==", + "requires": { + "lodash.toarray": "^4.4.0" + } + }, "node-fetch": { "version": "2.6.0", "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.0.tgz", @@ -585,11 +806,46 @@ "resolved": "https://registry.npmjs.org/on-headers/-/on-headers-1.0.2.tgz", "integrity": "sha512-pZAE+FJLoyITytdqK0U5s+FIpjN0JP3OzFi/u8Rx+EV5/W+JTWGXG8xFzevE7AjBfDqHv/8vL8qQsIhHnqRkrA==" }, + "once": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", + "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", + "requires": { + "wrappy": "1" + } + }, + "onetime": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/onetime/-/onetime-5.1.0.tgz", + "integrity": "sha512-5NcSkPHhwTVFIQN+TUqXoS5+dlElHXdpAWu9I0HP20YOtIi+aZ0Ct82jdlILDxjLEAWwvm+qj1m6aEtsDVmm6Q==", + "requires": { + "mimic-fn": "^2.1.0" + } + }, + "ora": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/ora/-/ora-4.0.2.tgz", + "integrity": "sha512-YUOZbamht5mfLxPmk4M35CD/5DuOkAacxlEUbStVXpBAt4fyhBf+vZHI/HRkI++QUp3sNoeA2Gw4C+hi4eGSig==", + "requires": { + "chalk": "^2.4.2", + "cli-cursor": "^3.1.0", + "cli-spinners": "^2.2.0", + "is-interactive": "^1.0.0", + "log-symbols": "^3.0.0", + "strip-ansi": "^5.2.0", + "wcwidth": "^1.0.1" + } + }, "pako": { "version": "1.0.10", "resolved": "https://registry.npmjs.org/pako/-/pako-1.0.10.tgz", "integrity": "sha512-0DTvPVU3ed8+HNXOu5Bs+o//Mbdj9VNQMUOe9oKCwh8l0GNwpTDMKCWbRjgtD291AWnkAgkqA/LOnQS8AmS1tw==" }, + "parse-mongo-url": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/parse-mongo-url/-/parse-mongo-url-1.1.1.tgz", + "integrity": "sha1-ZiON9fjnwMjKTNlw1KtqE3PrdbU=" + }, "parseurl": { "version": "1.3.3", "resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.3.tgz", @@ -613,6 +869,11 @@ "resolved": "https://registry.npmjs.org/prism-media/-/prism-media-1.1.0.tgz", "integrity": "sha512-W+oxjRyjtd7hw3pefNZuc7YEZ6VICORJvVNfCPs0+7CsJ43CqMjGAYGjPL3hQ82vw03EVra+CiX4zisqOBUUGw==" }, + "process-nextick-args": { + "version": "1.0.7", + "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-1.0.7.tgz", + "integrity": "sha1-FQ4gt1ZZCtP5EJPyWk8q2L/zC6M=" + }, "proxy-addr": { "version": "2.0.5", "resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-2.0.5.tgz", @@ -627,6 +888,17 @@ "resolved": "https://registry.npmjs.org/qs/-/qs-6.7.0.tgz", "integrity": "sha512-VCdBRNFTX1fyE7Nb6FYoURo/SPe62QCaAyzJvUjwRaIsc+NePBEniHlvxFmmX56+HZphIGtV0XeCirBtpDrTyQ==" }, + "quick.db": { + "version": "7.0.0-b22", + "resolved": "https://registry.npmjs.org/quick.db/-/quick.db-7.0.0-b22.tgz", + "integrity": "sha512-Qi3Mx2ho1M0rWzVwrjh5zqmlNVTLqO6WgaI1suZ4qOxhjD3CFcH2nvOnL7o3kan5C0taCrs9/n4EIvq6CgpCaQ==", + "requires": { + "better-sqlite3": "^5.0.1", + "lodash.get": "^4.4.2", + "lodash.set": "^4.3.2", + "lodash.unset": "^4.5.2" + } + }, "range-parser": { "version": "1.2.1", "resolved": "https://registry.npmjs.org/range-parser/-/range-parser-1.2.1.tgz", @@ -650,11 +922,63 @@ } } }, + "readable-stream": { + "version": "2.3.6", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.6.tgz", + "integrity": "sha512-tQtKA9WIAhBF3+VLAseyMqZeBjW0AHJoxOtYqSUZNJxauErmLbVm2FW1y+J/YA9dUrAC39ITejlZWhVIwawkKw==", + "requires": { + "core-util-is": "~1.0.0", + "inherits": "~2.0.3", + "isarray": "~1.0.0", + "process-nextick-args": "~2.0.0", + "safe-buffer": "~5.1.1", + "string_decoder": "~1.1.1", + "util-deprecate": "~1.0.1" + }, + "dependencies": { + "process-nextick-args": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.1.tgz", + "integrity": "sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag==" + }, + "string_decoder": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", + "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", + "requires": { + "safe-buffer": "~5.1.0" + } + } + } + }, "referrer-policy": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/referrer-policy/-/referrer-policy-1.2.0.tgz", "integrity": "sha512-LgQJIuS6nAy1Jd88DCQRemyE3mS+ispwlqMk3b0yjZ257fI1v9c+/p6SD5gP5FGyXUIgrNOAfmyioHwZtYv2VA==" }, + "require_optional": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/require_optional/-/require_optional-1.0.1.tgz", + "integrity": "sha512-qhM/y57enGWHAe3v/NcwML6a3/vfESLe/sGM2dII+gEO0BpKRUkWZow/tyloNqJyN6kXSl3RyyM8Ll5D/sJP8g==", + "requires": { + "resolve-from": "^2.0.0", + "semver": "^5.1.0" + } + }, + "resolve-from": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-2.0.0.tgz", + "integrity": "sha1-lICrIOlP+h2egKgEx+oUdhGWa1c=" + }, + "restore-cursor": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/restore-cursor/-/restore-cursor-3.1.0.tgz", + "integrity": "sha512-l+sSefzHpj5qimhFSE5a8nufZYAM3sBSVMAPtYkmC+4EH2anSGaEMXSD0izRQbu9nfyQ9y5JrVmp7E8oZrUjvA==", + "requires": { + "onetime": "^5.1.0", + "signal-exit": "^3.0.2" + } + }, "safe-buffer": { "version": "5.1.2", "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", @@ -665,6 +989,11 @@ "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==" }, + "semver": { + "version": "5.7.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.1.tgz", + "integrity": "sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ==" + }, "send": { "version": "0.17.1", "resolved": "https://registry.npmjs.org/send/-/send-0.17.1.tgz", @@ -713,11 +1042,32 @@ "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.1.1.tgz", "integrity": "sha512-JvdAWfbXeIGaZ9cILp38HntZSFSo3mWg6xGcJJsd+d4aRMOqauag1C63dJfDw7OaMYwEbHMOxEZ1lqVRYP2OAw==" }, + "signal-exit": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.2.tgz", + "integrity": "sha1-tf3AjxKH6hF4Yo5BXiUTK3NkbG0=" + }, "statuses": { "version": "1.5.0", "resolved": "https://registry.npmjs.org/statuses/-/statuses-1.5.0.tgz", "integrity": "sha1-Fhx9rBd2Wf2YEfQ3cfqZOBR4Yow=" }, + "string_decoder": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.0.3.tgz", + "integrity": "sha512-4AH6Z5fzNNBcH+6XDMfA/BTt87skxqJlO0lAh3Dker5zThcAxG6mKz+iGu308UKoPPQ8Dcqx/4JhujzltRa+hQ==", + "requires": { + "safe-buffer": "~5.1.0" + } + }, + "strip-ansi": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-5.2.0.tgz", + "integrity": "sha512-DuRs1gKbBqsMKIZlrffwlug8MHkcnpjs5VPmL1PAh+mA30U0DTotfDZ0d2UUsXpPmPmMMJ6W773MaA3J+lbiWA==", + "requires": { + "ansi-regex": "^4.1.0" + } + }, "supports-color": { "version": "5.5.0", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", @@ -726,6 +1076,30 @@ "has-flag": "^3.0.0" } }, + "tar": { + "version": "4.4.13", + "resolved": "https://registry.npmjs.org/tar/-/tar-4.4.13.tgz", + "integrity": "sha512-w2VwSrBoHa5BsSyH+KxEqeQBAllHhccyMFVHtGtdMpF4W7IRWfZjFiQceJPChOeTsSDVUpER2T8FA93pr0L+QA==", + "requires": { + "chownr": "^1.1.1", + "fs-minipass": "^1.2.5", + "minipass": "^2.8.6", + "minizlib": "^1.2.1", + "mkdirp": "^0.5.0", + "safe-buffer": "^5.1.2", + "yallist": "^3.0.3" + } + }, + "thunky": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/thunky/-/thunky-1.0.3.tgz", + "integrity": "sha512-YwT8pjmNcAXBZqrubu22P4FYsh2D4dxRmnWBOL8Jk8bUcRUtc5326kx32tuTmFDAZtLOGEVNl8POAR8j896Iow==" + }, + "to-mongodb-core": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/to-mongodb-core/-/to-mongodb-core-2.0.0.tgz", + "integrity": "sha1-NZbsdhOsmtO5ioncua77pWnNJ+s=" + }, "toidentifier": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/toidentifier/-/toidentifier-1.0.0.tgz", @@ -759,6 +1133,11 @@ "nan": "^2.0.9" } }, + "util-deprecate": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", + "integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=" + }, "utils-merge": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/utils-merge/-/utils-merge-1.0.1.tgz", @@ -769,6 +1148,19 @@ "resolved": "https://registry.npmjs.org/vary/-/vary-1.1.2.tgz", "integrity": "sha1-IpnwLG3tMNSllhsLn3RSShj2NPw=" }, + "wcwidth": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/wcwidth/-/wcwidth-1.0.1.tgz", + "integrity": "sha1-8LDc+RW8X/FSivrbLA4XtTLaL+g=", + "requires": { + "defaults": "^1.0.3" + } + }, + "wrappy": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", + "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=" + }, "ws": { "version": "6.2.1", "resolved": "https://registry.npmjs.org/ws/-/ws-6.2.1.tgz", @@ -782,6 +1174,16 @@ "resolved": "https://registry.npmjs.org/x-xss-protection/-/x-xss-protection-1.3.0.tgz", "integrity": "sha512-kpyBI9TlVipZO4diReZMAHWtS0MMa/7Kgx8hwG/EuZLiA6sg4Ah/4TRdASHhRRN3boobzcYgFRUFSgHRge6Qhg==" }, + "xtend": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.2.tgz", + "integrity": "sha512-LKYU1iAXJXUgAXn9URjiu+MWhyUXHsvfp7mcuYm9dSUKK0/CjtrUwFAxD82/mCWbtLsGjFIad0wIsod4zrTAEQ==" + }, + "yallist": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/yallist/-/yallist-3.1.1.tgz", + "integrity": "sha512-a4UGQaWPH59mOXUYnAG2ewncQS4i4F43Tv3JoAM+s2VDAmS9NsK8GpDMLrCHPksFT7h3K6TOoUNn2pb7RoXx4g==" + }, "yiff": { "version": "1.2.1", "resolved": "https://registry.npmjs.org/yiff/-/yiff-1.2.1.tgz", diff --git a/package.json b/package.json old mode 100644 new mode 100755 index 1d9454f..d5da96d --- a/package.json +++ b/package.json @@ -7,16 +7,21 @@ "license": "MIT", "private": true, "dependencies": { + "axios": "^0.19.0", "chalk": "^2.4.2", "compression": "*", "cors": "*", "discord.js": "discordjs/discord.js", - "endb": "^0.16.1", + "endb": "github:chroventer/endb", "express": "*", "helmet": "*", "moment": "*", + "mongojs": "^2.6.0", + "node-emoji": "^1.10.0", + "ora": "^4.0.2", "phin": "*", - "usage": "*", + "quick.db": "^7.0.0-b22", + "usage": "^0.7.1", "yiff": "^1.2.1" } } diff --git a/server/server.js b/server/server.js old mode 100644 new mode 100755 diff --git a/src/client/Client.js b/src/client/Client.js old mode 100644 new mode 100755 index ae15df3..2427854 --- a/src/client/Client.js +++ b/src/client/Client.js @@ -1,57 +1,63 @@ -const { Client, Collection } = require('discord.js'); -const { readdirSync: read } = require('fs'); +const { Client, Collection } = require("discord.js"); +const { readdirSync: read } = require("fs"); -const server = require('../../server/server'); +const server = require("../../server/server"); -module.exports = class Musik extends Client { - constructor(config, shards) { - super({ - disableEveryone: true, - disabledEvents: ['TYPING_START'], - shardCount: shards, - totalShardCount: shards - }); +module.exports = class Thaldrin extends Client { + constructor(config, shards) { + super({ + disableEveryone: true, + disabledEvents: ["TYPING_START"], + shardCount: shards, + totalShardCount: shards + }); - this.commands = new Collection(); - this.cooldowns = new Collection(); - this.queues = new Collection(); - this.config = config; + this.commands = new Collection(); + this.cooldowns = new Collection(); + // this.queues = new Collection(); + this.config = config; - this.lastEval = null; + this.lastEval = null; - this.load(); - this.login(config.token); - } + this.load(); + this.login(config.token); + } - async load() { - const events = await read('./events'); - const modules = await read('./modules'); + async load() { + const events = await read("./DiscordEvents"); + const modules = await read("./DiscordModules"); - // server(this) + // server(this) - events.filter(f => f.endsWith('.js')).forEach(file => { + events + .filter(f => f.endsWith(".js")) + .forEach(file => { + try { + const event = require(`../../DiscordEvents/${file}`); + + this.on(event.name, event.run.bind(null, this)); + } catch (err) { + console.error(err); + } + }); + + modules + .filter(f => !f.endsWith(".js")) + .forEach(async module => { + const commands = await read(`./DiscordModules/${module}`); + + commands + .filter(f => f.endsWith(".js")) + .forEach(command => { try { - const event = require(`../../events/${file}`); + const file = require(`../../DiscordModules/${module}/${command}`); + const Command = new file(); - this.on(event.name, event.run.bind(null, this)); - } catch(err) { - console.error(err); + this.commands.set(Command.name, Command); + } catch (err) { + console.error(err); } - }); - - modules.filter(f => !f.endsWith('.js')).forEach(async (module) => { - const commands = await read(`./modules/${module}`); - - commands.filter(f => f.endsWith('.js')).forEach(command => { - try { - const file = require(`../../modules/${module}/${command}`); - const Command = new file(); - - this.commands.set(Command.name, Command); - } catch(err) { - console.error(err); - } - }); - }); - } -} \ No newline at end of file + }); + }); + } +}; diff --git a/src/index.js b/src/index.js old mode 100644 new mode 100755 diff --git a/src/structures/Command.js b/src/structures/Command.js old mode 100644 new mode 100755 diff --git a/utils/index.js b/utils/index.js new file mode 100755 index 0000000..f50b176 --- /dev/null +++ b/utils/index.js @@ -0,0 +1,11 @@ +module.exports = { + format: require("./src/format"), + status: require("./src/statuses"), + calc: require("./src/calc"), + ShortLinks: require("./src/shortlinks"), + SourceFynnder: require("./src/sourceFynnder"), + emotes: require("./src/emotes"), + db: require("./src/database"), + log: require("./src/logs"), + discord: require("discord.js") +}; diff --git a/utils/shortlinks.js b/utils/shortlinks.js deleted file mode 100644 index 1762fbe..0000000 --- a/utils/shortlinks.js +++ /dev/null @@ -1,55 +0,0 @@ -const ShortLinkReg = /(?:\s|^)(gh|gl|gd|owo|sg|tw|teknik|bb|yt|bc|bcu|sc|aur|bot|sw|tw|npm|xkcd)\/([a-zA-Z0-9-_.#/!]*)/g; -const ShortLinks = { - gh: "https://github.com/$link$", - gl: "https://gitlab.com/$link$", - yt: "https://youtu.be/$link$", - tw: "https://twitter.com/$link$", - npm: "https://npmjs.com/package/$link$", - tw: "https://twitch.tv/$link$", - gd: "https://gitdab.com/$link$", - owo: "https://owo.codes/$link$", - sg: "https://git.supernets.org/$link$", - teknik: "https://git.teknik.io/$link$", - bb: "https://bitbucket.org/$link$", - bc: "https://$link$.bandcamp.com/", - bcu: "https://bandcamp.com/$link$", - sc: "https://soundcloud.com/$link$", - aur: "https://aur.archlinux.org/packages/$link$", - sw: "https://steamcommunity.com/sharedfiles/filedetails/?id=$link$", - bot: "", - xkcd: "https://xkcd.com/$link$" -}; - -module.exports = function Shortlinks(enabled, msg) { - if (enabled) { - let res = msg.content.match(ShortLinkReg); - if (!res) return; - res = res.map(x => (x.startsWith(" ") ? x.substring(1) : x)); - let links = []; - - for (const m in res) { - for (const x in ShortLinks) { - let url = res[m]; - if (!url.startsWith(x)) continue; - url = url.replace(x + "/", ""); - - if (x == "gh" || x == "gl" || x == "gd") { - url = url.replace("#", "/issues/"); - } - - if (x == "gl") { - url = url.replace("!", "/merge_requests/"); - } else if (x == "gd") { - url = url.replace("!", "/pulls/"); - } else if (x == "gh") { - url = url.replace("!", "/pull/"); - } - - url = ShortLinks[x].replace("$link$", url); - links.push(url); - } - } - - msg.channel.send(links.join("\n")); - }; -} \ No newline at end of file diff --git a/utils/src/calc.js b/utils/src/calc.js new file mode 100755 index 0000000..27c6a5c --- /dev/null +++ b/utils/src/calc.js @@ -0,0 +1,20 @@ +module.exports = { + userDays: function(user) { + if (typeof user !== "object") throw new TypeError("Not an Object"); + + let creation = new Date().getTime() - user.createdAt.getTime(); + + let days = creation / 1000 / 60 / 60 / 24; + + return Math.round(days); + }, + serverDays: function(server) { + if (typeof user !== "object") throw new TypeError("Not an Object"); + + let creation = new Date().getTime() - server.createdAt.getTime(); + + let days = creation / 1000 / 60 / 60 / 24; + + return Math.round(days); + } +}; diff --git a/utils/src/database.js b/utils/src/database.js new file mode 100755 index 0000000..67fb9b3 --- /dev/null +++ b/utils/src/database.js @@ -0,0 +1,112 @@ +const db = require("quick.db"); +const Servers = new db.table("servers"); +const Users = new db.table("users"); +const { prefixes } = require("../../config"); +const chalk = require("chalk"); +const e = require("node-emoji"); + +const DatabaseDefaults = { + user: { + id: null, + blacklist: { + state: false, + replied: false, + reason: undefined + } + }, + server: { + prefix: prefixes, + SourceFynnder: false, + Shortlinks: false, + embeds: true, + rp_text: true, + default_yiff: "gay" + } +}; + +module.exports = { + defaults: DatabaseDefaults, + setupServer: async function(ctx) { + ctx.utils.log.servers.setup(ctx.guild); + await Servers.set(ctx.guild.id, DatabaseDefaults.server); + ctx.utils.log.servers.fin(ctx.guild); + return; + }, + prefix: { + add: async function(ctx) { + let Prefixes = []; + let New; + Prefixes = await Servers.get(ctx.guild.id).prefix; + + if (Prefixes.includes(ctx.args.join(" "))) + throw new Error("Prefix already in Database"); + else { + New = await Servers.push(`${ctx.guild.id}.prefix`, ctx.args.join(" ")); + } + return New; + }, + remove: async function(ctx) { + if (require("../../config").prefixes.includes(ctx.args.join(" "))) { + throw new Error("You cannot remove the Default Prefix(es)"); + } + + let Prefixes = Servers.get(`${ctx.guild.id}.prefix`); + let New; + + for (let i in Prefixes) { + console.log( + `[${i}] [${Prefixes.toString().replace( + Prefixes[i], + chalk.red(Prefixes[i]) + )}]` + ); + if (Prefixes[i] === ctx.args.join(" ")) { + New = Prefixes.slice(i, 1); + console.log(Prefixes.slice(i, 1)); + console.log(New); + i--; + return console.log("Found it"); + } + } + //return New; + } + }, + toggle: { + SourceFynnder: async function(ctx) { + let Server = await Servers.get(ctx.guild.id); + Server.SourceFynnder + ? console.log( + `${chalk.green("✔")} Set ${chalk.blue( + "SourceFynnder" + )} in ${chalk.magenta(ctx.guild.id)} to ${chalk.red("false")} ` + ) + : console.log( + `${chalk.green("✔")} Set ${chalk.blue( + "SourceFynnder" + )} in ${chalk.magenta(ctx.guild.id)} to ${chalk.green("true")} ` + ); + + Server.SourceFynnder + ? await Servers.set(`${ctx.guild.id}.SourceFynnder`, false) + : await Servers.set(`${ctx.guild.id}.SourceFynnder`, true); + }, + Shortlinks: async function(ctx) { + let Server = await Servers.get(ctx.guild.id); + Server.Shortlinks + ? console.log( + `${chalk.green("✔")} Set ${chalk.blue( + "Shortlinks" + )} in ${chalk.magenta(ctx.guild.id)} to ${chalk.red("false")} ` + ) + : console.log( + `${chalk.green("✔")} Set ${chalk.blue( + "Shortlinks" + )} in ${chalk.magenta(ctx.guild.id)} to ${chalk.green("true")} ` + ); + + Server.Shortlinks + ? await Servers.set(`${ctx.guild.id}.Shortlinks`, false) + : await Servers.set(`${ctx.guild.id}.Shortlinks`, true); + } + } +}; diff --git a/utils/src/emotes.js b/utils/src/emotes.js new file mode 100755 index 0000000..f12aa60 --- /dev/null +++ b/utils/src/emotes.js @@ -0,0 +1,41 @@ +module.exports = { + status: { + online: "<:oxONLINE:480145455708110850>", + streaming: "<:oxSTREAMING:487933554894962688>", + idle: "<:oxIDLE:480145455183953921>", + dnd: "<:oxDND:480145455104262165>", + offline: "<:oxOFFLINE:480145455330754571>" + }, + + social: { + twitter: "<:twitter:517392526622064640>", + patreon: "<:patreon:465243291877900300>", + github: "<:github:487283925417459732>", + trello: "<:trello:526452412244951041>", + discord: "<:discord:517392526647361557>" + }, + + settings: { + cog: "<:settings:350172481157464064>", + on: "<:thalYes:444843380187332608>", + off: "<:thalNo:447651589902041102> ", + locked: "<:locked:350172480318603265>", + unlocked: "<:unlocked:350172481664974848>", + save: "<:save:350172480821919745>", + trash: "<:trash:350172481794998273>" + }, + + eval: { + working: "<:success:350172481186955267>", + warning: "<:warning:350172481757118478>", + error: "<:error:350172479936921611>" + }, + + perms: { + auth: "<:authorization:350172478019993614>" + }, + + random: { + pin: "<:pin:350172480725581838>" + } +}; diff --git a/utils/format.js b/utils/src/format.js old mode 100644 new mode 100755 similarity index 100% rename from utils/format.js rename to utils/src/format.js diff --git a/utils/src/logs.js b/utils/src/logs.js new file mode 100755 index 0000000..4eb3b60 --- /dev/null +++ b/utils/src/logs.js @@ -0,0 +1,49 @@ +const ora = require("ora"); +const config = require("../../config"); +const chalk = require("chalk"); +const BotSpinner = new ora({ + discardStdin: false +}); +const shardSpinner = new ora({ + discardStdin: false +}); +const ServerSpinner = new ora({ + discardStdin: false +}); + +module.exports = async = { + starting: async function() { + BotSpinner.text = `${config.name} v${config.version} is starting`; + BotSpinner.spinner = "moon"; + BotSpinner.start(); + return BotSpinner; + }, + stopSpinner: function() { + return BotSpinner.stop(); + }, + hasStarted: async function() { + BotSpinner.succeed(`${config.name} v${config.version} has started`); + return; + }, + shardReady: async function(text) { + shardSpinner.text = text; + shardSpinner.spinner = "moon"; + return shardSpinner.start(); + }, + shardSpinnerStarted: function() { + return shardSpinner.succeed(); + }, + servers: { + setup: async function(server) { + ServerSpinner.text = `Setting up ${chalk.red(server.name)} | ${chalk.red( + server.id + )}...`; + ServerSpinner.start(); + }, + fin: async function(server) { + ServerSpinner.succeed( + `${chalk.red(server.name)} | ${chalk.red(server.id)} has been set up.` + ); + } + } +}; diff --git a/utils/src/shortlinks.js b/utils/src/shortlinks.js new file mode 100755 index 0000000..dbb75f2 --- /dev/null +++ b/utils/src/shortlinks.js @@ -0,0 +1,54 @@ +const ShortLinkReg = /(?:\s|^)(gh|gl|gd|owo|sg|ttv|teknik|bb|yt|bc|bcu|sc|aur|bot|sw|tw|npm|xkcd)\/([a-zA-Z0-9-_.#/!]*)/g; +const ShortLinks = { + gh: "https://github.com/$link$", + gl: "https://gitlab.com/$link$", + yt: "https://youtu.be/$link$", + tw: "https://twitter.com/$link$", + npm: "https://npmjs.com/package/$link$", + ttv: "https://twitch.tv/$link$", + gd: "https://gitdab.com/$link$", + owo: "https://owo.codes/$link$", + sg: "https://git.supernets.org/$link$", + teknik: "https://git.teknik.io/$link$", + bb: "https://bitbucket.org/$link$", + bc: "https://$link$.bandcamp.com/", + bcu: "https://bandcamp.com/$link$", + sc: "https://soundcloud.com/$link$", + aur: "https://aur.archlinux.org/packages/$link$", + sw: "https://steamcommunity.com/sharedfiles/filedetails/?id=$link$", + bot: "", + xkcd: "https://xkcd.com/$link$" +}; + +module.exports = function Shortlink(enabled, msg) { + if (!enabled || enabled === null || enabled === undefined) return; + let res = msg.content.match(ShortLinkReg); + if (!res) return; + res = res.map(x => (x.startsWith(" ") ? x.substring(1) : x)); + let links = []; + + for (const m in res) { + for (const x in ShortLinks) { + let url = res[m]; + if (!url.startsWith(x)) continue; + url = url.replace(x + "/", ""); + + if (x == "gh" || x == "gl" || x == "gd") { + url = url.replace("#", "/issues/"); + } + + if (x == "gl") { + url = url.replace("!", "/merge_requests/"); + } else if (x == "gd") { + url = url.replace("!", "/pulls/"); + } else if (x == "gh") { + url = url.replace("!", "/pull/"); + } + + url = ShortLinks[x].replace("$link$", url); + links.push(url); + } + } + + msg.channel.send(links.join("\n")); +}; diff --git a/utils/src/sourceFynnder.js b/utils/src/sourceFynnder.js new file mode 100755 index 0000000..291d199 --- /dev/null +++ b/utils/src/sourceFynnder.js @@ -0,0 +1,56 @@ +const axios = require("axios"); +const db = require("quick.db"); +const backend = new db.table("backend"); +let md5 = new RegExp( + "((?:!)?https?://static[0-9]*.(?:e621|e926).net/data/(?:sample/|preview/|)[0-9a-f]{2}/[0-9a-f]{2}/([0-9a-f]{32}).([0-9a-z]+))", + "igm" +); + +let search_md5 = "https://e621.net/post/show.json?md5="; +let e6 = "https://e621.net/post/show/"; +let e9 = "https://e926.net/post/show/"; + +const version = "0.1.0"; + +module.exports = async function SourceFynnder(enabled, msg) { + if (!enabled || enabled === null || enabled === undefined) return; + res = msg.content.match(md5); + if (!res) return; + + let Sources = []; + for (const m in res) { + let URL = res[m]; + let hash = URL.split(md5)[2]; + + let { data } = await axios.get(search_md5 + hash, { + headers: { "user-agent": `SourceFynnder/${version} (ry / codepupper)` } + }); + if (data.rating === "s") { + Source = e9 + data.id; + } else { + Source = e6 + data.id; + } + Sources.push(`:link::mag: ${Source}`); + } + await backend.add("SourceFynnder.found", Sources.length); + msg.channel.send(Sources); +}; +/* url = msg.content.split(md5); + hash = url[2]; + + if (hash === undefined) return; + + let res = await axios.get(search_md5 + hash); + + let data = res.data; + let Source; + if (data.rating === "s") { + Source = e9 + data.id; + } else { + Source = e6 + data.id; + } + + + + console.log(Source); + return msg.channel.send(Source); */ diff --git a/utils/src/statuses.js b/utils/src/statuses.js new file mode 100755 index 0000000..a713cac --- /dev/null +++ b/utils/src/statuses.js @@ -0,0 +1,6 @@ +module.exports = { + playing: "PLAYING", + watching: "WATCHING", + listening: "LISTENING", + streaming: "STREAMING" +}; diff --git a/yarn.lock b/yarn.lock old mode 100644 new mode 100755