Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const { Client, MessageEmbed, Collection } = require ('discord.js')
- const fs = require('fs')
- const prefix = ">"
- const memberAdd = require('./Events/guildMemberAdd');
- const memberRemove = require('./Events/guildMemberRemove');
- const Enmap = require('enmap');
- class RF71 extends Client {
- constructor() {
- super();
- this.discord = require('discord.js')
- this.commands = new Collection();
- this.db = new Enmap({ name: "RF71DB" });
- }
- commandHandler() {
- const files = fs.readdirSync('./commands').filter(file => file.endsWith(".js"));
- for(const file of files) {
- const command = require(`../commands/${file}`);
- this.commands.set(command.name, command)
- }
- }
- start(token) {
- this.login(token);
- this.commandHandler();
- this.on('ready', () => console.log("Ready!"))
- this.on('message', async(message) => {
- let prefix = this.db.get(`${message.guild.id}-prefix`) || ">";
- if(message.author.bot || !message.guild || !message.content.startsWith(prefix)) return;
- const args = message.content.slice(prefix.length).trim().split(/ +/g)
- const cmd = args.shift().toLowerCase();
- const command = this.commands.get(cmd);
- if(!command) return;
- return command.run(this, message, args).catch(console.error)
- })
- this.on('guildMemberAdd', async(member) => {
- memberAdd(this, member);
- })
- this.on('guildMemberRemove', async(member) => {
- memberRemove(this, member);
- })
- }
- }
- module.exports = RF71;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement