nyx

The first CODM discrod bot -- cath.exe Template
git clone https://codeberg.org/night0721/nyx
Log | Files | Refs | LICENSE

commit 49b2b3aca599e599dd1fa2dcf0f71a7ed73fec07
parent 2e2501cf9093650abb03dff6e78aab103c801792
Author: NK <[email protected]>
Date:   Tue,  4 Apr 2023 16:26:56 +0100

still removing

Diffstat:
Dmodels/econ.js | 42------------------------------------------
Dmodels/inventory.js | 27---------------------------
Dmodels/level.js | 11-----------
Dmodels/warns.js | 12------------
Dutil/Data/gun.json | 14--------------
Dutil/functions/economy.js | 297-------------------------------------------------------------------------------
Mutil/functions/mongoose.js | 1-
7 files changed, 0 insertions(+), 404 deletions(-)

diff --git a/models/econ.js b/models/econ.js @@ -1,42 +0,0 @@ -const mongoose = require("mongoose"); -module.exports = mongoose.model( - "economy", - new mongoose.Schema({ - User: { - type: String, - required: true, - }, - CP: { - type: Number, - default: 0, - }, - BJWins: { - type: Number, - default: 0, - }, - SlotsWins: { - type: Number, - default: 0, - }, - BetWins: { - type: Number, - default: 0, - }, - Inventory: { - NA45: { type: Number, default: 0 }, - Deagle: { type: Number, default: 0 }, - MantaRay: { type: Number, default: 0 }, - Alias: { type: Number, default: 0 }, - Scylla: { type: Number, default: 0 }, - UrbanTracker: { type: Number, default: 0 }, - EpicXPCard: { type: Number, default: 0 }, - }, - Gun: { - Name: { type: String, default: "" }, - Rank: { type: String, default: "Iron" }, - Kills: { type: Number, default: 0 }, - XP: { type: Number, default: 0 }, - Level: { type: Number, default: 1 }, - }, - }) -); diff --git a/models/inventory.js b/models/inventory.js @@ -1,27 +0,0 @@ -const mongoose = require("mongoose"); - -const inventorySchema = mongoose.Schema({ - userId: { - type: String, - required: true, - }, - items: { - itemID: { - type: Number, - }, - itemName: { - type: String, - }, - itemWeapon: { - type: String, - }, - itemRarity: { - type: String, - }, - itemIMG: { - type: String, - }, - }, -}); - -module.exports = mongoose.model("inventory", inventorySchema); diff --git a/models/level.js b/models/level.js @@ -1,11 +0,0 @@ -const mongoose = require("mongoose"); -module.exports = mongoose.model( - "level", - new mongoose.Schema({ - xp: Number, - level: Number, - lastUpdate: Date, - userID: String, - guildID: String, - }) -); diff --git a/models/warns.js b/models/warns.js @@ -1,12 +0,0 @@ -const mongoose = require("mongoose"); -module.exports = mongoose.model( - "warn", - new mongoose.Schema({ - Guild: String, - User: String, - Warns: { - type: Array, - default: [], - }, - }) -); diff --git a/util/Data/gun.json b/util/Data/gun.json @@ -1,14 +0,0 @@ -[ - { - "name": "kuku69", - "description": "Meta gun of S7", - "emoji": "<:kuku69:894157060164440095>", - "link": "https://cdn.discordapp.com/emojis/894157060164440095.png" - }, - { - "name": "nani45", - "description": "Gae Gun", - "emoji": "<:nani45:893669056928972832>", - "link": "https://cdn.discordapp.com/emojis/893669056928972832.png" - } -] diff --git a/util/functions/economy.js b/util/functions/economy.js @@ -1,297 +0,0 @@ -const guns = require("../Data/gun.json"); -const req = { - Iron: 0, - Gold: 400, - Platinum: 1000, - Diamond: 2000, - Master: 3500, -}; -module.exports = async client => { - const econ = require("../../models/econ"); - const user = require("../../models/users"); - client.createUser = id => { - user.findOne({ User: id }, () => { - new user({ - User: id, - }).save(); - }); - }; - client.createProfile = id => { - econ.findOne({ User: id }, () => { - new econ({ - User: id, - }).save(); - }); - }; - client.multi = interaction => - new Promise(async ful => { - let multiplier = 0; - const b = await user.findOne({ User: interaction.user.id }); - if (!b) { - client.createUser(interaction.user.id); - } - if (b?.Premium === true) { - multiplier += 0.25; - } - if (client.path.includes(interaction.guild.id)) { - multiplier += 0.15; - } - if (interaction.channel.name.toLowerCase().includes("nyx")) { - multiplier += 0.1; - } - - ful(Math.round(multiplier * 10)); - }); - - client.bal = id => - new Promise(async ful => { - const data = await econ.findOne({ User: id }); - if (!data) { - client.createProfile(id); - } - ful(data.CP); - }); - - client.add = (id, amount, interaction) => { - econ.findOne({ User: id }, async (err, data) => { - let multi = 0; - if (err) throw err; - if (data) { - const users = require("../../models/users"); - users.findOne({ User: id }, (err, b) => { - if (!b) { - client.createUser(id); - } - if (b?.Premium === true) { - multi += 0.25; - } - - if (client.path.includes(interaction.guild.id)) { - multi += 0.15; - } - if (interaction.channel.name.toLowerCase().includes("nyx")) { - multi += 0.1; - } - if (multi === 0) { - data.CP += amount; - data.save(); - } else { - data.CP += Math.round(amount * multi + amount); - data.save(); - } - }); - } else { - client.createProfile(id); - } - }); - }; - client.rmv = (id, amount) => { - econ.findOne({ User: id }, async (err, data) => { - if (err) throw err; - if (data) { - data.CP -= amount; - data.save(); - } else { - client.createProfile(id); - } - }); - }; - client.addItem = (id, item, amount) => { - const economy = require("../../models/econ"); - economy.findOne({ User: id }, (err, data) => { - if (!data) { - client.createProfile(id); - } else { - data.Inventory[item] += amount; - data.save(); - } - }); - }; - client.removeItem = (id, item, amount) => { - const inventory = require("../../models/econ"); - inventory.findOne({ User: id }, (err, data) => { - if (!data) { - client.createProfile(id); - } else { - data.Inventory[item] -= amount; - data.save(); - } - }); - }; - client.addcmdsused = id => { - user.findOne({ User: id }, async (err, data) => { - if (err) console.log(err); - if (data) { - data.CommandUsed++; - data.save(); - } else { - client.createUser(id); - } - }); - }; - - client.ADDBJWin = id => { - econ.findOne({ User: id }, async (err, data) => { - if (err) throw err; - if (data) { - data.BJWins++; - data.save(); - } else { - client.createProfile(id); - } - }); - }; - client.ADDSWin = id => { - econ.findOne({ User: id }, async (err, data) => { - if (err) throw err; - if (data) { - data.SlotsWins++; - data.save(); - } else { - client.createProfile(id); - } - }); - }; - client.ADDBWin = id => { - econ.findOne({ User: id }, async (err, data) => { - if (err) throw err; - if (data) { - data.BetWins++; - data.save(); - } else { - client.createProfile(id); - } - }); - }; - client.addXP = async (id, xp, message) => { - try { - const data = await econ.findOne({ User: id }); - if (data?.Gun.XP >= 0) { - data.Gun.XP += xp; - data.Gun.Level = Math.floor(0.1 * Math.sqrt(data.Gun.XP)); - await data.save().catch(e => console.log(e)); - const emoji = guns.find(z => z.name === data.Gun.Name).emoji; - if ((data.Gun.XP -= xp) < req[data.Gun.Rank]) { - message.channel.send({ - content: `Congratulations **${message.user.tag}**! Your **${emoji}${data?.Gun.Name}** has upgraded to level **${data?.Gun.Rank}**!`, - }); - } - if (data?.Gun.XP < 400) { - data.Gun.Rank = "Iron"; - await data.save().catch(e => console.log(e)); - } - if (data?.Gun.XP >= 400 && data?.Gun.XP < 1000) { - data.Gun.Rank = "Gold"; - await data.save().catch(e => console.log(e)); - } - if (data?.Gun.XP >= 1000 && data?.Gun.XP < 2000) { - data.Gun.Rank = "Platinum"; - await data.save().catch(e => console.log(e)); - } - if (data?.Gun.XP >= 2000 && data?.Gun.XP < 3500) { - data.Gun.Rank = "Diamond"; - await data.save().catch(e => console.log(e)); - } - if (data?.Gun.XP >= 3500) { - data.Gun.Rank = "Master"; - await data.save().catch(e => console.log(e)); - } - - // if (Math.floor(0.1 * Math.sqrt((data.Gun.XP -= xp))) < data.Gun.Level) { - // if (data?.Gun.Name) { - // const emoji = guns.find(z => z.name === data?.Gun.Name).emoji; - // message.channel.send({ - // content: `Congratulations **${message.user.tag}**! Your **${emoji}${data?.Gun.Name}** has upgraded to level **${data?.Gun.Level}**!`, - // }); - // } else; - // } - } else { - const ee = new econ({ - User: id, - Gun: { - XP: xp, - Level: Math.floor(0.1 * Math.sqrt(xp)), - }, - }); - if (ee?.Gun.XP >= 400 && ee?.Gun.XP < 1000) { - ee.Gun.Rank = "Gold"; - const emoji = guns.find(z => z.name === ee?.Gun.Name).emoji; - message.channel.send({ - content: `Congratulations **${message.user.tag}**! Your **${emoji}${ee?.Gun.Name}** has upgraded to rank **${ee?.Gun.Rank}**!`, - }); - await ee.save().catch(e => console.log(e)); - } - if (ee?.Gun.XP >= 1000 && ee?.Gun.XP < 2000) { - ee.Gun.Rank = "Platinum"; - const emoji = guns.find(z => z.name === ee?.Gun.Name).emoji; - message.channel.send({ - content: `Congratulations **${message.user.tag}**! Your **${emoji}${ee?.Gun.Name}** has upgraded to rank **${ee?.Gun.Rank}**!`, - }); - await ee.save().catch(e => console.log(e)); - } - if (ee?.Gun.XP >= 2000 && ee?.Gun.XP < 3500) { - ee.Gun.Rank = "Diamond"; - const emoji = guns.find(z => z.name === ee?.Gun.Name).emoji; - message.channel.send({ - content: `Congratulations **${message.user.tag}**! Your **${emoji}${ee?.Gun.Name}** has upgraded to rank **${ee?.Gun.Rank}**!`, - }); - await ee.save().catch(e => console.log(e)); - } - if (ee?.Gun.XP >= 3500) { - ee.Gun.Rank = "Master"; - const emoji = guns.find(z => z.name === ee?.Gun.Name).emoji; - message.channel.send({ - content: `Congratulations **${message.user.tag}**! Your **${emoji}${ee?.Gun.Name}** has upgraded to rank **${ee?.Gun.Rank}**!`, - }); - await ee.save().catch(e => console.log(e)); - } - await ee.save().catch(e => console.log(e)); - // if (Math.floor(0.1 * Math.sqrt(xp)) > 0) { - // if (ee?.Gun.Name) { - // const emoji = guns.find(z => z.name === ee?.Gun.Name).emoji; - // message.channel.send({ - // content: `Congratulations **${message.user.tag}**! Your **${emoji}${ee?.Gun.Name}** has upgraded to level **${ee?.Gun.Level}**!`, - // }); - // } else; - // } - } - } catch (e) { - console.log(e); - } - }; - client.cmdsUSED = id => - new Promise(async ful => { - const data = await user.findOne({ User: id }); - if (!data) { - client.createProfile(id); - } - ful(data.CommandUsed); - }); - - client.bjWin = id => - new Promise(async ful => { - const data = await econ.findOne({ User: id }); - if (!data) { - client.createProfile(id); - } - ful(data.BJWins); - }); - - client.sWin = id => - new Promise(async ful => { - const data = await econ.findOne({ User: id }); - if (!data) { - client.createProfile(id); - } - ful(data.SlotsWins); - }); - - client.bWin = id => - new Promise(async ful => { - const data = await econ.findOne({ User: id }); - if (!data) { - client.createProfile(id); - } - ful(data.BetWins); - }); -}; diff --git a/util/functions/mongoose.js b/util/functions/mongoose.js @@ -7,7 +7,6 @@ mongoose.set("useFindAndModify", false); const u = require("../../models/users"); const g = require("../../models/guilds"); const m = require("../../models/bot"); -const e = require("../../models/econ"); module.exports = { /** * @param {String} URI - Mongo Connection URI