├── LICENSE ├── commands ├── public │ └── ping.js └── settings │ ├── prefix.js │ └── startlogs.js ├── config.js ├── events ├── anticrash │ └── unhandledRejection.js ├── client │ ├── ready.js │ ├── readyCheckDB.js │ ├── readyLogs.js │ └── readySlashCmds.js ├── guild │ └── guildCreate.js ├── interaction │ └── forContextMenu.js └── message │ └── messageCreate.js ├── index.js ├── package.json ├── readme.md ├── slashCmds └── public │ └── getMessageContent.js └── structures ├── checkForData.js ├── client └── index.js ├── database └── model.js └── utils └── index.js /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2021 Jeotique 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /commands/public/ping.js: -------------------------------------------------------------------------------- 1 | const {Bot} = require('../../structures/client') 2 | const Discord = require('discord.js') 3 | 4 | module.exports = { 5 | name: 'ping', 6 | aliases: ['speed'], 7 | 8 | /** 9 | * 10 | * @param {Bot} client 11 | * @param {Discord.Message} message 12 | * @param {*} args 13 | * @param {string} commandName 14 | */ 15 | run: async(client, message, args, commandName)=>{ 16 | try{ 17 | const embed = new Discord.MessageEmbed() 18 | embed.setTitle('PING') 19 | embed.addField('BOT', `${client.ws.ping}ms`, true) 20 | embed.setColor('BLUE') 21 | message.channel.send({embeds: [embed]}).then(msg => { 22 | let api = msg.createdAt - message.createdAt 23 | embed.addField("API", `${api}ms`, true) 24 | return msg.edit({embeds: [embed]}).catch(e=>{}) 25 | }).catch(e=>{}) 26 | }catch(err){ 27 | console.log(`[Error - ${commandName.toUpperCase()}] : ${err}`) 28 | } 29 | } 30 | } -------------------------------------------------------------------------------- /commands/settings/prefix.js: -------------------------------------------------------------------------------- 1 | const {Bot} = require('../../structures/client') 2 | const Discord = require('discord.js') 3 | 4 | module.exports = { 5 | name: 'prefix', 6 | aliases: ['setprefix'], 7 | 8 | /** 9 | * 10 | * @param {Bot} client 11 | * @param {Discord.Message} message 12 | * @param {*} args 13 | * @param {string} commandName 14 | */ 15 | run: async(client, message, args, commandName)=>{ 16 | try{ 17 | if(!message.member.permissions.has('MANAGE_GUILD') && !client.config.owners.includes(message.author.id)) return message.reply(`:x: You don't have the permission to use this command.`).catch(e=>{}) 18 | let newprefix = args[0] 19 | if(!newprefix) return message.channel.send("You didn't gave me any prefix.").catch(e=>{}) 20 | let currentprefix = await client.db.getOne('settings', [{serverid: message.guildId}], 'prefix') || client.config.prefix 21 | if(newprefix===currentprefix) return message.channel.send(`The prefix is exacly the same of my current one.`).catch(e=>{}) 22 | client.db.set('settings', [{serverid: message.guildId}], 'prefix', newprefix) 23 | await message.channel.send(`My new prefix is \`${newprefix}\``).catch(e=>{}) 24 | client.db.save('settings', ['prefix'], [{serverid: message.guildId}]).catch(e=>{ 25 | console.log(`Error during the save of the prefix in the database : ${e}`) 26 | }) 27 | }catch(err){ 28 | console.log(`[Error - ${commandName.toUpperCase()}] : ${err}`) 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /commands/settings/startlogs.js: -------------------------------------------------------------------------------- 1 | const {Bot} = require('../../structures/client') 2 | const Discord = require('discord.js') 3 | 4 | module.exports = { 5 | name: 'startlogs', 6 | aliases: ['startlog'], 7 | 8 | /** 9 | * 10 | * @param {Bot} client 11 | * @param {Discord.Message} message 12 | * @param {*} args 13 | * @param {string} commandName 14 | */ 15 | run: async(client, message, args, commandName)=>{ 16 | try{ 17 | if(!message.member.permissions.has('MANAGE_GUILD') && !client.config.owners.includes(message.author.id)) return message.reply(`:x: You don't have the permission to use this command.`).catch(e=>{}) 18 | let mention = message.mentions.channels.first()?.id || message.guild.channels.cache.filter(c=>c.type!=='GUILD_VOICE').get(args[0])?.id || message.channelId 19 | if(!mention) return message.reply("You didn't gave me any valid channel.").catch(e=>{}) 20 | let currentchannel = await client.db.getOne('channels', [{serverid: message.guildId}], 'startlogs') || client.config.prefix 21 | if(mention===currentchannel) return message.channel.send(`The channel is exacly the same of the current one.`).catch(e=>{}) 22 | client.db.set('channels', [{serverid: message.guildId}], 'startlogs', mention) 23 | await message.channel.send(`The new start logs channel is <#${mention}>`).catch(e=>{}) 24 | client.db.save('channels', ['startlogs'], [{serverid: message.guildId}]).catch(e=>{ 25 | console.log(`Error during the save of the startlogs in the database : ${e}`) 26 | }) 27 | }catch(err){ 28 | console.log(`[Error - ${commandName.toUpperCase()}] : ${err}`) 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | owners: ['467433131692261378'], 3 | token: 'your token goes here', 4 | prefix: '+', 5 | 6 | database: { 7 | host: '127.0.0.1', 8 | user: 'admin', 9 | pass: 'mysecretpass', 10 | database: 'local', 11 | } 12 | } -------------------------------------------------------------------------------- /events/anticrash/unhandledRejection.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | name: 'unhandledRejection', 3 | 4 | run: async(client, reason, p)=>{ 5 | console.log(p) 6 | return console.log(`[ERROR CATCH] \nReason : ${reason}`) 7 | } 8 | } -------------------------------------------------------------------------------- /events/client/ready.js: -------------------------------------------------------------------------------- 1 | const Discord = require('discord.js') 2 | let getNow = () => { return { time: new Date().toLocaleString("en-EN", { timeZone: "Europe/Paris", hour12: false, hour: "2-digit", minute: "2-digit", second: "2-digit" }) } } 3 | module.exports = { 4 | name: 'ready', 5 | 6 | run: async (client) => { 7 | console.clear() 8 | const chalk = require('chalk') 9 | console.log(chalk.green.bold("Connected !")) 10 | console.log(chalk.gray("Logged into"), chalk.yellow(`${client.user.tag}`)); 11 | console.log( 12 | chalk.white("Looking"), 13 | chalk.red(`${client.guilds.cache.reduce((a, b) => a + b.memberCount, 0)}`), 14 | chalk.white(`${client.guilds.cache.reduce((a, b) => a + b.memberCount, 0) > 1 ? "Members," : "Member,"}`), 15 | chalk.red(`${client.guilds.cache.size}`), 16 | chalk.white(`${client.guilds.cache.size > 1 ? "Servers." : "Server."}`) 17 | ) 18 | console.log( 19 | chalk.white(`Prefix :` + chalk.red(` ${client.config.prefix}`)), 20 | chalk.white("||"), 21 | chalk.red(`${client.commands.size}`), 22 | chalk.white(`Commands`), 23 | chalk.white('||'), 24 | chalk.red(`${client.aliases.size}`), 25 | chalk.white('Aliases') 26 | ); 27 | console.log("") 28 | console.log(chalk.red.bold("——————————[Statistics]——————————")) 29 | console.log(chalk.gray(`Working with ${process.version} on ${process.platform} ${process.arch}`)) 30 | console.log(chalk.gray(`Memory : ${(process.memoryUsage().rss / 1024 / 1024).toFixed(2)} MB RSS\n${(process.memoryUsage().heapUsed / 1024 / 1024).toFixed(2)} MB`)) 31 | console.log(`${chalk.cyan(getNow().time)} - ${chalk.green("Restart")}`) 32 | client.guilds.cache.map(async guild => { 33 | await guild.members.fetch().catch(e => { }) 34 | }) 35 | await client.users.fetch().catch(e => { }) 36 | client.user.setActivity(`${client.guilds.cache.size} servers || ${client.users.cache.size} members`, { type: 'STREAMING', url: "https://www.twitch.tv/Jeotique" }) 37 | setInterval(async () => { 38 | client.user.setActivity(`${client.guilds.cache.size} servers || ${client.users.cache.size} members`, { type: 'STREAMING', url: "https://www.twitch.tv/Jeotique" }) 39 | }, 120000) 40 | } 41 | } -------------------------------------------------------------------------------- /events/client/readyCheckDB.js: -------------------------------------------------------------------------------- 1 | const {Bot} = require('../../structures/client') 2 | const Discord = require('discord.js') 3 | const checkDB = require('../../structures/checkForData') 4 | 5 | module.exports = { 6 | name: 'ready', 7 | 8 | /** 9 | * @param {Bot} client 10 | */ 11 | run: async(client)=>{ 12 | if(client.guilds.cache.size < 1) return 13 | client.guilds.cache.map(async guild => { 14 | checkDB(client, guild) 15 | }) 16 | } 17 | }; -------------------------------------------------------------------------------- /events/client/readyLogs.js: -------------------------------------------------------------------------------- 1 | const {Bot} = require('../../structures/client') 2 | const Discord = require('discord.js'); 3 | 4 | module.exports = { 5 | name: 'ready', 6 | 7 | /** 8 | * @param {Bot} client 9 | */ 10 | run: async(client)=>{ 11 | if(client.guilds.cache.size < 1) return 12 | client.guilds.cache.map(async guild => { 13 | let logsid = await client.db.get('channels', [{serverid: guild.id}], 'startlogs') 14 | if(!logsid) return 15 | const channel = guild.channels.cache.get(logsid[0]) 16 | if(!channel) return 17 | channel.send(`The bot is online.`).catch(e=>{}) 18 | }) 19 | } 20 | }; -------------------------------------------------------------------------------- /events/client/readySlashCmds.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | name: 'ready', 3 | 4 | run: async(client)=>{ 5 | try{ 6 | await client.functions.sleep(3000) 7 | client.guilds.cache.forEach(async guild => { 8 | guild.commands.set(client.slashCommands).catch(e=>{}) 9 | }) 10 | }catch(err){ 11 | console.log('readySlashCmds error : '+err) 12 | } 13 | } 14 | } -------------------------------------------------------------------------------- /events/guild/guildCreate.js: -------------------------------------------------------------------------------- 1 | const {Bot} = require('../../structures/client') 2 | const Discord = require('discord.js') 3 | const checkDB = require('../../structures/checkForData') 4 | 5 | module.exports = { 6 | name: 'guildCreate', 7 | 8 | /** 9 | * @param {Bot} client 10 | * @param {Discord.Guild} guild 11 | */ 12 | run: async(client, guild)=>{ 13 | if(!guild.available) return 14 | checkDB(client, guild) 15 | } 16 | }; -------------------------------------------------------------------------------- /events/interaction/forContextMenu.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | name: 'interactionCreate', 3 | 4 | run: async(client, interaction)=>{ 5 | try{ 6 | if(interaction.isContextMenu()){ 7 | const command = client.slashCommands.get(interaction.commandName) 8 | if(!command) return 9 | command.run(client, interaction, command.name) 10 | } 11 | }catch(err){ 12 | console.log('forContextMenu error : '+err) 13 | } 14 | } 15 | } -------------------------------------------------------------------------------- /events/message/messageCreate.js: -------------------------------------------------------------------------------- 1 | const { Bot } = require('../../structures/client') 2 | const Discord = require('discord.js') 3 | module.exports = { 4 | name: 'messageCreate', 5 | 6 | /** 7 | * 8 | * @param {Bot} client 9 | * @param {Discord.Message} message 10 | */ 11 | run: async (client, message) => { 12 | try { 13 | if (!message) return 14 | if (!message.guild || !message.author) return 15 | if(message.author.bot) return 16 | let prefix = await client.db.getOne('settings', [{ serverid: message.guildId }], 'prefix') || client.config.prefix 17 | checkForSettings() 18 | if (message.content === `<@${client.user.id}>` || message.content === `<@!${client.user.id}>`) return message.reply(`My prefix is \`${prefix}\``).catch(e => { }) 19 | if (!message.content.startsWith(prefix) || message.content === prefix || message.content.startsWith(prefix + ' ')) prefix = `<@${client.user.id}>` 20 | if (!message.content.startsWith(prefix) || message.content === prefix || message.content.startsWith(prefix + ' ')) prefix = `<@!${client.user.id}>` 21 | if (!message.content.startsWith(prefix) || message.content === prefix || message.content.startsWith(prefix + ' ')) return 22 | const args = message.content.slice(prefix.length).trim().split(/ +/g) 23 | const commandName = args[0].toLowerCase().normalize() 24 | const cmd = client.commands.get(commandName) || client.aliases.get(commandName) 25 | args.shift() 26 | if (!cmd) return 27 | cmd.run(client, message, args, commandName) 28 | 29 | async function checkForSettings(){ 30 | let all = await client.db.getAllWhere('settings', [{serverid: message.guildId}]) 31 | if(all.length < 1) return (await client.db.insert('settings', {serverid: message.guildId, prefix: client.config.prefix})).save('settings', ['serverid', 'prefix'], [{serverid: message.guildId}]) 32 | } 33 | } catch (err) { 34 | console.log("messageCreate error : " + err) 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | const {Bot} = require('./structures/client') 2 | new Bot() -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "dependencies": { 3 | "chalk": "^4.1.2", 4 | "discord.js": "^13.3.1", 5 | "mxtorie": "^0.8.0", 6 | "mysql": "^2.18.1" 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /readme.md: -------------------------------------------------------------------------------- 1 | **Template handler** 2 | 3 | This template created by Jeotique is for newcomer. 4 | This handler is working with mysql database and the module ``mxtorie`` [npm here with documentation](https://www.npmjs.com/package/mxtorie) 5 | 6 | **How to start ?** 7 | 8 | **First step :** 9 | - `npm i discord.js` 10 | - `npm i mxtorie` 11 | - `npm i mysql` 12 | - `npm i chalk` 13 | 14 | **Second step :** 15 | Open the file `config.js` and change the token, etc 16 | Don't forget to change the database connection properties too. 17 | ![image](https://user-images.githubusercontent.com/71186872/141164368-505e8878-3740-4816-8ec0-8775e6520f41.png) 18 | 19 | **Third step :** 20 | Open the file `model.js` in `./structures/database` and edit it with what you want. 21 | **Don't remove 'serverid' and 'prefix' because example commands is working with it.** 22 | ![image](https://user-images.githubusercontent.com/71186872/141164425-44f6adc2-3b5b-4d26-8208-778175d17ce9.png) 23 | 24 | **If you edit the model.js for don't forget to edit the file `structures/checkForData.js` too** 25 | ![image](https://user-images.githubusercontent.com/71186872/141292515-98310658-1bee-4bed-8992-923254905fde.png) 26 | In blue its the key (name of the table), in red its the values, you insert in 'settings' a new line with values : 'serverid': 'id of the guild' and 'prefix': '+' 27 | If you add something in the `model.js` you will need to add it, example : i add in the 'settings' table : 28 | ```js 29 | { 30 | name: 'support', 31 | type: datatype.VARCHAR, 32 | length: 10 33 | } 34 | ``` 35 | In `checkForData.js` i will add : 36 | ```js 37 | (await client.db.insert('settings', {serverid: guild.id, prefix: client.config.prefix, support: 'off'})).save('settings', ['serverid', 'prefix', 'support'], [{serverid: guild.id}]) 38 | ``` 39 | 40 | In `save()` in red you have an array, its the value what you want to save in the database, and in purple its where you want to save (so here you save where `'serverid' = 'the guild id'`) 41 | 42 | Above where you have `let settings = await client.db.getAllWhere('settings', [{serverid: guild.id}])` you get every data in the cache where `serverid = 'the guild id'` and you check the length of the result (its returning an array, the `await` is very important because its a **promise**) `if(settings.length < 1)` and if the length is under 1 you will insert the data in the cache and save it after with `.save()` 43 | 44 | **Final step :** 45 | `node .` in your console to start the bot. 46 | 47 | **For any support you can find me here : [discord link](https://discord.gg/mxtorie)** 48 | (The server is french but i can answer to english too) 49 | -------------------------------------------------------------------------------- /slashCmds/public/getMessageContent.js: -------------------------------------------------------------------------------- 1 | const Discord = require('discord.js') 2 | const fs = require('fs') 3 | module.exports = { 4 | name: 'Get message content', 5 | type: 'MESSAGE', 6 | 7 | run: async(client, interaction, commandName)=>{ 8 | try{ 9 | await interaction.deferReply({ephemeral: true}).catch(e=>{}) 10 | const message = await interaction.channel.messages.fetch(interaction.targetId).catch(e=>{}) 11 | 12 | if(!message) return interaction.followUp({content: "Error : can't get the message."}).catch(e=>{}) 13 | return interaction.followUp({content: message.content?message.content:'\`no content\`'}).catch(e=>{}) 14 | 15 | }catch(err){ 16 | console.log(`${commandName.toUpperCase()} [ERROR] : ${err}`) 17 | } 18 | } 19 | } -------------------------------------------------------------------------------- /structures/checkForData.js: -------------------------------------------------------------------------------- 1 | const {Bot} = require('./client') 2 | const Discord = require('discord.js') 3 | /** 4 | * 5 | * @param {Bot} client 6 | * @param {Discord.Guild} guild 7 | */ 8 | module.exports = async(client, guild)=>{ 9 | let settings = await client.db.getAllWhere('settings', [{serverid: guild.id}]) 10 | if(settings.length < 1){ 11 | (await client.db.insert('settings', {serverid: guild.id, prefix: client.config.prefix})).save('settings', ['serverid', 'prefix'], [{serverid: guild.id}]) 12 | } 13 | let channels = await client.db.getAllWhere('channels', [{serverid: guild.id}]) 14 | if(channels.length < 1){ 15 | (await client.db.insert('channels', {serverid: guild.id, startlogs: '-'})).save('channels', ['serverid', 'startlogs'], [{serverid: guild.id}]) 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /structures/client/index.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Template handler for github [Jeotique] 3 | */ 4 | 5 | const { Client, Intents, Collection } = require('discord.js') 6 | const managers = require('mxtorie') //this module is created by Jeotique too, if you get any problem with contact me on my discord server discord.gg/mxtorie 7 | const model = require('../database/model') //this is the model for the database, you can add or remove column in 8 | const fs = require('fs') 9 | 10 | class Bot extends Client { 11 | constructor(options = { 12 | fetchAllMembers: true, 13 | restTimeOffset: 1, 14 | intents: [Intents.FLAGS.GUILD_EMOJIS_AND_STICKERS, Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_MESSAGES, Intents.FLAGS.GUILD_VOICE_STATES, Intents.FLAGS.GUILD_PRESENCES, Intents.FLAGS.GUILD_MEMBERS, Intents.FLAGS.GUILD_WEBHOOKS, Intents.FLAGS.GUILD_MESSAGE_REACTIONS, Intents.FLAGS.GUILD_BANS, Intents.FLAGS.GUILD_INVITES, Intents.FLAGS.GUILD_INTEGRATIONS, Intents.FLAGS.DIRECT_MESSAGES, Intents.FLAGS.DIRECT_MESSAGE_REACTIONS, Intents.FLAGS.DIRECT_MESSAGE_TYPING], 15 | partials: ['CHANNEL'] 16 | }) { 17 | super(options); 18 | this.setMaxListeners(15) 19 | 20 | this.commands = new Collection() 21 | this.aliases = new Collection() 22 | this.slashCommands = new Collection() 23 | this.config = require('../../config') 24 | this.functions = require('../utils') 25 | this.initCommands() 26 | this.initEvents() 27 | this.initSlashCommands() 28 | this.db = new managers.database({ 29 | host: this.config.database.host, 30 | user: this.config.database.user, 31 | pass: this.config.database.pass, 32 | database: this.config.database.database 33 | }, model) 34 | this.db.connectToDb().then(() => { 35 | setTimeout(() => { 36 | console.log('Connecting to the token...') 37 | this.login(this.config.token).catch(e => { 38 | console.error("Fatal error : \nToken connection failed : " + e) 39 | }) 40 | }, 3000) // THIS TIMEOUT IS IMPORTANT 41 | }).catch(e => console.log("Error during the connection to the database : " + e)) 42 | } 43 | 44 | initCommands() { 45 | const subFolders = fs.readdirSync('./commands') 46 | for (const category of subFolders) { 47 | const commandsFiles = fs.readdirSync(`./commands/${category}`).filter(file => file.endsWith('.js')) 48 | for (const commandFile of commandsFiles) { 49 | const command = require(`../../commands/${category}/${commandFile}`) 50 | this.commands.set(command.name, command) 51 | if (command.aliases && command.aliases.length > 0) { 52 | command.aliases.forEach(alias => this.aliases.set(alias, command)) 53 | } 54 | } 55 | } 56 | } 57 | 58 | initEvents() { 59 | const subFolders = fs.readdirSync(`./events`) 60 | for (const category of subFolders) { 61 | const eventsFiles = fs.readdirSync(`./events/${category}`).filter(file => file.endsWith(".js")) 62 | for (const eventFile of eventsFiles) { 63 | const event = require(`../../events/${category}/${eventFile}`) 64 | this.on(event.name, (...args) => event.run(this, ...args)) 65 | if (category === 'anticrash') process.on(event.name, (...args) => event.run(this, ...args)) 66 | } 67 | } 68 | } 69 | 70 | initSlashCommands() { 71 | const subFolders = fs.readdirSync('./slashCmds') 72 | for (const category of subFolders) { 73 | const commandsFiles = fs.readdirSync(`./slashCmds/${category}`).filter(file => file.endsWith('.js')) 74 | for (const commandFile of commandsFiles) { 75 | const command = require(`../../slashCmds/${category}/${commandFile}`) 76 | this.slashCommands.set(command.name, command) 77 | } 78 | } 79 | } 80 | } 81 | 82 | exports.Bot = Bot -------------------------------------------------------------------------------- /structures/database/model.js: -------------------------------------------------------------------------------- 1 | const { datatype } = require('mxtorie') 2 | 3 | module.exports = { 4 | settings: [{ 5 | name: 'serverid', 6 | type: datatype.VARCHAR, 7 | length: 18, 8 | }, { 9 | name: 'prefix', 10 | type: datatype.VARCHAR, 11 | length: 50 12 | }], 13 | channels: [{ 14 | name: 'serverid', 15 | type: datatype.VARCHAR, 16 | length: 18 17 | }, { 18 | name: 'startlogs', 19 | type: datatype.VARCHAR, 20 | length: 50 21 | }] 22 | } /*This is the model of your database, if you want to add a column you need to add it here, don't forget to add it in your save file too.*/ -------------------------------------------------------------------------------- /structures/utils/index.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | sleep: ms => new Promise(resolve=>setTimeout(resolve, ms)), 3 | Number(min, max) { 4 | return Math.floor(Math.random() * (max - min + 1)) + min; 5 | }, 6 | randomChar(Length) { 7 | let length 8 | if (!Length || length == 0) length = 15 9 | else length = Length 10 | let res = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789' 11 | let value = "" 12 | for (let i = 0, n = res.length; i < length; ++i) { 13 | value += res.charAt(Math.floor(Math.random() * n)) 14 | } 15 | return value 16 | }, 17 | convertDate(date) { 18 | return parseInt(date.getTime() / 1000) 19 | } 20 | } --------------------------------------------------------------------------------