custom names for monners

master
Kit Kasune 3 years ago
parent 12d74162d7
commit e2630e80f3
  1. 3
      bot.js
  2. 4
      commands/leveling/claim.js
  3. 2
      commands/leveling/daily.js
  4. 41
      commands/leveling/namemonners.js
  5. 2
      commands/leveling/stats.js
  6. 2
      events/messageCreate.js
  7. 4
      events/ready.js
  8. 0
      models/monnersnames.js
  9. 6
      util/lxp/gainxp.js
  10. 2
      util/lxp/spawnchest.js

@ -52,7 +52,8 @@ client.misc = {
animeID: new Discord.Collection(), animeID: new Discord.Collection(),
charsNum: 0, charsNum: 0,
charsLove: new Discord.Collection(), charsLove: new Discord.Collection(),
monners: {} monners: {},
monnersNames: new Map()
}, },
loggers: {}, loggers: {},
rl: readline.createInterface({input: process.stdin, output: process.stdout}), rl: readline.createInterface({input: process.stdin, output: process.stdout}),

@ -14,7 +14,7 @@ module.exports = {
async execute(message, msg, args, cmd, prefix, mention, client) { async execute(message, msg, args, cmd, prefix, mention, client) {
if (!client.misc.cache.chests.enabled.includes(message.guild.id)) {return message.channel.send("Chests aren't enabled in this server!");} if (!client.misc.cache.chests.enabled.includes(message.guild.id)) {return message.channel.send("Chests aren't enabled in this server!");}
if (!client.misc.cache.chests.waiting.has(message.channel.id)) {return message.channel.send("There are no chests to claim in this channel.");} if (!client.misc.cache.chests.waiting.has(message.channel.id)) {return message.channel.send("There are no chests to claim in this channel.");}
if (!client.misc.cache.monners[message.author.id]) {return message.channel.send("There was an issue on my side with claiming your chest. This happened because I don't have your Monners info cached, so send a message anywhere and then try again. Sorry!");} if (!client.misc.cache.monners[message.author.id]) {return message.channel.send(`There was an issue on my side with claiming your chest. This happened because I don't have your ${message.misc.mn} info cached, so send a message anywhere and then try again. Sorry!`);}
let chest = client.misc.cache.chests.waiting.get(message.channel.id); let chest = client.misc.cache.chests.waiting.get(message.channel.id);
client.misc.cache.monners[message.author.id] += chest.amount; client.misc.cache.monners[message.author.id] += chest.amount;
@ -22,7 +22,7 @@ module.exports = {
chest.message.delete().catch(() => {}); chest.message.delete().catch(() => {});
return message.channel.send({embeds: [new Discord.MessageEmbed() return message.channel.send({embeds: [new Discord.MessageEmbed()
.setAuthor({name: message.member.displayName, iconURL: message.member.displayAvatarURL()}) .setAuthor({name: message.member.displayName, iconURL: message.member.displayAvatarURL()})
.setDescription(`You've claimed ${client.utils.an(chest.rarity.name, true)} Chest with **${chest.amount} Monners<:monners:926736756047495218>**`) .setDescription(`You've claimed ${client.utils.an(chest.rarity.name, true)} Chest with **${chest.amount} ${message.misc.mn}<:monners:926736756047495218>**`)
.setColor(chest.rarity.color) .setColor(chest.rarity.color)
]}).catch(() => {}); ]}).catch(() => {});
} }

@ -44,7 +44,7 @@ module.exports = {
.setAuthor({iconURL: message.guild ? message.member.displayAvatarURL() : message.author.iconURL(), name: message.guild ? message.member.displayName : message.author.username}) .setAuthor({iconURL: message.guild ? message.member.displayAvatarURL() : message.author.iconURL(), name: message.guild ? message.member.displayName : message.author.username})
.setDescription(`You've claimed today's daily!`) .setDescription(`You've claimed today's daily!`)
.addField("Streak", streakIncrease ? `Your streak has **increased** to **${tm.daily.streak}**` : 'Your streak has **reset** to **1**.', true) .addField("Streak", streakIncrease ? `Your streak has **increased** to **${tm.daily.streak}**` : 'Your streak has **reset** to **1**.', true)
.addField("Bonus Monners", `<:monners:926736756047495218> ${bonus}`, true) .addField(`Bonus ${message.misc.mn}`, `<:monners:926736756047495218> ${bonus}`, true)
.addField("Total Dailies Claimed", `${tm.daily.total}`) .addField("Total Dailies Claimed", `${tm.daily.total}`)
.setColor('c375f0') .setColor('c375f0')
]}); ]});

