Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Require the necessary things and login to the bot.
- const Discord = require("discord.js");
- const moment = require('moment');
- const fs = require('fs');
- const config = require("./config.json");
- const prefix = config.prefix;
- const manager = require('./shards.js');
- const client = new Discord.Client();
- client.login(config.token);
- // Read the Commands folder
- client.commands = new Discord.Collection();
- const commandFiles = fs.readdirSync('./commands').filter(file => file.endsWith('.js'));
- // Include the other files we have
- for (const file of commandFiles) {
- const command = require(`./commands/${file.slice(0,-3)}`)
- client.commands.set(command.name, command);
- }
- // Sets status upon bot being booted up & logged in.
- client.on("ready", () => {
- client.user.setPresence({
- status: "online",
- activity: {
- name: `${config.prefix}help`,
- type: "PLAYING"
- }
- }); // End of Setting Presence
- console.log(`Reading file: ` + file.slice(0,-3));
- // Sends embed when bot is reloaded
- const onEmbed = new Discord.MessageEmbed() // WORKS!
- .setColor('#000000')
- .setFooter(`The bot has been successfully rebooted. 💜 If you have issues please ping cute.as.ducks#8061`);
- let channel = client.channels.cache.find(c => c.id === '776192612671553578');
- channel.send(onEmbed);
- }); // End of setting status.
- // Listens for messages.
- client.on('message', message => {
- if (!message.content.startsWith(prefix) || message.author.bot) return;
- const args = message.content.slice(prefix.length).trim().split(/ +/);
- const commandName = args.shift().toLowerCase();
- const command = client.commands.get(commandName) || client.commands.find(cmd => cmd.aliases && cmd.aliases.includes(commandName));
- if (!client.commands.has(command)) return;
- try {
- client.commands.get(command).execute(message, args);
- } catch (error) {
- console.error(error);
- message.reply('there was an error trying to execute that command!');
- }
- if (!message.guild) return;
- }); // End of listening for messages.
Advertisement
Add Comment
Please, Sign In to add comment