forked from Supositware/Haha-Yes
Rewrite of the whole bot
parent
c8dbe442be
commit
670383fe81
@ -1 +1,5 @@
|
|||||||
config.json
|
config.json
|
||||||
|
node_modules/
|
||||||
|
package.json
|
||||||
|
package-lock.json
|
||||||
|
.DS_Store
|
||||||
|
@ -0,0 +1,12 @@
|
|||||||
|
module.exports = {
|
||||||
|
name: 'args-info',
|
||||||
|
description: 'change your text into arguments',
|
||||||
|
args: true,
|
||||||
|
usage: '<random arguments>',
|
||||||
|
execute(message, args) {
|
||||||
|
if (args[0] === 'foo') {
|
||||||
|
return message.channel.send('bar');
|
||||||
|
}
|
||||||
|
message.channel.send(`First argument: ${args[0]}`);
|
||||||
|
},
|
||||||
|
};
|
@ -0,0 +1,15 @@
|
|||||||
|
module.exports = {
|
||||||
|
name: 'avatar',
|
||||||
|
aliases: ['icon', 'pfp'],
|
||||||
|
description: 'Send the avatar of the user mentionned',
|
||||||
|
execute(message) {
|
||||||
|
if (!message.mentions.users.size) {
|
||||||
|
return message.channel.send(`Your avatar: ${message.author.displayAvatarURL}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
const avatarList = message.mentions.users.map(user => {
|
||||||
|
return `${user.username}'s avatar: ${user.displayAvatarURL}`;
|
||||||
|
});
|
||||||
|
message.channel.send(avatarList);
|
||||||
|
},
|
||||||
|
};
|
@ -1,6 +1,10 @@
|
|||||||
exports.run = (client,message) => {
|
module.exports = {
|
||||||
if (message.author.id == "267065637183029248") {
|
name: 'ded',
|
||||||
message.channel.send("haha yes im ded now k bye thx").catch(console.error);
|
description: 'Reboot the bot',
|
||||||
process.exit();
|
aliases: ['shutdown', 'reboot'],
|
||||||
}
|
execute(message) {
|
||||||
};
|
if (message.author.id === '267065637183029248') {
|
||||||
|
process.exit();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
};
|
||||||
|
@ -1,27 +0,0 @@
|
|||||||
exports.run = (client, message, args) => {
|
|
||||||
|
|
||||||
function clean(text) {
|
|
||||||
if (typeof (text) === "string")
|
|
||||||
return text.replace(/`/g, "`" + String.fromCharCode(8203)).replace(/@/g, "@" + String.fromCharCode(8203));
|
|
||||||
else
|
|
||||||
return text;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (message.author.id == "267065637183029248") {
|
|
||||||
|
|
||||||
try {
|
|
||||||
const code = args.join(" ");
|
|
||||||
let evaled = eval(code);
|
|
||||||
|
|
||||||
if (typeof evaled !== "string")
|
|
||||||
evaled = require("util").inspect(evaled);
|
|
||||||
|
|
||||||
message.channel.send(clean(evaled), { code: "xl" });
|
|
||||||
} catch (err) {
|
|
||||||
message.channel.send(`\`ERROR\` \`\`\`xl\n${clean(err)}\n\`\`\``);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
message.channel.send("Sick you thought");
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,9 +1,46 @@
|
|||||||
exports.run = (client, message) => {
|
const { prefix } = require('../config.json');
|
||||||
message.channel.send({embed: {
|
|
||||||
color: 3447003,
|
module.exports = {
|
||||||
title: "Help",
|
name: 'help',
|
||||||
description: "Ping: Pong! \n Kick: Kick people from the server (Staff only) {haha kick (mention user)(reasons)} \n Reload: reload a specific command without rebooting the bot (owner only) {haha reload (name of commands)} \n Eval: let the owner do any commands {haha eval (the command)}",
|
description: 'List all of my commands or info about a specific command.',
|
||||||
timestamp: new Date(),
|
aliases: ['commands'],
|
||||||
}
|
usage: '[command name]',
|
||||||
});
|
cooldown: 5,
|
||||||
}
|
execute(message, args) {
|
||||||
|
const data = [];
|
||||||
|
const { commands } = message.client;
|
||||||
|
|
||||||
|
if (!args.length) {
|
||||||
|
data.push('Here\'s a list of all my commands:');
|
||||||
|
data.push(commands.map(command => command.name).join(', '));
|
||||||
|
data.push(`\nYou can send \`${prefix}help [command name]\` to get info on a specific command!`);
|
||||||
|
|
||||||
|
return message.author.send(data, { split: true })
|
||||||
|
.then(() => {
|
||||||
|
if (message.channel.type === 'dm') return;
|
||||||
|
message.reply('I\'ve sent you a DM with all my commands!');
|
||||||
|
})
|
||||||
|
.catch(error => {
|
||||||
|
console.error(`Could not send help DM to ${message.author.tag}.\n`, error);
|
||||||
|
message.reply('it seems like I can\'t DM you!');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
const name = args[0].toLowerCase();
|
||||||
|
const command = commands.get(name) || commands.find(c => c.aliases && c.aliases.includes(name));
|
||||||
|
|
||||||
|
if (!command) {
|
||||||
|
return message.reply('that\'s not a valid command!');
|
||||||
|
}
|
||||||
|
|
||||||
|
data.push(`**Name:** ${command.name}`);
|
||||||
|
|
||||||
|
if (command.aliases) data.push(`**Aliases:** ${command.aliases.join(', ')}`);
|
||||||
|
if (command.description) data.push(`**Description:** ${command.description}`);
|
||||||
|
if (command.usage) data.push(`**Usage:** ${prefix}${command.name} ${command.usage}`);
|
||||||
|
|
||||||
|
data.push(`**Cooldown:** ${command.cooldown || 3} second(s)`);
|
||||||
|
|
||||||
|
message.channel.send(data, { split: true });
|
||||||
|
},
|
||||||
|
};
|
@ -1,20 +0,0 @@
|
|||||||
exports.run = (client, message, [mention, ...reason]) => {
|
|
||||||
const StaffRole = message.guild.roles.find("name", "Staff");
|
|
||||||
if (!StaffRole)
|
|
||||||
return console.log("The Staff role does not exist");
|
|
||||||
|
|
||||||
if (!message.member.roles.has(StaffRole.id))
|
|
||||||
return message.reply("Sick you thought");
|
|
||||||
|
|
||||||
if (message.mentions.members.size === 0)
|
|
||||||
return message.reply("Please mention a user to kick");
|
|
||||||
|
|
||||||
if (!message.guild.me.hasPermission("KICK_MEMBERS"))
|
|
||||||
return message.reply("");
|
|
||||||
|
|
||||||
const kickMember = message.mentions.members.first();
|
|
||||||
|
|
||||||
kickMember.kick(reason.join(" ")).then(member => {
|
|
||||||
message.reply(`${member.user.username} was succesfully kicked.`);
|
|
||||||
});
|
|
||||||
};
|
|
@ -1,3 +1,7 @@
|
|||||||
exports.run = (client, message, args) => {
|
module.exports = {
|
||||||
message.channel.send("pong!").catch(console.error);
|
name: 'ping',
|
||||||
}
|
description: 'Ping!',
|
||||||
|
execute(message) {
|
||||||
|
message.channel.send('Pong.');
|
||||||
|
},
|
||||||
|
};
|
||||||
|
@ -0,0 +1,18 @@
|
|||||||
|
module.exports = {
|
||||||
|
name: 'prune',
|
||||||
|
description: 'Bulk delete messages',
|
||||||
|
execute(message, args) {
|
||||||
|
const amount = parseInt(args[0]) + 1;
|
||||||
|
|
||||||
|
if (isNaN(amount)) {
|
||||||
|
return message.reply('that dosen\'t seem to be a valid number.');
|
||||||
|
}
|
||||||
|
else if (amount <= 1 || amount > 100) {
|
||||||
|
return message.reply('you need to input a number between 1 and 99.');
|
||||||
|
}
|
||||||
|
message.channel.bulkDelete(amount, true).catch(err => {
|
||||||
|
console.error(err);
|
||||||
|
message.channel.send('there was an error trying to prune messages in this channel!');
|
||||||
|
});
|
||||||
|
},
|
||||||
|
};
|
@ -1,15 +0,0 @@
|
|||||||
exports.run = (client, message, args) => {
|
|
||||||
const user = message.mentions.users.first();
|
|
||||||
const amount = !!parseInt(message.content.split(' ')[1]) ? parseInt(message.content.split(' ')[1]) : parseInt(message.content.split(' ')[2])
|
|
||||||
if (!amount) return message.reply('Must specify an amount to delete!');
|
|
||||||
if (!amount && !user) return message.reply('Must specify a user and amount, or just an amount, of messages to purge!');
|
|
||||||
message.channel.fetchMessages({
|
|
||||||
limit: 100,
|
|
||||||
}).then((messages) => {
|
|
||||||
if (user) {
|
|
||||||
const filterBy = user ? user.id : Client.user.id;
|
|
||||||
messages = messages.filter(m => m.author.id === filterBy).array().slice(0, amount);
|
|
||||||
}
|
|
||||||
message.channel.bulkDelete(messages).catch(error => console.log(error.stack));
|
|
||||||
});
|
|
||||||
};
|
|
@ -1,17 +0,0 @@
|
|||||||
exports.run = (client, message, args) => {
|
|
||||||
if (message.author.id == "267065637183029248") {
|
|
||||||
if(!args || args.size < 1) return message.reply("Must provide a command name to reload.");
|
|
||||||
const commandName = args[0];
|
|
||||||
|
|
||||||
if(!client.commands.has(commandName)) {
|
|
||||||
return message.reply("That command does not exist");
|
|
||||||
}
|
|
||||||
|
|
||||||
delete require.cache[require.resolve(`./${commandName}.js`)];
|
|
||||||
|
|
||||||
client.commands.delete(commandName);
|
|
||||||
const props = require(`./${commandName}.js`);
|
|
||||||
client.commands.set(commandName, props);
|
|
||||||
message.reply(`The command ${commandName} has been reloaded`);
|
|
||||||
};
|
|
||||||
}
|
|
@ -0,0 +1,8 @@
|
|||||||
|
module.exports = {
|
||||||
|
name: 'server',
|
||||||
|
description: 'Send some informations about the server',
|
||||||
|
guildOnly: true,
|
||||||
|
execute(message) {
|
||||||
|
message.channel.send(`This server's name is: ${message.guild.name}\nTotal members: ${message.guild.memberCount}`);
|
||||||
|
},
|
||||||
|
};
|
@ -0,0 +1,7 @@
|
|||||||
|
module.exports = {
|
||||||
|
name: 'user-info',
|
||||||
|
description: 'Send some information about the user',
|
||||||
|
execute(message) {
|
||||||
|
message.channel.send(`Your username: ${message.author.username}\nYour ID: ${message.author.id}`);
|
||||||
|
},
|
||||||
|
};
|
@ -1,3 +0,0 @@
|
|||||||
exports.run = (client, message, args) => {
|
|
||||||
message.channel.send("haha yes").catch(console.error);
|
|
||||||
}
|
|
@ -1,14 +0,0 @@
|
|||||||
module.exports = (client, message) => {
|
|
||||||
if (message.author.bot) return;
|
|
||||||
|
|
||||||
if (message.content.indexOf(client.config.prefix) !== 0) return;
|
|
||||||
|
|
||||||
const args = message.content.slice(client.config.prefix.length).trim().split(/ +/g);
|
|
||||||
const command = args.shift().toLowerCase();
|
|
||||||
|
|
||||||
const cmd = client.commands.get(command);
|
|
||||||
|
|
||||||
if (!cmd) return;
|
|
||||||
|
|
||||||
cmd.run(client, message, args);
|
|
||||||
};
|
|
@ -1,3 +0,0 @@
|
|||||||
module.exports = (client) => {
|
|
||||||
console.log(`Ready to server in ${client.channels.size} channels on ${client.guilds.size} servers, for a total of ${client.users.size} users.`);
|
|
||||||
};
|
|
@ -1,39 +0,0 @@
|
|||||||
const Discord = require("discord.js");
|
|
||||||
const Enmap = require("enmap");
|
|
||||||
const fs = require("fs");
|
|
||||||
|
|
||||||
const client = new Discord.Client();
|
|
||||||
const config = require("./config.json");
|
|
||||||
const responseObject = require("./reply.json");
|
|
||||||
|
|
||||||
client.config = config;
|
|
||||||
|
|
||||||
fs.readdir("./events/", (err, files) => {
|
|
||||||
if (err) return console.error(err);
|
|
||||||
files.forEach(file => {
|
|
||||||
const event = require(`./events/${file}`);
|
|
||||||
let eventName = file.split(".")[0];
|
|
||||||
client.on(eventName, event.bind(null, client));
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
client.commands = new Enmap();
|
|
||||||
|
|
||||||
fs.readdir("./commands/", (err, files) => {
|
|
||||||
if (err) return console.error(err);
|
|
||||||
files.forEach(file => {
|
|
||||||
if (!file.endsWith(".js")) return;
|
|
||||||
let props = require(`./commands/${file}`);
|
|
||||||
let commandName = file.split(".")[0];
|
|
||||||
console.log(`Attempting to load command ${commandName}`);
|
|
||||||
client.commands.set(commandName, props);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
client.on("message", (message) => {
|
|
||||||
if(responseObject[message.content]) {
|
|
||||||
message.channel.send(responseObject[message.content]);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
client.login(config.token);
|
|
@ -0,0 +1,83 @@
|
|||||||
|
const fs = require('fs');
|
||||||
|
const Discord = require('discord.js');
|
||||||
|
const { prefix, token } = require('./config.json');
|
||||||
|
|
||||||
|
const client = new Discord.Client();
|
||||||
|
client.commands = new Discord.Collection();
|
||||||
|
const commandFiles = fs.readdirSync('./commands').filter(file => file.endsWith('.js'));
|
||||||
|
|
||||||
|
for (const file of commandFiles) {
|
||||||
|
const command = require(`./commands/${file}`);
|
||||||
|
client.commands.set(command.name, command);
|
||||||
|
}
|
||||||
|
|
||||||
|
const cooldowns = new Discord.Collection();
|
||||||
|
|
||||||
|
// Ready
|
||||||
|
|
||||||
|
client.on('ready', () => {
|
||||||
|
console.log('Ready!');
|
||||||
|
});
|
||||||
|
|
||||||
|
client.on('message', message => {
|
||||||
|
if (!message.content.startsWith(prefix) || message.author.bot) return;
|
||||||
|
|
||||||
|
const args = message.content.slice(prefix.length).split(/ +/);
|
||||||
|
const commandName = args.shift().toLowerCase();
|
||||||
|
|
||||||
|
if (!client.commands.has(commandName)) return;
|
||||||
|
|
||||||
|
const command = client.commands.get(commandName)
|
||||||
|
|| client.commands.find(cmd => cmd.aliases && cmd.aliases.includes(commandName));
|
||||||
|
|
||||||
|
if (!command) return;
|
||||||
|
|
||||||
|
if (command.guildOnly && message.channel.type !== 'text') {
|
||||||
|
return message.reply('I can\'t execute that command inside DMs!');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (command.args && !args.length) {
|
||||||
|
let reply = `You didin't provide any arguments, ${message.author}!`;
|
||||||
|
|
||||||
|
if (command.usage) {
|
||||||
|
reply += `\nThe proper usage would be: \`${prefix}${command.name} ${command.usage}\``;
|
||||||
|
}
|
||||||
|
|
||||||
|
return message.channel.send(reply);
|
||||||
|
}
|
||||||
|
// Cooldown
|
||||||
|
|
||||||
|
if (!cooldowns.has(command.name)) {
|
||||||
|
cooldowns.set(command.name, new Discord.Collection());
|
||||||
|
}
|
||||||
|
|
||||||
|
const now = Date.now();
|
||||||
|
const timestamps = cooldowns.get(command.name);
|
||||||
|
const cooldownAmount = (command.cooldown || 1) * 1000;
|
||||||
|
|
||||||
|
if (!timestamps.has(message.author.id)) {
|
||||||
|
timestamps.set(message.author.id, now);
|
||||||
|
setTimeout(() => timestamps.delete(message.author.id), cooldownAmount);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
const expirationTime = timestamps.get(message.author.id) + cooldownAmount;
|
||||||
|
|
||||||
|
if (now < expirationTime) {
|
||||||
|
const timeLeft = (expirationTime - now) / 1000;
|
||||||
|
return message.reply(`please wait ${timeLeft.toFixed(1)} more second(s) before reusing the \`${command.name}\` command.`);
|
||||||
|
}
|
||||||
|
|
||||||
|
timestamps.set(message.author.id, now);
|
||||||
|
setTimeout(() => timestamps.delete(message.author.id), cooldownAmount);
|
||||||
|
}
|
||||||
|
// Error
|
||||||
|
try {
|
||||||
|
command.execute(message, args);
|
||||||
|
}
|
||||||
|
catch (error) {
|
||||||
|
console.error(error);
|
||||||
|
message.reply('there was an error trying to execute that command!');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
client.login(token);
|
@ -0,0 +1,27 @@
|
|||||||
|
const { CommandoClient } = require('discord.js-commando');
|
||||||
|
const path = require('path');
|
||||||
|
const { token } = require('./config.json');
|
||||||
|
|
||||||
|
const client = new CommandoClient({
|
||||||
|
commandPrefix: 'haha ',
|
||||||
|
owner: '267065637183029248',
|
||||||
|
invite: 'https://discord.gg/bRCvFy9',
|
||||||
|
});
|
||||||
|
|
||||||
|
client.registry
|
||||||
|
.registerDefaultTypes()
|
||||||
|
.registerGroups([
|
||||||
|
['first', 'Your First Command Group'],
|
||||||
|
])
|
||||||
|
.registerDefaultGroups()
|
||||||
|
.registerDefaultCommands()
|
||||||
|
.registerCommandsIn(path.join(__dirname, 'commands'));
|
||||||
|
|
||||||
|
client.on('ready', () => {
|
||||||
|
console.log(`Logged in as ${client.user.tag}! (${client.user.id})`);
|
||||||
|
client.user.setActivity('with Commando');
|
||||||
|
});
|
||||||
|
|
||||||
|
client.on('error', console.error);
|
||||||
|
|
||||||
|
client.login(token);
|
@ -1,156 +0,0 @@
|
|||||||
{
|
|
||||||
"extends": "eslint:recommended",
|
|
||||||
"env": {
|
|
||||||
"node": true,
|
|
||||||
"es6": true
|
|
||||||
},
|
|
||||||
"parserOptions": {
|
|
||||||
"ecmaVersion": 2017
|
|
||||||
},
|
|
||||||
"rules": {
|
|
||||||
"no-extra-parens": ["warn", "all", {
|
|
||||||
"nestedBinaryExpressions": false
|
|
||||||
}],
|
|
||||||
"valid-jsdoc": ["warn", {
|
|
||||||
"requireReturn": false,
|
|
||||||
"requireReturnDescription": false,
|
|
||||||
"preferType": {
|
|
||||||
"String": "string",
|
|
||||||
"Number": "number",
|
|
||||||
"Boolean": "boolean",
|
|
||||||
"Symbol": "symbol",
|
|
||||||
"function": "Function",
|
|
||||||
"object": "Object",
|
|
||||||
"date": "Date",
|
|
||||||
"error": "Error"
|
|
||||||
}
|
|
||||||
}],
|
|
||||||
|
|
||||||
"accessor-pairs": "warn",
|
|
||||||
"array-callback-return": "error",
|
|
||||||
"complexity": "off",
|
|
||||||
"consistent-return": "error",
|
|
||||||
"curly": ["error", "multi-line", "consistent"],
|
|
||||||
"dot-location": ["error", "property"],
|
|
||||||
"dot-notation": "error",
|
|
||||||
"eqeqeq": "off",
|
|
||||||
"no-console": ["error", { "allow": ["log", "warn", "error"] }],
|
|
||||||
"no-empty-function": "error",
|
|
||||||
"no-floating-decimal": "error",
|
|
||||||
"no-implied-eval": "error",
|
|
||||||
"no-invalid-this": "error",
|
|
||||||
"no-lone-blocks": "error",
|
|
||||||
"no-multi-spaces": "error",
|
|
||||||
"no-new-func": "error",
|
|
||||||
"no-new-wrappers": "error",
|
|
||||||
"no-new": "error",
|
|
||||||
"no-octal-escape": "error",
|
|
||||||
"no-return-assign": "error",
|
|
||||||
"no-self-compare": "error",
|
|
||||||
"no-sequences": "error",
|
|
||||||
"no-unmodified-loop-condition": "error",
|
|
||||||
"no-unused-expressions": "error",
|
|
||||||
"no-useless-call": "error",
|
|
||||||
"no-useless-concat": "error",
|
|
||||||
"no-useless-escape": "error",
|
|
||||||
"no-void": "error",
|
|
||||||
"no-warning-comments": "warn",
|
|
||||||
"wrap-iife": "error",
|
|
||||||
"yoda": "error",
|
|
||||||
|
|
||||||
"no-label-var": "error",
|
|
||||||
"no-shadow": "error",
|
|
||||||
"no-undef-init": "error",
|
|
||||||
|
|
||||||
"callback-return": "error",
|
|
||||||
"handle-callback-err": "error",
|
|
||||||
"no-mixed-requires": "error",
|
|
||||||
"no-new-require": "error",
|
|
||||||
"no-path-concat": "error",
|
|
||||||
"no-process-env": "error",
|
|
||||||
|
|
||||||
"array-bracket-spacing": "error",
|
|
||||||
"block-spacing": "error",
|
|
||||||
"brace-style": ["error", "1tbs", { "allowSingleLine": true }],
|
|
||||||
"camelcase": "error",
|
|
||||||
"comma-dangle": "error",
|
|
||||||
"comma-spacing": "error",
|
|
||||||
"comma-style": "error",
|
|
||||||
"computed-property-spacing": "error",
|
|
||||||
"consistent-this": "error",
|
|
||||||
"eol-last": "error",
|
|
||||||
"func-names": "error",
|
|
||||||
"func-style": ["error", "declaration", { "allowArrowFunctions": true }],
|
|
||||||
"id-length": ["error", { "exceptions": ["i", "j", "a", "b", "_"] }],
|
|
||||||
"indent": ["error", 2],
|
|
||||||
"key-spacing": "error",
|
|
||||||
"keyword-spacing": ["error", {
|
|
||||||
"overrides": {
|
|
||||||
"if": { "after": true },
|
|
||||||
"for": { "after": true },
|
|
||||||
"while": { "after": true },
|
|
||||||
"catch": { "after": true },
|
|
||||||
"switch": { "after": true }
|
|
||||||
}
|
|
||||||
}],
|
|
||||||
"max-depth": "error",
|
|
||||||
"max-len": ["error", 200, 2],
|
|
||||||
"max-nested-callbacks": ["error", { "max": 4 }],
|
|
||||||
"max-statements-per-line": ["error", { "max": 2 }],
|
|
||||||
"new-cap": "error",
|
|
||||||
"newline-per-chained-call": ["error", { "ignoreChainWithDepth": 6 }],
|
|
||||||
"no-array-constructor": "error",
|
|
||||||
"no-bitwise": "warn",
|
|
||||||
"no-inline-comments": "error",
|
|
||||||
"no-lonely-if": "error",
|
|
||||||
"no-mixed-operators": "error",
|
|
||||||
"no-multiple-empty-lines": ["error", { "max": 2, "maxEOF": 1, "maxBOF": 0 }],
|
|
||||||
"no-new-object": "error",
|
|
||||||
"no-spaced-func": "error",
|
|
||||||
"no-trailing-spaces": "error",
|
|
||||||
"no-unneeded-ternary": "error",
|
|
||||||
"no-whitespace-before-property": "error",
|
|
||||||
"object-curly-newline": "error",
|
|
||||||
"object-curly-spacing": ["error", "always"],
|
|
||||||
"operator-assignment": "error",
|
|
||||||
"operator-linebreak": ["error", "after"],
|
|
||||||
"padded-blocks": ["error", { "classes": "always", "blocks": "never", "switches": "never" }],
|
|
||||||
"quote-props": ["error", "as-needed"],
|
|
||||||
"quotes": ["error", "single", { "avoidEscape": true, "allowTemplateLiterals": true }],
|
|
||||||
"semi-spacing": "error",
|
|
||||||
"semi": "error",
|
|
||||||
"space-before-blocks": "error",
|
|
||||||
"space-before-function-paren": ["error", {"anonymous": "always", "named": "never", "asyncArrow": "always"}],
|
|
||||||
"space-in-parens": "error",
|
|
||||||
"space-infix-ops": "error",
|
|
||||||
"space-unary-ops": "error",
|
|
||||||
"spaced-comment": "error",
|
|
||||||
"unicode-bom": "error",
|
|
||||||
|
|
||||||
"arrow-body-style": "error",
|
|
||||||
"arrow-spacing": "error",
|
|
||||||
"no-duplicate-imports": "error",
|
|
||||||
"no-useless-computed-key": "error",
|
|
||||||
"no-useless-constructor": "error",
|
|
||||||
"prefer-arrow-callback": "error",
|
|
||||||
"prefer-const": "error",
|
|
||||||
"prefer-destructuring": ["error", {
|
|
||||||
"VariableDeclarator": {
|
|
||||||
"array": false,
|
|
||||||
"object": true
|
|
||||||
},
|
|
||||||
"AssignmentExpression": {
|
|
||||||
"array": true,
|
|
||||||
"object": true
|
|
||||||
}
|
|
||||||
}, {
|
|
||||||
"enforceForRenamedProperties": false
|
|
||||||
}],
|
|
||||||
"prefer-rest-params": "error",
|
|
||||||
"prefer-spread": "error",
|
|
||||||
"prefer-template": "error",
|
|
||||||
"rest-spread-spacing": "error",
|
|
||||||
"template-curly-spacing": "error",
|
|
||||||
"yield-star-spacing": "error"
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,208 +0,0 @@
|
|||||||
Apache License
|
|
||||||
Version 2.0, January 2004
|
|
||||||
http://www.apache.org/licenses/
|
|
||||||
|
|
||||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
||||||
|
|
||||||
1. Definitions.
|
|
||||||
|
|
||||||
"License" shall mean the terms and conditions for use, reproduction,
|
|
||||||
and distribution as defined by Sections 1 through 9 of this document.
|
|
||||||
|
|
||||||
"Licensor" shall mean the copyright owner or entity authorized by
|
|
||||||
the copyright owner that is granting the License.
|
|
||||||
|
|
||||||
"Legal Entity" shall mean the union of the acting entity and all
|
|
||||||
other entities that control, are controlled by, or are under common
|
|
||||||
control with that entity. For the purposes of this definition,
|
|
||||||
"control" means (i) the power, direct or indirect, to cause the
|
|
||||||
direction or management of such entity, whether by contract or
|
|
||||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
||||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
||||||
|
|
||||||
"You" (or "Your") shall mean an individual or Legal Entity
|
|
||||||
exercising permissions granted by this License.
|
|
||||||
|
|
||||||
"Source" form shall mean the preferred form for making modifications,
|
|
||||||
including but not limited to software source code, documentation
|
|
||||||
source, and configuration files.
|
|
||||||
|
|
||||||
"Object" form shall mean any form resulting from mechanical
|
|
||||||
transformation or translation of a Source form, including but
|
|
||||||
not limited to compiled object code, generated documentation,
|
|
||||||
and conversions to other media types.
|
|
||||||
|
|
||||||
"Work" shall mean the work of authorship, whether in Source or
|
|
||||||
Object form, made available under the License, as indicated by a
|
|
||||||
copyright notice that is included in or attached to the work
|
|
||||||
(an example is provided in the Appendix below).
|
|
||||||
|
|
||||||
"Derivative Works" shall mean any work, whether in Source or Object
|
|
||||||
form, that is based on (or derived from) the Work and for which the
|
|
||||||
editorial revisions, annotations, elaborations, or other modifications
|
|
||||||
represent, as a whole, an original work of authorship. For the purposes
|
|
||||||
of this License, Derivative Works shall not include works that remain
|
|
||||||
separable from, or merely link (or bind by name) to the interfaces of,
|
|
||||||
the Work and Derivative Works thereof.
|
|
||||||
|
|
||||||
"Contribution" shall mean any work of authorship, including
|
|
||||||
the original version of the Work and any modifications or additions
|
|
||||||
to that Work or Derivative Works thereof, that is intentionally
|
|
||||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
||||||
or by an individual or Legal Entity authorized to submit on behalf of
|
|
||||||
the copyright owner. For the purposes of this definition, "submitted"
|
|
||||||
means any form of electronic, verbal, or written communication sent
|
|
||||||
to the Licensor or its representatives, including but not limited to
|
|
||||||
communication on electronic mailing lists, source code control systems,
|
|
||||||
and issue tracking systems that are managed by, or on behalf of, the
|
|
||||||
Licensor for the purpose of discussing and improving the Work, but
|
|
||||||
excluding communication that is conspicuously marked or otherwise
|
|
||||||
designated in writing by the copyright owner as "Not a Contribution."
|
|
||||||
|
|
||||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
||||||
on behalf of whom a Contribution has been received by Licensor and
|
|
||||||
subsequently incorporated within the Work.
|
|
||||||
|
|
||||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
||||||
this License, each Contributor hereby grants to You a perpetual,
|
|
||||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
||||||
copyright license to reproduce, prepare Derivative Works of,
|
|
||||||
publicly display, publicly perform, sublicense, and distribute the
|
|
||||||
Work and such Derivative Works in Source or Object form.
|
|
||||||
|
|
||||||
3. Grant of Patent License. Subject to the terms and conditions of
|
|
||||||
this License, each Contributor hereby grants to You a perpetual,
|
|
||||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
||||||
(except as stated in this section) patent license to make, have made,
|
|
||||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
||||||
where such license applies only to those patent claims licensable
|
|
||||||
by such Contributor that are necessarily infringed by their
|
|
||||||
Contribution(s) alone or by combination of their Contribution(s)
|
|
||||||
with the Work to which such Contribution(s) was submitted. If You
|
|
||||||
institute patent litigation against any entity (including a
|
|
||||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
||||||
or a Contribution incorporated within the Work constitutes direct
|
|
||||||
or contributory patent infringement, then any patent licenses
|
|
||||||
granted to You under this License for that Work shall terminate
|
|
||||||
as of the date such litigation is filed.
|
|
||||||
|
|
||||||
4. Redistribution. You may reproduce and distribute copies of the
|
|
||||||
Work or Derivative Works thereof in any medium, with or without
|
|
||||||
modifications, and in Source or Object form, provided that You
|
|
||||||
meet the following conditions:
|
|
||||||
|
|
||||||
(a) You must give any other recipients of the Work or
|
|
||||||
Derivative Works a copy of this License; and
|
|
||||||
|
|
||||||
(b) You must cause any modified files to carry prominent notices
|
|
||||||
stating that You changed the files; and
|
|
||||||
|
|
||||||
(c) You must retain, in the Source form of any Derivative Works
|
|
||||||
that You distribute, all copyright, patent, trademark, and
|
|
||||||
attribution notices from the Source form of the Work,
|
|
||||||
excluding those notices that do not pertain to any part of
|
|
||||||
the Derivative Works; and
|
|
||||||
|
|
||||||
(d) If the Work includes a "NOTICE" text file as part of its
|
|
||||||
distribution, then any Derivative Works that You distribute must
|
|
||||||
include a readable copy of the attribution notices contained
|
|
||||||
within such NOTICE file, excluding those notices that do not
|
|
||||||
pertain to any part of the Derivative Works, in at least one
|
|
||||||
of the following places: within a NOTICE text file distributed
|
|
||||||
as part of the Derivative Works; within the Source form or
|
|
||||||
documentation, if provided along with the Derivative Works; or,
|
|
||||||
within a display generated by the Derivative Works, if and
|
|
||||||
wherever such third-party notices normally appear. The contents
|
|
||||||
of the NOTICE file are for informational purposes only and
|
|
||||||
do not modify the License. You may add Your own attribution
|
|
||||||
notices within Derivative Works that You distribute, alongside
|
|
||||||
or as an addendum to the NOTICE text from the Work, provided
|
|
||||||
that such additional attribution notices cannot be construed
|
|
||||||
as modifying the License.
|
|
||||||
|
|
||||||
You may add Your own copyright statement to Your modifications and
|
|
||||||
may provide additional or different license terms and conditions
|
|
||||||
for use, reproduction, or distribution of Your modifications, or
|
|
||||||
for any such Derivative Works as a whole, provided Your use,
|
|
||||||
reproduction, and distribution of the Work otherwise complies with
|
|
||||||
the conditions stated in this License.
|
|
||||||
|
|
||||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
||||||
any Contribution intentionally submitted for inclusion in the Work
|
|
||||||
by You to the Licensor shall be under the terms and conditions of
|
|
||||||
this License, without any additional terms or conditions.
|
|
||||||
Notwithstanding the above, nothing herein shall supersede or modify
|
|
||||||
the terms of any separate license agreement you may have executed
|
|
||||||
with Licensor regarding such Contributions.
|
|
||||||
|
|
||||||
6. Trademarks. This License does not grant permission to use the trade
|
|
||||||
names, trademarks, service marks, or product names of the Licensor,
|
|
||||||
except as required for reasonable and customary use in describing the
|
|
||||||
origin of the Work and reproducing the content of the NOTICE file.
|
|
||||||
|
|
||||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
||||||
agreed to in writing, Licensor provides the Work (and each
|
|
||||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
||||||
implied, including, without limitation, any warranties or conditions
|
|
||||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
||||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
||||||
appropriateness of using or redistributing the Work and assume any
|
|
||||||
risks associated with Your exercise of permissions under this License.
|
|
||||||
|
|
||||||
8. Limitation of Liability. In no event and under no legal theory,
|
|
||||||
whether in tort (including negligence), contract, or otherwise,
|
|
||||||
unless required by applicable law (such as deliberate and grossly
|
|
||||||
negligent acts) or agreed to in writing, shall any Contributor be
|
|
||||||
liable to You for damages, including any direct, indirect, special,
|
|
||||||
incidental, or consequential damages of any character arising as a
|
|
||||||
result of this License or out of the use or inability to use the
|
|
||||||
Work (including but not limited to damages for loss of goodwill,
|
|
||||||
work stoppage, computer failure or malfunction, or any and all
|
|
||||||
other commercial damages or losses), even if such Contributor
|
|
||||||
has been advised of the possibility of such damages.
|
|
||||||
|
|
||||||
9. Accepting Warranty or Additional Liability. While redistributing
|
|
||||||
the Work or Derivative Works thereof, You may choose to offer,
|
|
||||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
||||||
or other liability obligations and/or rights consistent with this
|
|
||||||
License. However, in accepting such obligations, You may act only
|
|
||||||
on Your own behalf and on Your sole responsibility, not on behalf
|
|
||||||
of any other Contributor, and only if You agree to indemnify,
|
|
||||||
defend, and hold each Contributor harmless for any liability
|
|
||||||
incurred by, or claims asserted against, such Contributor by reason
|
|
||||||
of your accepting any such warranty or additional liability.
|
|
||||||
|
|
||||||
END OF TERMS AND CONDITIONS
|
|
||||||
|
|
||||||
APPENDIX: How to apply the Apache License to your work.
|
|
||||||
|
|
||||||
To apply the Apache License to your work, attach the following
|
|
||||||
boilerplate notice, with the fields enclosed by brackets "{}"
|
|
||||||
replaced with your own identifying information. (Don't include
|
|
||||||
the brackets!) The text should be enclosed in the appropriate
|
|
||||||
comment syntax for the file format. We also recommend that a
|
|
||||||
file or class name and description of purpose be included on the
|
|
||||||
same "printed page" as the copyright notice for easier
|
|
||||||
identification within third-party archives.
|
|
||||||
|
|
||||||
APPENDIX: Code from other projects
|
|
||||||
This project contains partial code from Discord.js version 10.
|
|
||||||
Project Link: https://github.com/discordjs/discord.js
|
|
||||||
Author: Amish Shaw (hydrabolt)
|
|
||||||
License: https://github.com/discordjs/discord.js/blob/master/LICENSE
|
|
||||||
|
|
||||||
|
|
||||||
Copyright 2018 Évelyne Lachance <eslachance@gmail.com>
|
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
you may not use this file except in compliance with the License.
|
|
||||||
You may obtain a copy of the License at
|
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
See the License for the specific language governing permissions and
|
|
||||||
limitations under the License.
|
|
@ -1,48 +0,0 @@
|
|||||||
# Enmap - Enhanced Maps
|
|
||||||
|
|
||||||
Enhanced Maps are a data structure that can be used to store data in memory that can also be saved in a database behind the scenes. These operations are fast, safe, and painless.
|
|
||||||
|
|
||||||
The data is synchronized to the database automatically, seamlessly, and asynchronously for maximum effectiveness. The storage system used is an `sqlite` database which is fast,
|
|
||||||
performant, can be easily backed up, and supports multiple simultaneous connections.
|
|
||||||
|
|
||||||
## Documentation
|
|
||||||
|
|
||||||
* [Installation](https://evie.gitbook.io/enmap/install)
|
|
||||||
* [Basic Setup](https://evie.gitbook.io/enmap/usage)
|
|
||||||
* [API Reference](https://evie.gitbook.io/enmap/api)
|
|
||||||
* [Examples](https://evie.gitbook.io/enmap/examples)
|
|
||||||
|
|
||||||
## Support
|
|
||||||
|
|
||||||
Support is offered on my official [Evie.Codes Discord](https://discord.gg/N7ZKH3P).
|
|
||||||
|
|
||||||
## FAQs
|
|
||||||
|
|
||||||
### Q: So what's Enmap
|
|
||||||
|
|
||||||
**A**: Enmaps are the Javascript Map() data structure with additional utility methods. This started
|
|
||||||
as a pretty straight clone of the [Discord.js Collections](https://discord.js.org/#/docs/main/stable/class/Collection)
|
|
||||||
but since its creation has grown far beyond those methods alone.
|
|
||||||
|
|
||||||
### Q: What is "Persistent"?
|
|
||||||
|
|
||||||
**A**: With the use of the optional providers modules, any data added to the Enmap
|
|
||||||
is stored not only in temporary memory but also backed up in a local database. This means that
|
|
||||||
when you restart your project, your data is not lost and is loaded on startup.
|
|
||||||
|
|
||||||
### Q: How big can the Enmap be?
|
|
||||||
|
|
||||||
**A**: The size of the memory used is directly proportional to the size of all the keys loaded in memory.
|
|
||||||
The more data you have, the more complex it is, the more memory it can use. You can use the
|
|
||||||
[fetchAll](https://evie.gitbook.io/enmap/usage/fetchall) options to reduce memory usage.
|
|
||||||
|
|
||||||
### Q: Who did you make this for?
|
|
||||||
|
|
||||||
**A**: Well, myself because I do use it often. But also, I built it specifically for beginners in mind.
|
|
||||||
Enmap's main goal is to remain simple to use, as fast as possible, and a solid as possible.
|
|
||||||
|
|
||||||
### Q: What's is used for?
|
|
||||||
|
|
||||||
**A**: Enmap is useful for storing very simple key/value data for easy retrieval, and also for more complex objects with many properties.
|
|
||||||
Mainly, because of who I originally made this for, it's used in Discord.js Bots to save currencies, content blocks, server settings, and
|
|
||||||
user information for bans, blacklists, timers, warning systems, etc.
|
|
@ -1,338 +0,0 @@
|
|||||||
declare module 'enmap' {
|
|
||||||
/**
|
|
||||||
* A enhanced Map structure with additional utility methods.
|
|
||||||
* Can be made persistent
|
|
||||||
* @extends {Map}
|
|
||||||
*/
|
|
||||||
export = Enmap;
|
|
||||||
|
|
||||||
type PropOrFun = (val: any, key: string | number, thisArg: Enmap) => any;
|
|
||||||
type filterFunc = (val: any, key: string | number, thisArg: Enmap) => boolean;
|
|
||||||
type someFunc = (val: any, key: string | number, thisArg: Enmap) => boolean;
|
|
||||||
type everyFunc = (val: any, key: string | number, thisArg: Enmap) => boolean;
|
|
||||||
type mapFunc = (val: any, key: string | number, thisArg: Enmap) => any;
|
|
||||||
type reduceFunc = (
|
|
||||||
accumulator: any,
|
|
||||||
currentValue: any,
|
|
||||||
currentKey: string | number,
|
|
||||||
thisArg: Enmap
|
|
||||||
) => any;
|
|
||||||
|
|
||||||
class Enmap extends Map {
|
|
||||||
/**
|
|
||||||
* Initialize multiple Enmaps easily.
|
|
||||||
* @param {Array<string>} names Array of strings. Each array entry will create a separate enmap with that name.
|
|
||||||
* @param {EnmapProvider} Provider Valid EnmapProvider object.
|
|
||||||
* @param {Object} options Options object to pass to the provider. See provider documentation for its options.
|
|
||||||
* @returns {Array<Map>} An array of initialized Enmaps.
|
|
||||||
*/
|
|
||||||
public static multi(names: string[], Provider: any, options?: any): Enmap[];
|
|
||||||
|
|
||||||
public fetchAll: boolean;
|
|
||||||
|
|
||||||
private db: object;
|
|
||||||
private defer: boolean;
|
|
||||||
private persistent: boolean;
|
|
||||||
|
|
||||||
constructor(iterable?: Iterable<any> | { provider: any }, options?: any);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Shuts down the underlying persistent enmap database.
|
|
||||||
*/
|
|
||||||
public close(): void;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Retrieves a key from the enmap. If fetchAll is false, returns a promise.
|
|
||||||
* @param {string|number} key The key to retrieve from the enmap.
|
|
||||||
* @return {*|Promise<*>} The value or a promise containing the value.
|
|
||||||
*/
|
|
||||||
public get(key: string | number): any | Promise<any>;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Force fetch one or more key values from the enmap. If the database has changed, that new value is used.
|
|
||||||
* @param {string|number} keyOrKeys A single key or array of keys to force fetch from the enmap database.
|
|
||||||
* @return {*|Map} A single value if requested, or a non-persistent enmap of keys if an array is requested.
|
|
||||||
*/
|
|
||||||
public fetch(
|
|
||||||
keyOrKeys: string | number | Array<string | number>
|
|
||||||
): any | Enmap;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Fetches every key from the persistent enmap and loads them into the current enmap value.
|
|
||||||
* @return {Map} The enmap containing all values.
|
|
||||||
*/
|
|
||||||
public fetchEverything(): this;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set the value in Enmap.
|
|
||||||
* @param {string|number} key Required. The key of the element to add to The Enmap.
|
|
||||||
* If the Enmap is persistent this value MUST be a string or number.
|
|
||||||
* @param {*} val Required. The value of the element to add to The Enmap.
|
|
||||||
* If the Enmap is persistent this value MUST be stringifiable as JSON.
|
|
||||||
* @return {Enmap} The Enmap.
|
|
||||||
*/
|
|
||||||
public set(key: string | number, val: any): this;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set the value in Enmap, but returns a promise that resolves once writte to the database.
|
|
||||||
* Useless on non-persistent Enmaps.
|
|
||||||
* @param {string|number} key Required. The key of the element to add to The Enmap.
|
|
||||||
* If the Enmap is persistent this value MUST be a string or number.
|
|
||||||
* @param {*} val Required. The value of the element to add to The Enmap.
|
|
||||||
* If the Enmap is persistent this value MUST be stringifiable as JSON.
|
|
||||||
* @return {Promise<Map>} The Enmap.
|
|
||||||
*/
|
|
||||||
public setAsync(key: string | number, val: any): Promise<this>;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the specific property within a stored value. If the value isn't an object or array,
|
|
||||||
* returns the unchanged data If the key does not exist or the value is not an object, throws an error.
|
|
||||||
* @param {string|number} key Required. The key of the element to get from The Enmap.
|
|
||||||
* @param {*} prop Required. The property to retrieve from the object or array.
|
|
||||||
* @return {*} The value of the property obtained.
|
|
||||||
*/
|
|
||||||
public getProp(key: string | number, prop: any): any;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Modify the property of a value inside the enmap, if the value is an object or array.
|
|
||||||
* This is a shortcut to loading the key, changing the value, and setting it back.
|
|
||||||
* @param {string|number} key Required. The key of the element to add to The Enmap or array.
|
|
||||||
* This value MUST be a string or number.
|
|
||||||
* @param {*} prop Required. The property to modify inside the value object or array.
|
|
||||||
* @param {*} val Required. The value to apply to the specified property.
|
|
||||||
* @param {boolean} save Optional. Whether to save to persistent DB (used as false in init)
|
|
||||||
* @return {Map} The EnMap.
|
|
||||||
*/
|
|
||||||
public setProp(key: string | number, prop: any, val: any): this;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns whether or not the key exists in the Enmap.
|
|
||||||
* @param {string|number} key Required. The key of the element to add to The Enmap or array.
|
|
||||||
* This value MUST be a string or number.
|
|
||||||
* @returns {Promise<boolean>}
|
|
||||||
*/
|
|
||||||
public has(key: string | number): boolean;
|
|
||||||
public has(key: string | number): Promise<boolean>;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns whether or not the property exists within an object or array value in enmap.
|
|
||||||
* @param {string|number} key Required. The key of the element to check in the Enmap or array.
|
|
||||||
* @param {*} prop Required. The property to verify inside the value object or array.
|
|
||||||
* @return {boolean} Whether the property exists.
|
|
||||||
*/
|
|
||||||
public hasProp(key: string | number, prop: any): boolean;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Delete a property from an object or array value in Enmap.
|
|
||||||
* @param {string|number} key Required. The key of the element to delete the property from in Enmap.
|
|
||||||
* @param {*} prop Required. The name of the property to remove from the object.
|
|
||||||
* @returns {Promise<Enmap>|Enmap} If fetchAll is true, return the Enmap. Otherwise return a promise containing
|
|
||||||
* the Enmap.
|
|
||||||
*/
|
|
||||||
public deleteProp(key: string | number, prop: any): Promise<this> | this;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Deletes a key in the Enmap.
|
|
||||||
* @param {string|number} key Required. The key of the element to delete from The Enmap.
|
|
||||||
* @param {boolean} bulk Internal property used by the purge method.
|
|
||||||
*/
|
|
||||||
public delete(key: string | number): boolean;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @param {string|number} key Required. The key of the element to delete from The Enmap.
|
|
||||||
* @param {boolean} bulk Internal property used by the purge method.
|
|
||||||
*/
|
|
||||||
public deleteAsync(key: string | number): boolean;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates an ordered array of the values of this Enmap, and caches it internally.
|
|
||||||
* The array will only be reconstructed if an item is added to or removed from the Enmap,
|
|
||||||
* or if you change the length of the array itself. If you don't want this caching behaviour,
|
|
||||||
* use `Array.from(enmap.values())` instead.
|
|
||||||
* @returns {Array}
|
|
||||||
*/
|
|
||||||
public array(): any[];
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates an ordered array of the keys of this Enmap, and caches it internally.
|
|
||||||
* The array will only be reconstructed if an item is added to or removed from the Enmap,
|
|
||||||
* or if you change the length of the array itself. If you don't want this caching behaviour,
|
|
||||||
* use `Array.from(enmap.keys())` instead.
|
|
||||||
* @returns {Array}
|
|
||||||
*/
|
|
||||||
public keyArray(): any[];
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Obtains random value(s) from this Enmap. This relies on {@link Enmap#array},
|
|
||||||
* and thus the caching mechanism applies here as well.
|
|
||||||
* @param {number} [count] Number of values to obtain randomly
|
|
||||||
* @returns {*|Array<*>} The single value if `count` is undefined,
|
|
||||||
* or an array of values of `count` length
|
|
||||||
*/
|
|
||||||
public random(count: number): any | any[];
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Obtains random key(s) from this Enmap. This relies on {@link Enmap#keyArray},
|
|
||||||
* and thus the caching mechanism applies here as well.
|
|
||||||
* @param {number} [count] Number of keys to obtain randomly
|
|
||||||
* @returns {*|Array<*>} The single key if `count` is undefined,
|
|
||||||
* or an array of keys of `count` length
|
|
||||||
*/
|
|
||||||
public randomKey(count: number): any | any[];
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Searches for all items where their specified property's value is identical to the given value
|
|
||||||
* (`item[prop] === value`).
|
|
||||||
* @param {string} prop The property to test against
|
|
||||||
* @param {*} value The expected value
|
|
||||||
* @returns {Array}
|
|
||||||
* @example
|
|
||||||
* enmap.findAll('username', 'Bob');
|
|
||||||
*/
|
|
||||||
public findAll(prop: string, value: any): any[];
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Searches for a single item where its specified property's value is identical to the given value
|
|
||||||
* (`item[prop] === value`), or the given function returns a truthy value. In the latter case, this is identical to
|
|
||||||
* [Array.find()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/find).
|
|
||||||
* <warn>All Enmap used in Discord.js are mapped using their `id` property, and if you want to find by id you
|
|
||||||
* should use the `get` method. See
|
|
||||||
* [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/get)
|
|
||||||
* for details.</warn>
|
|
||||||
* @param {string|Function} propOrFn The property to test against, or the function to test with
|
|
||||||
* @param {*} [value] The expected value - only applicable and required if using a property for the first argument
|
|
||||||
* @returns {*}
|
|
||||||
* @example
|
|
||||||
* enmap.find('username', 'Bob');
|
|
||||||
* @example
|
|
||||||
* enmap.find(val => val.username === 'Bob');
|
|
||||||
*/
|
|
||||||
public find(propOrFn: string | PropOrFun, value: any): any;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Searches for the key of a single item where its specified property's value is identical to the given value
|
|
||||||
* (`item[prop] === value`), or the given function returns a truthy value. In the latter case, this is identical to
|
|
||||||
* https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/findIndex
|
|
||||||
* @param {string|Function} propOrFn The property to test against, or the function to test with
|
|
||||||
* @param {*} [value] The expected value - only applicable and required if using a property for the first argument
|
|
||||||
* @returns {*}
|
|
||||||
* @example
|
|
||||||
* enmap.findKey('username', 'Bob');
|
|
||||||
* @example
|
|
||||||
* enmap.findKey(val => val.username === 'Bob');
|
|
||||||
*/
|
|
||||||
public findKey(propOrFn: string | PropOrFun, value: any): any;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Searches for the existence of a single item where its specified property's value is identical to the given value
|
|
||||||
* (`item[prop] === value`).
|
|
||||||
* <warn>Do not use this to check for an item by its ID. Instead, use `enmap.has(id)`. See
|
|
||||||
* [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/has) for details.
|
|
||||||
* </warn>
|
|
||||||
* @param {string} prop The property to test against
|
|
||||||
* @param {*} value The expected value
|
|
||||||
* @returns {boolean}
|
|
||||||
* @example
|
|
||||||
* if (enmap.exists('username', 'Bob')) {
|
|
||||||
* console.log('user here!');
|
|
||||||
* }
|
|
||||||
*/
|
|
||||||
public exists(prop: string, value: any): boolean;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Identical to
|
|
||||||
* [Array.filter()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/filter),
|
|
||||||
* but returns a Enmap instead of an Array.
|
|
||||||
* @param {Function} fn Function used to test (should return a boolean)
|
|
||||||
* @param {Object} [thisArg] Value to use as `this` when executing function
|
|
||||||
* @returns {Enmap}
|
|
||||||
*/
|
|
||||||
public filter(fn: filterFunc, thisArg?: any): Enmap;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Identical to
|
|
||||||
* [Array.filter()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/filter).
|
|
||||||
* @param {Function} fn Function used to test (should return a boolean)
|
|
||||||
* @param {Object} [thisArg] Value to use as `this` when executing function
|
|
||||||
* @returns {Array}
|
|
||||||
*/
|
|
||||||
public filterArray(fn: filterFunc, thisArg?: any): any[];
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Identical to
|
|
||||||
* [Array.map()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map).
|
|
||||||
* @param {Function} fn Function that produces an element of the new array, taking three arguments
|
|
||||||
* @param {*} [thisArg] Value to use as `this` when executing function
|
|
||||||
* @returns {Array}
|
|
||||||
*/
|
|
||||||
public map(fn: mapFunc, thisArg?: any): any[];
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Identical to
|
|
||||||
* [Array.some()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/some).
|
|
||||||
* @param {Function} fn Function used to test (should return a boolean)
|
|
||||||
* @param {Object} [thisArg] Value to use as `this` when executing function
|
|
||||||
* @returns {boolean}
|
|
||||||
*/
|
|
||||||
public some(fn: someFunc, thisArg?: any): any[];
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Identical to
|
|
||||||
* [Array.every()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/every).
|
|
||||||
* @param {Function} fn Function used to test (should return a boolean)
|
|
||||||
* @param {Object} [thisArg] Value to use as `this` when executing function
|
|
||||||
* @returns {boolean}
|
|
||||||
*/
|
|
||||||
public every(fn: everyFunc, thisArg?: any): any[];
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Identical to
|
|
||||||
* [Array.reduce()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/reduce).
|
|
||||||
* @param {Function} fn Function used to reduce, taking four arguments; `accumulator`, `currentValue`, `currentKey`,
|
|
||||||
* and `enmap`
|
|
||||||
* @param {*} [initialValue] Starting value for the accumulator
|
|
||||||
* @returns {*}
|
|
||||||
*/
|
|
||||||
public reduce(fn: reduceFunc, initialValue: any): any[];
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates an identical shallow copy of this Enmap.
|
|
||||||
* @returns {Enmap}
|
|
||||||
* @example const newColl = someColl.clone();
|
|
||||||
*/
|
|
||||||
public clone(): Enmap;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Combines this Enmap with others into a new Enmap. None of the source Enmaps are modified.
|
|
||||||
* @param {...Enmap} enmaps Enmaps to merge
|
|
||||||
* @returns {Enmap}
|
|
||||||
* @example const newColl = someColl.concat(someOtherColl, anotherColl, ohBoyAColl);
|
|
||||||
*/
|
|
||||||
public concat(...enmaps: Enmap[]): Enmap;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Calls the `delete()` method on all items that have it.
|
|
||||||
* @param {boolean} bulk Optional. Defaults to True. whether to use the provider's "bulk" delete feature
|
|
||||||
* if it has one.
|
|
||||||
*/
|
|
||||||
public deleteAll(bulk: boolean): void;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Calls the `delete()` method on all items that have it.
|
|
||||||
* @param {boolean} bulk Optional. Defaults to True. whether to use the provider's "bulk" delete feature
|
|
||||||
* if it has one.
|
|
||||||
* @return {Promise} Returns a promise that is resolved when the database is cleared.
|
|
||||||
*/
|
|
||||||
public deleteAllAsync(bulk: boolean): Promise<any>;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Checks if this Enmap shares identical key-value pairings with another.
|
|
||||||
* This is different to checking for equality using equal-signs, because
|
|
||||||
* the Enmaps may be different objects, but contain the same data.
|
|
||||||
* @param {Enmap} enmap Enmap to compare with
|
|
||||||
* @returns {boolean} Whether the Enmaps have identical contents
|
|
||||||
*/
|
|
||||||
public equals(enmap: Enmap): boolean;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,3 +0,0 @@
|
|||||||
const Enmap = require('./src/index.js');
|
|
||||||
|
|
||||||
module.exports = Enmap;
|
|
@ -1,64 +0,0 @@
|
|||||||
{
|
|
||||||
"_from": "enmap",
|
|
||||||
"_id": "enmap@4.0.12",
|
|
||||||
"_inBundle": false,
|
|
||||||
"_integrity": "sha512-jvK94Fyk8HtJlYQdW/XW4pNfUzxzsjF7UlaC1MalpZq944ti9HL+XcRLFTmM1/Px/9dZxGeUPLMBUhAO0/S6YA==",
|
|
||||||
"_location": "/enmap",
|
|
||||||
"_phantomChildren": {},
|
|
||||||
"_requested": {
|
|
||||||
"type": "tag",
|
|
||||||
"registry": true,
|
|
||||||
"raw": "enmap",
|
|
||||||
"name": "enmap",
|
|
||||||
"escapedName": "enmap",
|
|
||||||
"rawSpec": "",
|
|
||||||
"saveSpec": null,
|
|
||||||
"fetchSpec": "latest"
|
|
||||||
},
|
|
||||||
"_requiredBy": [
|
|
||||||
"#USER",
|
|
||||||
"/"
|
|
||||||
],
|
|
||||||
"_resolved": "https://registry.npmjs.org/enmap/-/enmap-4.0.12.tgz",
|
|
||||||
"_shasum": "432a58a87b8b5605e49ad71e2fcbfaa78a967e88",
|
|
||||||
"_spec": "enmap",
|
|
||||||
"_where": "/Users/loic/Documents/DiscordJS",
|
|
||||||
"author": {
|
|
||||||
"name": "Evelyne Lachance"
|
|
||||||
},
|
|
||||||
"bugs": {
|
|
||||||
"url": "https://github.com/eslachance/enmap/issues"
|
|
||||||
},
|
|
||||||
"bundleDependencies": false,
|
|
||||||
"dependencies": {
|
|
||||||
"lodash": "^4.17.10"
|
|
||||||
},
|
|
||||||
"deprecated": false,
|
|
||||||
"description": "Enhanced Maps are a data structure that can be used to store data in memory that can also be saved in a database behind the scenes. These operations are fast, safe, and painless.",
|
|
||||||
"devDependencies": {
|
|
||||||
"eslint": "^4.19.1",
|
|
||||||
"eslint-config-airbnb-base": "^11.3.2",
|
|
||||||
"eslint-config-standard": "^10.2.1",
|
|
||||||
"eslint-plugin-import": "^2.13.0",
|
|
||||||
"eslint-plugin-node": "^5.1.1",
|
|
||||||
"eslint-plugin-promise": "^3.5.0",
|
|
||||||
"eslint-plugin-standard": "^3.0.1"
|
|
||||||
},
|
|
||||||
"homepage": "https://github.com/eslachance/enmap#readme",
|
|
||||||
"keywords": [],
|
|
||||||
"license": "Apache-2.0",
|
|
||||||
"main": "index.js",
|
|
||||||
"name": "enmap",
|
|
||||||
"peerDependencies": {
|
|
||||||
"better-sqlite-pool": "^0.1.2"
|
|
||||||
},
|
|
||||||
"repository": {
|
|
||||||
"type": "git",
|
|
||||||
"url": "git+https://github.com/eslachance/enmap.git"
|
|
||||||
},
|
|
||||||
"scripts": {
|
|
||||||
"test": "mocha"
|
|
||||||
},
|
|
||||||
"types": "index.d.ts",
|
|
||||||
"version": "4.0.12"
|
|
||||||
}
|
|
@ -1,12 +0,0 @@
|
|||||||
class CustomError extends Error {
|
|
||||||
|
|
||||||
constructor(message, name = null) {
|
|
||||||
super();
|
|
||||||
Error.captureStackTrace(this, this.constructor);
|
|
||||||
this.name = name || 'EnmapError';
|
|
||||||
this.message = message;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
module.exports = CustomError;
|
|
File diff suppressed because it is too large
Load Diff
@ -1,4 +0,0 @@
|
|||||||
This is a simple bot for discord built using Discord.js
|
|
||||||
This bot can kick people and reply to haha yes
|
|
||||||
haha yes
|
|
||||||
yes
|
|
@ -1,4 +0,0 @@
|
|||||||
{
|
|
||||||
"lol": "haha yes funi",
|
|
||||||
"haha yes": "haha yes"
|
|
||||||
}
|
|
Loading…
Reference in New Issue