@ -0,0 +1,41 @@
const Discord = require('discord.js');
const Saves = require('../../models/saves');
module.exports = {
name: "namemonners",
aliases: ['namemon', 'nm'],
meta: {
category: 'Leveling',
description: "Rename the currency for your server",
syntax: '`namemonners <clear|name>`',
extra: null,
guildOnly: true
},
help: new Discord.MessageEmbed()
.setTitle("Help -> Monners Naming")
.setDescription("Rename the Monners for your server. This merely a cosmetic effect. Monners gains will remain global regardless.")
.addField("Notice", "You must be an administrator in the server in order to edit these settings.")
.addField("Syntax", "`namemonners <clear|name>`"),
async execute(message, msg, args, cmd, prefix, mention, client) {
if (!args.length) {return message.channel.send(`Syntax: \`${prefix}namemonners <clear|name>\``);}
if (!message.member.permissions.has("ADMINISTRATOR")) {return message.channel.send("You must be an administrator in this server in order to do that.");}
let name = args.join(" ");
const names = await Saves.findOne({name: 'monnersnames'});
const nsaves = names.saves;
if (name.toLowerCase() === 'clear') {
nsaves.delete(message.guild.id);
client.misc.cache.monnersNames.delete(message.guild.id);
message.channel.send("I'll now refer to currency in this server as Monners again.");
} else {
if (name.length > 12) {return message.channel.send("That name is too long! Keep it short and simple.");}
if (name.match(/<a?:.+:\d+>/gm)) {return message.channel.send("You can't have an emoji in your monners name.");}
if (!name.match(/^[a-zA-Z0-9-]+$/gm)) {return message.channel.send("Your name must contain only alphanumeric characters.");}
nsaves.set(message.guild.id, name);
client.misc.cache.monnersNames.set(message.guild.id, name);
message.channel.send(`Cool. I'll refer to Monners in this server as "${name}" now.`);
}
names.saves = nsaves;
return await names.save();
}
};

