Added snowflake and experimental xp system, made logger easier to use
This commit is contained in:
parent
606c1ea1dc
commit
171253c52c
12 changed files with 137 additions and 43 deletions
|
@ -1,6 +1,6 @@
|
|||
const database = require("../utils/database.js");
|
||||
|
||||
exports.run = async (message) => {
|
||||
const guild = (await database.find({ id: message.channel.guild.id }).exec())[0];
|
||||
const guild = (await database.guilds.find({ id: message.channel.guild.id }).exec())[0];
|
||||
return `${message.author.mention}, my command list can be found here: https://essem.space/esmBot/commands.html?dev=true\nThis server's prefix is \`${guild.prefix}\`.`;
|
||||
};
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
const database = require("../utils/database.js");
|
||||
|
||||
exports.run = async (message, args) => {
|
||||
const guild = (await database.find({ id: message.channel.guild.id }).exec())[0];
|
||||
const guild = (await database.guilds.find({ id: message.channel.guild.id }).exec())[0];
|
||||
if (args.length !== 0) {
|
||||
if (!message.member.permission.has("administrator") && message.member.id !== "198198681982205953") return `${message.author.mention}, you need to be an administrator to change the bot prefix!`;
|
||||
guild.set("prefix", args[0]);
|
||||
|
|
|
@ -5,12 +5,7 @@ exports.run = async (message, args) => {
|
|||
if (!message.channel.guild.members.get(client.user.id).permission.has("manageMessages") && !message.channel.permissionsOf(client.user.id).has("manageMessages")) return `${message.author.mention}, I don't have the \`Manage Messages\` permission!`;
|
||||
if (args.length === 0 || !args[0].match(/^\d+$/)) return `${message.author.mention}, you need to provide the number of messages to purge!`;
|
||||
const numberOfMessages = parseInt(args[0]) + 1;
|
||||
const messageCollection = await message.channel.getMessages(numberOfMessages);
|
||||
const messages = [];
|
||||
for (const messageObject of messageCollection) {
|
||||
messages.push(messageObject.id);
|
||||
}
|
||||
await message.channel.deleteMessages(messages);
|
||||
await message.channel.purge(numberOfMessages);
|
||||
const purgeMessage = await message.channel.createMessage(`Successfully purged ${args[0]} messages.`);
|
||||
await require("util").promisify(setTimeout)(10000);
|
||||
await purgeMessage.delete();
|
||||
|
|
6
commands/snowflake.js
Normal file
6
commands/snowflake.js
Normal file
|
@ -0,0 +1,6 @@
|
|||
exports.run = async (message, args) => {
|
||||
if (!args[0].match(/^\d+$/) && args[0] < 21154535154122752) return `${message.author.mention}, that's not a valid snowflake!`;
|
||||
return new Date((args[0] / 4194304) + 1420070400000).toUTCString();
|
||||
};
|
||||
|
||||
exports.aliases = ["timestamp", "snowstamp", "snow"];
|
|
@ -5,28 +5,28 @@ const paginator = require("../utils/pagination/pagination.js");
|
|||
const { random } = require("../utils/misc.js");
|
||||
|
||||
exports.run = async (message, args) => {
|
||||
const guild = (await database.find({ id: message.channel.guild.id }).exec())[0];
|
||||
const guild = (await database.guilds.find({ id: message.channel.guild.id }).exec())[0];
|
||||
const tags = guild.tags;
|
||||
const blacklist = ["add", "edit", "remove", "delete", "list", "random"];
|
||||
switch (args[0].toLowerCase()) {
|
||||
case "add":
|
||||
if (args[1] === undefined) return `${message.author.mention}, you need to provide the name of the tag you want to add!`;
|
||||
if (blacklist.indexOf(args[1].toLowerCase()) > -1) return `${message.author.mention}, you can't make a tag with that name!`;
|
||||
if (tags.exists(args[1].toLowerCase())) return `${message.author.mention}, this tag already exists!`;
|
||||
if (tags.has(args[1].toLowerCase())) return `${message.author.mention}, this tag already exists!`;
|
||||
await setTag(args.slice(2).join(" "), args[1].toLowerCase(), message, guild);
|
||||
return `${message.author.mention}, the tag \`${args[1].toLowerCase()}\` has been added!`;
|
||||
case "delete":
|
||||
case "remove":
|
||||
if (args[1] === undefined) return `${message.author.mention}, you need to provide the name of the tag you want to delete!`;
|
||||
if (!tags.exists(args[1].toLowerCase())) return `${message.author.mention}, this tag doesn't exist!`;
|
||||
if (tags[args[1].toLowerCase()].author !== message.author.id && tags[args[1].toLowerCase()].author !== config.botOwner) return `${message.author.mention}, you don't own this tag!`;
|
||||
if (!tags.has(args[1].toLowerCase())) return `${message.author.mention}, this tag doesn't exist!`;
|
||||
if (tags.get(args[1].toLowerCase()).author !== message.author.id && tags.get(args[1].toLowerCase()).author !== config.botOwner) return `${message.author.mention}, you don't own this tag!`;
|
||||
tags.set(args[1].toLowerCase(), undefined);
|
||||
await guild.save();
|
||||
return `${message.author.mention}, the tag \`${args[1].toLowerCase()}\` has been deleted!`;
|
||||
case "edit":
|
||||
if (args[1] === undefined) return `${message.author.mention}, you need to provide the name of the tag you want to edit!`;
|
||||
if (!tags.exists(args[1].toLowerCase())) return `${message.author.mention}, this tag doesn't exist!`;
|
||||
if (tags[args[1].toLowerCase()].author !== message.author.id && tags[args[1].toLowerCase()].author !== config.botOwner) return `${message.author.mention}, you don't own this tag!`;
|
||||
if (!tags.has(args[1].toLowerCase())) return `${message.author.mention}, this tag doesn't exist!`;
|
||||
if (tags.get(args[1].toLowerCase()).author !== message.author.id && tags.get(args[1].toLowerCase()).author !== config.botOwner) return `${message.author.mention}, you don't own this tag!`;
|
||||
await setTag(args.slice(2).join(" "), args[1].toLowerCase(), message, guild);
|
||||
return `${message.author.mention}, the tag \`${args[1].toLowerCase()}\` has been edited!`;
|
||||
case "list":
|
||||
|
@ -34,11 +34,11 @@ exports.run = async (message, args) => {
|
|||
if (!message.channel.guild.members.get(client.user.id).permission.has("embedLinks") && !message.channel.permissionsOf(client.user.id).has("embedLinks")) return `${message.author.mention}, I don't have the \`Embed Links\` permission!`;
|
||||
var pageSize = 15;
|
||||
var embeds = [];
|
||||
console.log(Array.from(tags.keys()));
|
||||
var groups = Array.from(tags.keys()).map((item, index) => {
|
||||
return index % pageSize === 0 ? Array.from(tags.keys()).slice(index, index + pageSize) : null;
|
||||
}).filter((item) => {
|
||||
return item;
|
||||
});
|
||||
console.log(groups);
|
||||
for (const [i, value] of groups.entries()) {
|
||||
embeds.push({
|
||||
"embed": {
|
||||
|
@ -61,8 +61,8 @@ exports.run = async (message, args) => {
|
|||
return tags[random(Object.keys(tags))].content;
|
||||
default:
|
||||
if (args.length === 0) return `${message.author.mention}, you need to specify the name of the tag you want to view!`;
|
||||
if (!tags.exists(args[0].toLowerCase())) return `${message.author.mention}, this tag doesn't exist!`;
|
||||
return tags[`${args[0].toLowerCase()}.content`];
|
||||
if (!tags.has(args[0].toLowerCase())) return `${message.author.mention}, this tag doesn't exist!`;
|
||||
return tags.get(args[0].toLowerCase()).content;
|
||||
}
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue