Writing comments for index.js
This commit is contained in:
		
							
								
								
									
										32
									
								
								index.js
									
									
									
									
									
								
							
							
						
						
									
										32
									
								
								index.js
									
									
									
									
									
								
							@@ -1,38 +1,28 @@
 | 
				
			|||||||
const Eris = require('eris')
 | 
					const Eris = require('eris')
 | 
				
			||||||
const config = require('./config.json')
 | 
					const config = require('./config.json')
 | 
				
			||||||
const client = new Eris(config.token, {maxShards: "auto", getAllUsers:true, intents:["guildPresences", "guildMembers", "guilds", "guildMessages"]})
 | 
					const client = new Eris(config.token, {maxShards: "auto", getAllUsers:true, intents:["guildPresences", "guildMembers", "guilds", "guildMessages"]}) // You can change your token using config.json
 | 
				
			||||||
const fs = require('fs')
 | 
					const fs = require('fs')
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// Command Handler
 | 
					// Command Handler
 | 
				
			||||||
client.commands = new Eris.Collection()
 | 
					client.commands = new Eris.Collection() // Making a new collection for commands
 | 
				
			||||||
fs.readdir('./commands/', (err, files) => {
 | 
					fs.readdir('./commands/', (err, files) => {
 | 
				
			||||||
	if (err) console.error(err)
 | 
						if (err) console.error(err)
 | 
				
			||||||
	files.forEach(file => {
 | 
						files.forEach(file => {
 | 
				
			||||||
		let f = require(`./commands/${file}`)
 | 
							let f = require(`./commands/${file}`)
 | 
				
			||||||
		client.commands.set(f.info.name, f)
 | 
							client.commands.set(f.info.name, f) // Setting commands and names in collection
 | 
				
			||||||
	})
 | 
						})
 | 
				
			||||||
})
 | 
					})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
let prefix = config.prefix
 | 
					let prefix = config.prefix // You can change your prefix using config.json (default is "!")
 | 
				
			||||||
 | 
					 | 
				
			||||||
client.on('messageCreate', async message => {
 | 
					client.on('messageCreate', async message => {
 | 
				
			||||||
	if (message.author.bot || !message.channel.guild || !message.content.startsWith(prefix)) return
 | 
						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
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	let args = message.content.slice(prefix.length).trim().split(/ +/g)
 | 
						let args = message.content.slice(prefix.length).trim().split(/ +/g) // Getting the args from message
 | 
				
			||||||
	let command = args.shift().toLowerCase()
 | 
						let command = args.shift().toLowerCase() // Getting the command from args
 | 
				
			||||||
	let cmd;
 | 
						let cmd;
 | 
				
			||||||
	if (client.commands.has(command)) cmd = client.commands.get(command)
 | 
						if (client.commands.has(command)) cmd = client.commands.get(command) // Checking if typed command is exists
 | 
				
			||||||
	if (cmd) cmd.run(client, message, args)
 | 
						if (cmd) cmd.run(client, message, args) // Running the command if it is exists
 | 
				
			||||||
 | 
					 | 
				
			||||||
})
 | 
					})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					client.on('ready', () => console.log('Bot is ready!')) // Ready Event
 | 
				
			||||||
 | 
					client.connect() // Connecting to the bot
 | 
				
			||||||
// Ready Event
 | 
					 | 
				
			||||||
client.on('ready', () => {
 | 
					 | 
				
			||||||
	console.log('Bot is ready!')
 | 
					 | 
				
			||||||
})
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
client.connect()
 | 
					 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user