Removed XP system, fixed a few more bugs

This commit is contained in:
TheEssem 2019-12-16 12:13:38 -06:00
parent 29cd75ac3d
commit 903f5eebf0
7 changed files with 5 additions and 67 deletions

View File

@ -28,7 +28,6 @@ body
h1#img-srchttpsrawgithubusercontentcomtheessemesmbot-rewritemasteresmbotpng-width64-esmbot-dev-command-list h1#img-srchttpsrawgithubusercontentcomtheessemesmbot-rewritemasteresmbotpng-width64-esmbot-dev-command-list
img(src='https://raw.githubusercontent.com/TheEssem/esmBot-rewrite/master/esmbot.png' width='64') img(src='https://raw.githubusercontent.com/TheEssem/esmBot-rewrite/master/esmbot.png' width='64')
| esmBot Command List | esmBot Command List
p by Essem#9261
p p
strong strong
| You are currently using esmBot Dev! Things may change at any time without warning and there will be bugs. Many bugs. If you find one, | You are currently using esmBot Dev! Things may change at any time without warning and there will be bugs. Many bugs. If you find one,

View File

@ -9,6 +9,7 @@ exports.run = async (message, args) => {
const embeds = []; const embeds = [];
const request = await fetch(`https://www.googleapis.com/customsearch/v1?key=${process.env.GOOGLE}&cx=${process.env.CSE}&safe=active&searchType=image&q=${encodeURIComponent(args.join(" "))}`); const request = await fetch(`https://www.googleapis.com/customsearch/v1?key=${process.env.GOOGLE}&cx=${process.env.CSE}&safe=active&searchType=image&q=${encodeURIComponent(args.join(" "))}`);
const images = await request.json(); const images = await request.json();
if (!images.items) return `${message.author.mention}, I couldn't find any results!`;
for (const [i, value] of images.items.entries()) { for (const [i, value] of images.items.entries()) {
embeds.push({ embeds.push({
"embed": { "embed": {
@ -27,7 +28,7 @@ exports.run = async (message, args) => {
} }
}); });
} }
if (embeds.length === 0) return `${message.author.mention}, I couldn't find any results!`; //if (embeds.length === 0) return `${message.author.mention}, I couldn't find any results!`;
return paginator(message, embeds); return paginator(message, embeds);
}; };

View File

@ -7,7 +7,7 @@ exports.run = async (message, args) => {
const numberOfMessages = parseInt(args[0]) + 1; const numberOfMessages = parseInt(args[0]) + 1;
await message.channel.purge(numberOfMessages); await message.channel.purge(numberOfMessages);
const purgeMessage = await message.channel.createMessage(`Successfully purged ${args[0]} messages.`); const purgeMessage = await message.channel.createMessage(`Successfully purged ${args[0]} messages.`);
await require("util").promisify(setTimeout)(10000); await require("util").promisify(setTimeout)(5000);
await purgeMessage.delete(); await purgeMessage.delete();
return; return;
}; };

View File

@ -7,6 +7,7 @@ exports.run = async (message) => {
message.channel.sendTyping(); message.channel.sendTyping();
const rawData = await sharp(image.data).ensureAlpha().raw().toBuffer({ resolveWithObject: true }); const rawData = await sharp(image.data).ensureAlpha().raw().toBuffer({ resolveWithObject: true });
const qrBuffer = jsqr(rawData.data, rawData.info.width, rawData.info.height); const qrBuffer = jsqr(rawData.data, rawData.info.width, rawData.info.height);
if (!qrBuffer) return `${message.author.mention}, I couldn't find a QR code!`;
return `\`\`\`\n${qrBuffer.data}\n\`\`\``; return `\`\`\`\n${qrBuffer.data}\n\`\`\``;
}; };

View File

