├── README.md ├── docs ├── en │ └── readme.md └── ru │ └── readme.md ├── package.json └── src ├── commands ├── Economy │ ├── add-money.js │ ├── balance.js │ ├── biography.js │ ├── leaderboard.js │ ├── pay.js │ └── timely.js ├── Information │ └── ping.js └── Moderation │ ├── unwarn.js │ ├── warn.js │ └── warns.js ├── config.yml ├── events ├── interactionCreate.js ├── messageCreate.js └── ready.js ├── index.js └── lib ├── App.js ├── extensions ├── Discord.js └── models │ └── User.js └── utils ├── CommandsLoader.js ├── ConnectMongo.js └── EventsLoader.js /README.md: -------------------------------------------------------------------------------- 1 |
2 | Russian Guide / English Guide 3 |
4 |
5 | 6 | ## Русская часть: 7 | Приветствую! вот и дошли мои ручки спустя год переписать этот гавнакод, дак еще и на [discord.js v13](https://www.npmjs.com/package/discord.js/v/13.6.0). 8 | 9 | **Изменения:** 10 | - [X] Полная оптимизация и реабилитация. 11 | - [X] Переписано на discord.js@13.6.0. 12 | - [X] Слеш-команды и новая эко-система. 13 | 14 |
15 | 16 | **📑 Текстовая иструкция по установке:** [клик](https://github.com/nyansterowo/MongoDB-bot/tree/v2/docs/ru)
17 | 18 | **💸 Поддержать автора:** 19 | - Материально: [клик](https://www.donationalerts.com/r/reedi) 20 | - Морально: [поставить звездочку на репозиторий]() 21 | 22 |

23 | 24 | **Если у вас возникли какие-либо проблемы, пишите мне в [телеграм](https://t.me/nyansterowo).** 25 | 26 |


27 |
28 | Russian Guide / English Guide 29 |
30 |
31 | 32 | ## English part: 33 | Greetings! so my pens reached a year later to rewrite this shit code, so also on [discord.js v13](https://www.npmjs.com/package/discord.js/v/13.6.0). 34 | 35 | **Changes:** 36 | - [X] Complete optimization and rehabilitation. 37 | - [X] Rewritten on discord.js@13.6.0. 38 | - [X] Slash commands and a new ecosystem. 39 | 40 |
41 | 42 | **📑 Text installation instructions:** [клик](https://github.com/nyansterowo/MongoDB-bot/tree/v2/docs/en)
43 | 44 | **💸 Support the author:** 45 | - Financially: [клик](https://www.donationalerts.com/r/reedi) 46 | - Morally: [поставить звездочку на репозиторий]() 47 | 48 |

49 | 50 | **If you have any problems, write to me at [telegram](https://t.me/nyansterowo).** 51 | -------------------------------------------------------------------------------- /docs/en/readme.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nyansterowo/MongoDB-bot/58ee8045b36a636af492c2778bacaec810c68f16/docs/en/readme.md -------------------------------------------------------------------------------- /docs/ru/readme.md: -------------------------------------------------------------------------------- 1 | **Переходим на оффициальный сайт mongodb, [создаем](https://account.mongodb.com/account/register) новый аккаунт, либо [входим](https://account.mongodb.com/account/login) в существующий. После, если вы создали новый аккаунт, вас попросят пройти легкий вопрос-ответ:** 2 | ![](https://media.discordapp.net/attachments/970315076072509471/970591338556960808/1.png?width=942&height=480) 3 |




4 | **После чего, вас просят выбрать тариф. Мы конечно же выбираем бесплатный.** 5 | ![](https://media.discordapp.net/attachments/970315076072509471/970591338854744144/2.png?width=942&height=480) 6 |




7 | **Далее нас просят выбрать облочного провайдера и регион где будет стоять сервер: (после нажимаем на Create Cluster)** 8 | ![](https://media.discordapp.net/attachments/970315076072509471/970591339160948746/3.png?width=942&height=480) 9 |




10 | **Далее создаем пользователя для кластера, в поля вписываем желаемый ник и пароль: (после зеленую кнопку)** 11 | ![](https://media.discordapp.net/attachments/970315076072509471/970632295574822972/unknown.png?width=753&height=480) 12 | ![](https://media.discordapp.net/attachments/970315076072509471/970632534574653440/unknown.png) 13 |




14 | **Ниже, в первое поле пишим `0.0.0.0/0` и сохраняем.** 15 | ![](https://media.discordapp.net/attachments/970315076072509471/970632803970609212/unknown.png?width=810&height=480) 16 |




17 | **После всего, мы видим такую картину(если у вас по другому, значит кластер еще не создался, ждите). Нажимаем на кнопку `Connect`**
18 | ![](https://media.discordapp.net/attachments/970315076072509471/970633340807962654/unknown.png?width=942&height=480) 19 |




20 | **Выбираем второй пункт (Connect your application) и копируем ссылку:** 21 | ![](https://cdn.discordapp.com/attachments/970315076072509471/970633637991186462/unknown.png) 22 | ![](https://media.discordapp.net/attachments/970315076072509471/970633899526991882/unknown.png?width=580&height=480) 23 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "mongodb-bot", 3 | "version": "2.0.0", 4 | "description": "Discord bot based on the mongoose database", 5 | "main": "src/index.js", 6 | "scripts": { 7 | "test": "node src/index.js" 8 | }, 9 | "repository": { 10 | "type": "git", 11 | "url": "git+https://github.com/nyansterowo/MongoDB-bot.git" 12 | }, 13 | "keywords": [ 14 | "mongoose", 15 | "mongodb", 16 | "discord", 17 | "bot" 18 | ], 19 | "author": "nyansterowo", 20 | "license": "MIT", 21 | "bugs": { 22 | "url": "https://github.com/nyansterowo/MongoDB-bot/issues" 23 | }, 24 | "homepage": "https://github.com/nyansterowo/MongoDB-bot#readme", 25 | "dependencies": { 26 | "@discordjs/builders": "^0.13.0", 27 | "@discordjs/rest": "^0.4.1", 28 | "discord.js": "^13.6.0", 29 | "fs": "^0.0.1-security", 30 | "mongoose": "^6.3.1", 31 | "mongoose-findorcreate": "^3.0.0", 32 | "require-dir": "^1.2.0", 33 | "yaml": "^2.0.1" 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/commands/Economy/add-money.js: -------------------------------------------------------------------------------- 1 | const { SlashCommandBuilder } = require('@discordjs/builders'); 2 | const Model = require("../../lib/extensions/models/User"); 3 | 4 | module.exports = { 5 | data: new SlashCommandBuilder() 6 | .setName("add-money") 7 | .setDescription("Выдать баланс пользователю (либо себе).") 8 | .addNumberOption(option => option.setName('money').setDescription('Укажите количество монет.').setRequired(true)) 9 | .addUserOption(option => option.setName('user').setDescription('Укажите пользователя (необязательно).')), 10 | 11 | async execute(client, interaction) { 12 | let mention = interaction.options.getUser('user') || interaction.user; 13 | let bal = interaction.options.getNumber('money'); 14 | let user = await Model.findOrCreate({ uid: mention.id, gid: interaction.member.guild.id }, { uid: mention.id, gid: interaction.member.guild.id }); 15 | 16 | if(bal <= 0) return interaction.reply("Укажите число больше нуля."); 17 | 18 | user.doc.eco.balance += parseInt(bal); user.doc.save(); 19 | 20 | interaction.reply({ 21 | embeds: [{ 22 | color: client.config.color, 23 | description: `Пользователю **${mention.tag}** было добавлено на баланс \`${bal}$\``, 24 | }] 25 | }); 26 | } 27 | }; -------------------------------------------------------------------------------- /src/commands/Economy/balance.js: -------------------------------------------------------------------------------- 1 | const { SlashCommandBuilder } = require('@discordjs/builders'); 2 | const Model = require("../../lib/extensions/models/User"); 3 | 4 | module.exports = { 5 | data: new SlashCommandBuilder() 6 | .setName("balance") 7 | .setDescription("Посмотреть свой серверный баланс.") 8 | .addUserOption(option => option.setName('user').setDescription('Укажите пользователя (необязательно).')), 9 | 10 | async execute(client, interaction) { 11 | let mention = interaction.options.getUser('user') || interaction.user; 12 | let user = await Model.findOrCreate({ uid: mention.id, gid: interaction.member.guild.id }, { uid: mention.id, gid: interaction.member.guild.id }); 13 | 14 | interaction.reply({ 15 | embeds: [{ 16 | color: client.config.color, 17 | fields: [ 18 | { 19 | name: "Экономика:", 20 | value: `💸 **Баланс:** \`${user.doc.eco.balance}$\`\n✉️ **Сообщений:** \`${user.doc.eco.messages}\``, 21 | inline: true, 22 | }, 23 | { 24 | name: "Статус:", 25 | value: `🎇 **Опыт:** \`${user.doc.eco.xp}/${100 * user.doc.eco.level}\`\n🎈 **Уровень:** \`${user.doc.eco.level}\`\n📛 **Предупреждений:** \`${user.doc.warns.length}/3\``, 26 | inline: true, 27 | } 28 | ], 29 | description: `\`\`\`${user.doc.eco.biography}\`\`\``, 30 | thumbnail: { 31 | url: mention.displayAvatarURL({ dynamic: true }), 32 | }, 33 | }] 34 | }); 35 | } 36 | }; -------------------------------------------------------------------------------- /src/commands/Economy/biography.js: -------------------------------------------------------------------------------- 1 | const { SlashCommandBuilder } = require('@discordjs/builders'); 2 | const Model = require("../../lib/extensions/models/User"); 3 | 4 | module.exports = { 5 | data: new SlashCommandBuilder() 6 | .setName("biography") 7 | .setDescription("Изменить свою биографию в профиле.") 8 | .addStringOption(option => option.setName('bio').setDescription('Укажите новую биографию.').setRequired(true)), 9 | 10 | async execute(client, interaction) { 11 | await Model.findOneAndUpdate({ uid: interaction.user.id, gid: interaction.member.guild.id }, { '$set': { "eco.biography": interaction.options.getString('bio') } }).catch(err => {}); 12 | 13 | interaction.reply({ 14 | embeds: [{ 15 | color: client.config.color, 16 | description: `Биография была успешно обновлена!`, 17 | }] 18 | }); 19 | } 20 | }; -------------------------------------------------------------------------------- /src/commands/Economy/leaderboard.js: -------------------------------------------------------------------------------- 1 | const { SlashCommandBuilder } = require('@discordjs/builders'); 2 | const Model = require("../../lib/extensions/models/User"); 3 | 4 | module.exports = { 5 | data: new SlashCommandBuilder() 6 | .setName("leaderboard") 7 | .setDescription("Посмотреть лидеров по балансу."), 8 | 9 | async execute(client, interaction) { 10 | 11 | let db = await Model.find(); 12 | 13 | interaction.reply({ 14 | embeds: [{ 15 | color: client.config.color, 16 | description: db.splice(0, 10).filter(a => a.eco.balance > 0) 17 | .map((b, i) => `\`${i++})\` ${client.users.cache.get(b.uid)?.tag || "Unknown#0000"} - **${b.eco.balance}$**`).join("\n"), 18 | }] 19 | }); 20 | } 21 | }; -------------------------------------------------------------------------------- /src/commands/Economy/pay.js: -------------------------------------------------------------------------------- 1 | const { SlashCommandBuilder } = require('@discordjs/builders'); 2 | const Model = require("../../lib/extensions/models/User"); 3 | 4 | module.exports = { 5 | data: new SlashCommandBuilder() 6 | .setName("pay") 7 | .setDescription("Передать баланс пользователю.") 8 | .addNumberOption(option => option.setName('money').setDescription('Укажите количество монет.').setRequired(true)) 9 | .addUserOption(option => option.setName('user').setDescription('Укажите пользователя (необязательно).').setRequired(true)), 10 | 11 | async execute(client, interaction) { 12 | let mention = interaction.options.getUser('user'); 13 | let bal = interaction.options.getNumber('money'); 14 | 15 | if(mention.id == interaction.user.id) return interaction.reply("Зачем передать баланс самому себе?"); 16 | 17 | let user1 = await Model.findOrCreate({ uid: interaction.user.id, gid: interaction.member.guild.id }, { uid: interaction.user.id, gid: interaction.member.guild.id }); 18 | let user2 = await Model.findOrCreate({ uid: mention.id, gid: interaction.member.guild.id }, { uid: mention.id, gid: interaction.member.guild.id }); 19 | 20 | if(user1.doc.eco.balance < bal) return interaction.reply("У вас нет столько денег!"); 21 | 22 | user1.doc.eco.balance -= parseInt(bal); user1.doc.save(); 23 | user2.doc.eco.balance += parseInt(bal); user2.doc.save(); 24 | 25 | 26 | interaction.reply({ 27 | embeds: [{ 28 | color: client.config.color, 29 | description: `Пользователь **${interaction.user.tag}** передал своему другу **${mention.tag}** баланс в размере \`${bal}$\``, 30 | }] 31 | }); 32 | } 33 | }; -------------------------------------------------------------------------------- /src/commands/Economy/timely.js: -------------------------------------------------------------------------------- 1 | const { SlashCommandBuilder } = require('@discordjs/builders'); 2 | const Model = require("../../lib/extensions/models/User"); 3 | 4 | module.exports = { 5 | data: new SlashCommandBuilder() 6 | .setName("timely") 7 | .setDescription("Получить ежедневный бонус"), 8 | 9 | async execute(client, interaction) { 10 | let user = await Model.findOrCreate({ uid: interaction.user.id, gid: interaction.member.guild.id }, { uid: interaction.user.id, gid: interaction.member.guild.id }); 11 | 12 | let money = Math.floor(Math.random() * 5000) 13 | if(Date.now() < user.doc.eco.timelytime) return interaction.reply("Вы недавно забрали свой бонус, приходите чуть позже."); 14 | user.doc.eco.balance += parseInt(money); user.doc.eco.timelytime = Date.now() + 8.64e+7; user.doc.save() 15 | 16 | interaction.reply({ 17 | embeds: [{ 18 | color: client.config.color, 19 | description: `На ваш баланс успешно было добавлено \`${money}$\`.`, 20 | }] 21 | }); 22 | } 23 | }; -------------------------------------------------------------------------------- /src/commands/Information/ping.js: -------------------------------------------------------------------------------- 1 | const { SlashCommandBuilder } = require('@discordjs/builders'); 2 | 3 | module.exports = { 4 | data: new SlashCommandBuilder() 5 | .setName("ping") 6 | .setDescription("Получить пинг бота."), 7 | 8 | async execute(client, interaction) { 9 | 10 | const sent = await interaction.reply({ content: 'Pinging...', fetchReply: true }); 11 | interaction.editReply(`Websocket heartbeat: ${client.ws.ping}ms.\nRoundtrip latency: ${sent.createdTimestamp - interaction.createdTimestamp}ms`); 12 | } 13 | }; -------------------------------------------------------------------------------- /src/commands/Moderation/unwarn.js: -------------------------------------------------------------------------------- 1 | const { SlashCommandBuilder } = require('@discordjs/builders'); 2 | const Model = require("../../lib/extensions/models/User"); 3 | 4 | module.exports = { 5 | data: new SlashCommandBuilder() 6 | .setName("unwarn") 7 | .setDescription("Выдать предупреждение пользователю.") 8 | .addUserOption(option => option.setName('user').setDescription('Укажите пользователя.').setRequired(true)) 9 | .addNumberOption(option => option.setName('case-id').setDescription('Укажите айди предупреждения.').setRequired(true)), 10 | 11 | async execute(client, interaction) { 12 | let mention = interaction.options.getUser('user'); 13 | let caseid = interaction.options.getNumber('case-id'); 14 | 15 | let user = await Model.findOrCreate({ uid: mention.id, gid: interaction.member.guild.id }, { uid: mention.id, gid: interaction.member.guild.id }); 16 | let inarray = user.doc.warns.find(x => x.caseid == caseid); 17 | 18 | if(!inarray) return interaction.reply("Предупреждения под данный айди нет."); 19 | user.doc.warns.splice(user.doc.warns.indexOf(inarray), 1); user.doc.save(); 20 | 21 | interaction.reply({ 22 | embeds: [{ 23 | color: client.config.color, 24 | description: `Администратор **${interaction.user.tag}** успешно снял предупреждение у пользователя **${mention.tag}** \`(${user.doc.warns.length}/3)\``, 25 | }] 26 | }); 27 | } 28 | }; -------------------------------------------------------------------------------- /src/commands/Moderation/warn.js: -------------------------------------------------------------------------------- 1 | const { SlashCommandBuilder } = require('@discordjs/builders'); 2 | const Model = require("../../lib/extensions/models/User"); 3 | 4 | module.exports = { 5 | data: new SlashCommandBuilder() 6 | .setName("warn") 7 | .setDescription("Выдать предупреждение пользователю.") 8 | .addUserOption(option => option.setName('user').setDescription('Укажите пользователя.').setRequired(true)) 9 | .addStringOption(option => option.setName('reason').setDescription('Укажите причину предупреждения.').setRequired(true)), 10 | 11 | async execute(client, interaction) { 12 | let mention = interaction.options.getUser('user'); 13 | let res = interaction.options.getString('reason'); 14 | 15 | if(mention.id == interaction.user.id) return interaction.reply("Зачем давать предупреждение самому себе?"); 16 | let user = await Model.findOrCreate({ uid: mention.id, gid: interaction.member.guild.id }, { uid: mention.id, gid: interaction.member.guild.id }); 17 | 18 | user.doc.warns.push({ caseid: user.doc.warns.length, mod: interaction.user.id, reason: res }); user.doc.save(); 19 | 20 | if(user.doc.warns.length >= 3) { 21 | await interaction.guild.members.ban(interaction.options.getUser('user')) 22 | .then(interaction.reply("Пользователь получил много жалоб, он был заблокирован на сервере. \`(3/3)\`")) 23 | .catch(interaction.reply("Пользователь получил много предупреждений, но я не смог его выгнать потому-что, у меня нет прав. \`(3/3)\`")); 24 | } else await interaction.reply({ 25 | embeds: [{ 26 | color: client.config.color, 27 | description: `Администратор **${interaction.user.tag}** успешно выдал предупреждение пользователю **${mention.tag}** \`(${user.doc.warns.length}/3)\``, 28 | }] 29 | }); 30 | } 31 | }; 32 | -------------------------------------------------------------------------------- /src/commands/Moderation/warns.js: -------------------------------------------------------------------------------- 1 | const { SlashCommandBuilder } = require('@discordjs/builders'); 2 | const Model = require("../../lib/extensions/models/User"); 3 | 4 | module.exports = { 5 | data: new SlashCommandBuilder() 6 | .setName("warns") 7 | .setDescription("Посмотреть список своих предупреждений."), 8 | 9 | async execute(client, interaction) { 10 | let user = await Model.findOrCreate({ uid: interaction.user.id, gid: interaction.member.guild.id }, { uid: interaction.user.id, gid: interaction.member.guild.id }); 11 | 12 | interaction.reply({ 13 | embeds: [{ 14 | color: client.config.color, 15 | description: user.doc.warns.map((x) => `\`${x.caseid})\` <@${x.mod}> - ${x.reason}`).join("\n") || "В данный момент у вас нет предупреждений!", 16 | }] 17 | }); 18 | } 19 | }; -------------------------------------------------------------------------------- /src/config.yml: -------------------------------------------------------------------------------- 1 | token: " " 2 | database: " " 3 | 4 | color: "#7764f1" -------------------------------------------------------------------------------- /src/events/interactionCreate.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | name: "interactionCreate", 3 | once: false, 4 | async execute(client, interaction) { 5 | if (!interaction.isCommand()) return; 6 | const command = client.commands.get(interaction.commandName); 7 | if (!command) return; 8 | 9 | try { 10 | await command.execute(client, interaction); 11 | } catch (error) { 12 | await interaction.reply({ content: `Произошла ошибка во время выполнения команды.\n\`\`\`${error}\`\`\``, ephemeral: true }); 13 | } 14 | }, 15 | }; -------------------------------------------------------------------------------- /src/events/messageCreate.js: -------------------------------------------------------------------------------- 1 | const Model = require("../lib/extensions/models/User"); 2 | 3 | module.exports = { 4 | name: 'messageCreate', 5 | once: true, 6 | async execute(client, message) { 7 | if(message.author.bot == true) return; 8 | 9 | const user = await Model.findOrCreate({ uid: message.author.id, gid: message.guildId }, { uid: message.author.id, gid: message.guildId }); 10 | 11 | if(user.doc.eco.xp >= 100 * user.doc.eco.level) { 12 | user.doc.eco.xp -= Number(100 * user.doc.eco.level); 13 | user.doc.eco.level++; 14 | 15 | user.doc.eco.balance += Math.floor(Math.random() * 100); 16 | 17 | message.channel.send({ 18 | embeds: [{ 19 | color: client.config.color, 20 | description: `🎉 Поздравляю **${message.author.tag}**, теперь у вас \`${user.doc.eco.level}\` уровень.`, 21 | }] 22 | }) 23 | } else user.doc.eco.xp++; 24 | 25 | user.doc.eco.messages++; 26 | user.doc.save(); 27 | }, 28 | }; -------------------------------------------------------------------------------- /src/events/ready.js: -------------------------------------------------------------------------------- 1 | const { REST } = require('@discordjs/rest'); 2 | const { Routes } = require('discord-api-types/v9'); 3 | 4 | module.exports = { 5 | name: 'ready', 6 | once: true, 7 | async execute(client) { 8 | const rest = new REST({ version: "9" }).setToken(client.config.token); 9 | 10 | client.guilds.cache.forEach(async x => { 11 | try { 12 | await rest.put(Routes.applicationGuildCommands(client.user.id, x.id), { body: client.list }) 13 | } catch (err) { 14 | console.error(`Failed to update the list of slash commands on the server with id — ${x.id} (${err.message})`) 15 | } 16 | }); 17 | 18 | delete client.list; 19 | }, 20 | }; -------------------------------------------------------------------------------- /src/index.js: -------------------------------------------------------------------------------- 1 | const Sampl = require("./lib/App"); 2 | const client = new Sampl(); 3 | client.start(true); -------------------------------------------------------------------------------- /src/lib/App.js: -------------------------------------------------------------------------------- 1 | const { Client, Collection } = require("discord.js"); 2 | const discord = require("./extensions/Discord.js"); 3 | 4 | const { parse: parseYaml } = require("yaml"); 5 | const { readFileSync } = require("fs"); 6 | 7 | require("require-dir")("./utils", { extensions: [".js"] }); 8 | 9 | class SampleClient extends Client { 10 | constructor() { 11 | super({ ...discord }); 12 | 13 | this.commands = new Collection(); 14 | this.config = parseYaml(readFileSync("./src/config.yml", "utf8")); 15 | } 16 | 17 | start(load) { 18 | this.login(this.config.token) 19 | .then(console.log(`[DISCORD] The application has successfully connected to the discord api`)) 20 | .catch(err => console.error(`[DISCORD] Error: ${err.message}`)); 21 | 22 | if(load == true) this.preloadall(); 23 | } 24 | 25 | preloadall() { 26 | EventsLoader(this); 27 | CommandsLoader(this); 28 | ConnectMongo(this.config); 29 | } 30 | 31 | distroy() { 32 | process.exit(); 33 | } 34 | } 35 | 36 | module.exports = SampleClient; -------------------------------------------------------------------------------- /src/lib/extensions/Discord.js: -------------------------------------------------------------------------------- 1 | const { Intents } = require('discord.js'); 2 | 3 | module.exports = { 4 | disableEveryone: true, 5 | disableMentions: 'everyone', 6 | fetchAllMembers: false, 7 | 8 | restTimeOffset: 0, 9 | failIfNotExists: false, 10 | shards: "auto", 11 | allowedMentions: { 12 | parse: ["roles", "users"], 13 | repliedUser: false, 14 | }, 15 | 16 | partials: ['MESSAGE', 'CHANNEL', 'REACTION', 'GUILD_MEMBER', 'USER'], 17 | intents: [ 18 | Intents.FLAGS.GUILDS, 19 | Intents.FLAGS.GUILD_MEMBERS, 20 | Intents.FLAGS.GUILD_BANS, 21 | Intents.FLAGS.GUILD_EMOJIS_AND_STICKERS, 22 | Intents.FLAGS.GUILD_INTEGRATIONS, 23 | Intents.FLAGS.GUILD_WEBHOOKS, 24 | Intents.FLAGS.GUILD_INVITES, 25 | Intents.FLAGS.GUILD_VOICE_STATES, 26 | Intents.FLAGS.GUILD_PRESENCES, 27 | Intents.FLAGS.GUILD_MESSAGES, 28 | Intents.FLAGS.GUILD_MESSAGE_REACTIONS, 29 | Intents.FLAGS.DIRECT_MESSAGES, 30 | Intents.FLAGS.DIRECT_MESSAGE_REACTIONS, 31 | ], 32 | 33 | presence: { 34 | activities: [{ name: "tg: @nyansterowo", type: "PLAYING" }], 35 | status: "online" 36 | } 37 | }; -------------------------------------------------------------------------------- /src/lib/extensions/models/User.js: -------------------------------------------------------------------------------- 1 | const { Schema, model } = require('mongoose'); 2 | const findorcreate = require('mongoose-findorcreate'); 3 | 4 | const User = Schema({ 5 | uid: { type: String, default: null }, 6 | gid: { type: String, default: null }, 7 | 8 | eco: { 9 | balance: { type: Number, default: 0 }, 10 | xp: { type: Number, default: 0 }, 11 | level: { type: Number, default: 1 }, 12 | 13 | timelytime: { type: Number, default: 0 }, 14 | 15 | messages: { type: Number, default: 0 }, 16 | biography: { type: String, default: ">_<" }, 17 | }, 18 | 19 | warns: { type: Array, default: [] } 20 | }); 21 | 22 | User.plugin(findorcreate); 23 | module.exports = model("User", User) -------------------------------------------------------------------------------- /src/lib/utils/CommandsLoader.js: -------------------------------------------------------------------------------- 1 | const fs = require('fs'); 2 | const path = require('path'); 3 | 4 | function findFiles(folderPath){ 5 | const files = [] 6 | folderPath = path.isAbsolute(folderPath) ? folderPath : path.join(process.cwd(), folderPath) 7 | const folder = fs.readdirSync(folderPath, { withFileTypes: true }) 8 | 9 | for(const file of folder){ 10 | const pathFile = path.join(folderPath, file.name) 11 | if(file.isDirectory()){ 12 | files.push(...findFiles(pathFile)) 13 | continue 14 | } 15 | files.push(pathFile) 16 | } 17 | return files; 18 | } 19 | 20 | CommandsLoader = async(client) => { 21 | client.list = []; 22 | for(const file of findFiles("./src/commands/")){ 23 | try { 24 | const { dir, base } = path.parse(file); 25 | const command = require(file); 26 | 27 | client.list.push(command.data.toJSON()); 28 | client.commands.set(command.data.name, command); 29 | }catch(err) { 30 | console.error(`[COMMANDS] Command ${file.split("src\\commands\\")[1]} failed to load. ${err.message.split("\n")[0]}`); 31 | } 32 | } 33 | } 34 | 35 | module.exports = CommandsLoader; -------------------------------------------------------------------------------- /src/lib/utils/ConnectMongo.js: -------------------------------------------------------------------------------- 1 | const { connect, connection } = require("mongoose"); 2 | 3 | ConnectMongo = (config) => { 4 | connect(config.database, { useNewUrlParser: true, useUnifiedTopology: true }); 5 | 6 | connection.on("connected", () => console.log("[DATABASE] Successfully connected to MongoDB!")) 7 | connection.on("error", (e) => console.error(`[DATABASE] An error occurred while connecting to the database. ${e.message}`)); 8 | } 9 | 10 | 11 | module.exports = ConnectMongo; -------------------------------------------------------------------------------- /src/lib/utils/EventsLoader.js: -------------------------------------------------------------------------------- 1 | const { promisify } = require("util"); 2 | const readdir = promisify(require("fs").readdir); 3 | 4 | EventsLoader = async(client) => { 5 | const eventFiles = await readdir("src/events"); 6 | 7 | for (const file of eventFiles) { 8 | if (!file.endsWith(".js")) return; 9 | 10 | const event = require(`../../events/${file}`); 11 | if (event.once) { 12 | client.once(event.name, (...args) => event.execute(client, ...args)); 13 | } else { 14 | client.on(event.name, (...args) => event.execute(client, ...args)); 15 | } 16 | } 17 | } 18 | 19 | module.exports = EventsLoader; --------------------------------------------------------------------------------