29 lines
1.5 KiB
JavaScript
Raw Normal View History

2023-11-29 18:22:10 +03:00
const Eris = require('eris')
const config = require('./config.json')
2023-11-29 18:33:48 +03:00
const client = new Eris(config.token, {maxShards: "auto", getAllUsers:true, intents:["guildPresences", "guildMembers", "guilds", "guildMessages"]}) // You can change your token using config.json
2023-11-29 18:22:10 +03:00
const fs = require('fs')
// Command Handler
2023-11-29 18:33:48 +03:00
client.commands = new Eris.Collection() // Making a new collection for commands
2023-11-29 18:22:10 +03:00
fs.readdir('./commands/', (err, files) => {
if (err) console.error(err)
files.forEach(file => {
let f = require(`./commands/${file}`)
2023-11-29 18:33:48 +03:00
client.commands.set(f.info.name, f) // Setting commands and names in collection
2023-11-29 18:22:10 +03:00
})
})
2023-11-29 18:33:48 +03:00
let prefix = config.prefix // You can change your prefix using config.json (default is "!")
2023-11-29 18:22:10 +03:00
client.on('messageCreate', async message => {
2023-11-29 18:33:48 +03:00
if (message.author.bot || !message.channel.guild || !message.content.startsWith(prefix)) return // Rejects if message author is a bot, message was not sent in a guild channel, message not starts with prefix
2023-11-29 18:22:10 +03:00
2023-11-29 18:33:48 +03:00
let args = message.content.slice(prefix.length).trim().split(/ +/g) // Getting the args from message
let command = args.shift().toLowerCase() // Getting the command from args
2023-11-29 18:22:10 +03:00
let cmd;
2023-11-29 18:33:48 +03:00
if (client.commands.has(command)) cmd = client.commands.get(command) // Checking if typed command is exists
2023-11-29 20:01:04 +03:00
if (cmd && cmd.info.enabled) cmd.run(client, message, args) // Running the command if it is exists
2023-11-29 18:22:10 +03:00
})
2023-11-29 18:33:48 +03:00
client.on('ready', () => console.log('Bot is ready!')) // Ready Event
client.connect() // Connecting to the bot