@ -71,7 +71,7 @@ module.exports = {
.setDescription("Local leveling stats") .setDescription("Local leveling stats")
.addField("Level", `${xp.level}`, true) .addField("Level", `${xp.level}`, true)
.addField("XP", `**${xp.xp}** of **${Math.ceil(100 + (((xp.level / 3) ** 2) * 2))}** needed to level up`, true) .addField("XP", `**${xp.xp}** of **${Math.ceil(100 + (((xp.level / 3) ** 2) * 2))}** needed to level up`, true)
.addField("Monners", `<:monners:926736756047495218> ${tcur}`) .addField(`${message.misc.mn}`, `<:monners:926736756047495218> ${tcur}`)
.setThumbnail(client.users.cache.get(u.id).avatarURL({size: 2048})) .setThumbnail(client.users.cache.get(u.id).avatarURL({size: 2048}))
.setColor("c375f0") .setColor("c375f0")
.setFooter({text: "Natsuki"}) .setFooter({text: "Natsuki"})

@ -35,6 +35,8 @@ module.exports = async (client, message) => {
: message.content.slice(3 + client.user.id.length).trim().replace('\u200E', '').split(/\s+/g); : message.content.slice(3 + client.user.id.length).trim().replace('\u200E', '').split(/\s+/g);
let cmd = args.shift().toLowerCase().trim(); let cmd = args.shift().toLowerCase().trim();
message.misc = {mn: message.guild ? (client.misc.cache.monnersNames.get(message.guild.id) || 'Monners') : 'Monners'};
if (message.content.includes("@everyone")) {return;} if (message.content.includes("@everyone")) {return;}
if ([`<@${client.user.id}>`, `<@!${client.user.id}>`].includes(msg)) { if ([`<@${client.user.id}>`, `<@!${client.user.id}>`].includes(msg)) {

@ -5,6 +5,7 @@ const lastfm = require("lastfm");
const GuildSettings = require('../models/guild'); const GuildSettings = require('../models/guild');
const BotDataSchema = require('../models/bot'); const BotDataSchema = require('../models/bot');
const LogData = require('../models/log'); const LogData = require('../models/log');
const Saves = require('../models/saves');
const siftStatuses = require('../util/siftstatuses'); const siftStatuses = require('../util/siftstatuses');
const localXPCacheClean = require('../util/lxp/cacheloop'); const localXPCacheClean = require('../util/lxp/cacheloop');
@ -82,6 +83,9 @@ module.exports = async client => {
await require('../util/cache')(client); await require('../util/cache')(client);
let mnsaves = await Saves.findOne({name: 'monnersnames'}) || new Saves({name: 'monnersnames'});
client.misc.cache.monnersNames = mnsaves.saves;
setInterval(() => localXPCacheClean(client), 150000); setInterval(() => localXPCacheClean(client), 150000);
setInterval(() => monitorCacheClean(client), 150000); setInterval(() => monitorCacheClean(client), 150000);

@ -38,7 +38,7 @@ module.exports = async (client, member, channel) => {
client.misc.cache.monners[member] += cur; client.misc.cache.monners[member] += cur;
if (ch && ch.permissionsFor(ch.guild.me.id).has('SEND_MESSAGES')) { if (ch && ch.permissionsFor(ch.guild.me.id).has('SEND_MESSAGES')) {
if (!ch.permissionsFor(ch.guild.me.id).has('ATTACH_FILES')) {ch.send(`<:awoo:560193779764559896> <@${member}> has reached **Level ${x + 1}**, and gained **${cur}** bonus Monners<:monners:926736756047495218>! <a:meowth_monners:926736229184208927>`).catch((e) => {/*console.error(e)*/});} if (!ch.permissionsFor(ch.guild.me.id).has('ATTACH_FILES')) {ch.send(`<:awoo:560193779764559896> <@${member}> has reached **Level ${x + 1}**, and gained **${cur}** bonus ${client.misc.cache.monnersNames.get(channel.guild.id) || 'Monners'}<:monners:926736756047495218>! <a:meowth_monners:926736229184208927>`).catch((e) => {/*console.error(e)*/});}
else { else {
const canvas = Canvas.createCanvas(1193, 411); const canvas = Canvas.createCanvas(1193, 411);
const context = canvas.getContext('2d'); const context = canvas.getContext('2d');
@ -55,7 +55,7 @@ module.exports = async (client, member, channel) => {
const monnersImage = await Canvas.loadImage('https://cdn.discordapp.com/emojis/926736756047495218'); const monnersImage = await Canvas.loadImage('https://cdn.discordapp.com/emojis/926736756047495218');
context.drawImage(monnersImage, canvas.width / 2.8, canvas.height / 1.5, 58, 60); context.drawImage(monnersImage, canvas.width / 2.8, canvas.height / 1.5, 58, 60);
context.fillText(`${oldMonners} + ${cur} Bonus Monners`, (canvas.width / 2.8) + 70, (canvas.height / 1.55) + 57); context.fillText(`${oldMonners} + ${cur} Bonus ${client.misc.cache.monnersNames.get(channel.guild.id) || 'Monners'}`, (canvas.width / 2.8) + 70, (canvas.height / 1.55) + 57);
context.font = applyText(canvas, `${ch.guild.members.cache.get(member).displayName}`); //center text context.font = applyText(canvas, `${ch.guild.members.cache.get(member).displayName}`); //center text
context.fillText(`${ch.guild.members.cache.get(member).displayName}`, canvas.width / 2.8, canvas.height / 2.7); context.fillText(`${ch.guild.members.cache.get(member).displayName}`, canvas.width / 2.8, canvas.height / 2.7);
@ -64,7 +64,7 @@ module.exports = async (client, member, channel) => {
context.drawImage(avatar, 40, 40, canvas.height - 80, canvas.height - 80); context.drawImage(avatar, 40, 40, canvas.height - 80, canvas.height - 80);
ch.send({ ch.send({
content: `<:awoo:560193779764559896> <@${member}> has reached **Level ${x + 1}**, and gained **${cur}** bonus Monners<:monners:926736756047495218>! <a:meowth_monners:926736229184208927>`, content: `<:awoo:560193779764559896> <@${member}> has reached **Level ${x + 1}**, and gained **${cur}** bonus ${client.misc.cache.monnersNames.get(channel.guild.id) || 'Monners'}<:monners:926736756047495218>! <a:meowth_monners:926736229184208927>`,
files: [new Discord.MessageAttachment(canvas.toBuffer(), 'level-up.png')] files: [new Discord.MessageAttachment(canvas.toBuffer(), 'level-up.png')]
}); });
} }

@ -66,7 +66,7 @@ module.exports = async (client, member, channel, prefix) => {
let chestEmbed = new Discord.MessageEmbed() let chestEmbed = new Discord.MessageEmbed()
.setTitle(`${client.utils.an(rarity.name, true)} Chest has spawned!`) .setTitle(`${client.utils.an(rarity.name, true)} Chest has spawned!`)
.setDescription(`It has **${amount} Monners<:monners:926736756047495218>**`) .setDescription(`It has **${amount} ${client.misc.cache.monnersNames.get(member.guild.id) || 'Monners'}<:monners:926736756047495218>**`)
.setFooter({text: `Type ${prefix}claim to claim it!`}) .setFooter({text: `Type ${prefix}claim to claim it!`})
.setColor(rarity.color) //create the chest message .setColor(rarity.color) //create the chest message

Loading…
Cancel
Save