@ -15,44 +15,6 @@ module.exports = async (message) => {
const guildConf = (await database.guilds.find({ id: message.channel.guild.id }).exec())[0]; const guildConf = (await database.guilds.find({ id: message.channel.guild.id }).exec())[0];
const prefix = prefixMention.test(message.content) ? message.content.match(prefixMention)[0] : guildConf.prefix; const prefix = prefixMention.test(message.content) ? message.content.match(prefixMention)[0] : guildConf.prefix;
// xp stuff
const xp = (await database.xp.find({ id: message.channel.guild.id }).exec())[0];
if (xp.enabled === true && !message.member.roles.includes("631290345824714762")) {
const info = xp.members.get(message.author.id);
if (!info) {
logger.log("Member not in XP database, adding");
const memberInfo = {
xpAmount: 10,
level: 0
};
xp.members.set(message.author.id, memberInfo);
await xp.save();
} else {
const newAmount = info.xpAmount + 10;
const level = Math.floor(0.1 * Math.sqrt(newAmount));
if (info.level < level) {
logger.log(`${message.author.username} has leveled up`);
if (message.channel.guild.id === "631290275456745502" && level === 5) {
await message.author.addRole("638759280752853022", "level 5");
await message.channel.createMessage(`${message.author.mention} just leveled up to level ${level}... AND unlocked the better members role!`);
} else if (message.channel.guild.id === "631290275456745502" && level === 10) {
await message.author.addRole("638822807626711078", "level 10");
await message.channel.createMessage(`${message.author.mention} just leveled up to level ${level}... AND unlocked the even better members role!`);
} else if (message.channel.guild.id === "631290275456745502" && level === 25) {
await message.author.addRole("631299545657114645", "level 25");
await message.channel.createMessage(`${message.author.mention} just leveled up to level ${level}... AND unlocked the best members role!`);
} else {
await message.channel.createMessage(`${message.author.mention} just leveled up to level ${level}!`);
}
}
xp.members.set(message.author.id, {
xpAmount: newAmount,
level: level
});
await xp.save();
}
}
// ignore other stuff // ignore other stuff
if (message.content.startsWith(prefix) === false && !message.mentions.includes(client.user) && message.channel.id !== "573553254575898626") return; if (message.content.startsWith(prefix) === false && !message.mentions.includes(client.user) && message.channel.id !== "573553254575898626") return;

View File

@ -9,9 +9,8 @@ const twitter = process.env.TWITTER === "true" ? require("../utils/twitter.js")
// run when ready // run when ready
module.exports = async () => { module.exports = async () => {
// make sure settings/tags exist // make sure settings/tags exist
for (const [id, guild] of client.guilds) { for (const [id] of client.guilds) {
const guildDB = (await database.guilds.find({ id: id }).exec())[0]; const guildDB = (await database.guilds.find({ id: id }).exec())[0];
const xpDB = (await database.xp.find({ id: id }).exec())[0];
if (!guildDB) { if (!guildDB) {
console.log(`Registering guild database entry for guild ${id}...`); console.log(`Registering guild database entry for guild ${id}...`);
const newGuild = new database.guilds({ const newGuild = new database.guilds({
@ -21,22 +20,6 @@ module.exports = async () => {
}); });
await newGuild.save(); await newGuild.save();
} }
if (!xpDB) {
console.log(`Registering xp database entry for guild ${id}...`);
const memberInfo = {};
for (const [id] of guild.members) {
memberInfo[id] = {
xpAmount: 0,
level: 0
};
}
const newXP = new database.xp({
id: id,
members: memberInfo,
enabled: false
});
await newXP.save();
}
} }
// generate docs // generate docs

View File

@ -8,13 +8,6 @@ const guildSchema = new mongoose.Schema({
}); });
const Guild = mongoose.model("Guild", guildSchema); const Guild = mongoose.model("Guild", guildSchema);
const xpSchema = new mongoose.Schema({
id: String,
members: Map,
enabled: Boolean
});
const XP = mongoose.model("XP", xpSchema);
const tweetSchema = new mongoose.Schema({ const tweetSchema = new mongoose.Schema({
tweets: [String], tweets: [String],
replies: [String], replies: [String],
@ -28,5 +21,4 @@ const tweetSchema = new mongoose.Schema({
const TweetCollection = mongoose.model("TweetCollection", tweetSchema); const TweetCollection = mongoose.model("TweetCollection", tweetSchema);
exports.guilds = Guild; exports.guilds = Guild;
exports.xp = XP;
exports.tweets = TweetCollection; exports.tweets = TweetCollection;