Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const botconfig = require("./botconfig.json");
- const Discord = require("discord.js");
- const bot = new Discord.Client({disableEveryone: true});
- const fs = require("fs");
- bot.commands = new Discord.Collection();
- bot.aliases = new Discord.Collection();
- bot.on('ready', function() {
- console.log(`${bot.user.username} is online and running in ${bot.guilds.size} servers!`);
- console.log(`${bot.user.username}'s prefix is ${botconfig.prefix}`);
- setInterval(async () => {
- const statuslist = [
- "Jac.",
- "/help"
- ];
- const random = Math.floor(Math.random() * statuslist.length);
- try {
- await bot.user.setPresence({
- game: {
- name: `${statuslist[random]}`,
- type: "LISTENING",
- url: 'https://www.twitch.tv/DiveristyRises'
- },
- status: "online"
- });
- } catch (error) {
- console.error(error);
- }
- }, 9000);
- });
- // Command handler
- fs.readdir("./commands/", (err, files) => {
- if(err) console.log(err)
- let jsfile = files.filter(f => f.split(".").pop() === "js")
- if(jsfile.length <= 0) {
- return console.log("Couldn't find commands!")
- }
- jsfile.forEach((f, i) => {
- let pull = require(`./commands/${f}`);
- bot.commands.set(pull.config.name, pull);
- pull.config.aliases.forEach(alias => {
- bot.aliases.set(alias, pull.config.name)
- })
- })
- });
- // Message Event
- bot.on("message", async message => {
- if(message.author.bot || message.channel.type === "dm") return;
- if(message.content === "gn") return message.channel.send("goodnight");
- let prefix = botconfig.prefix;
- let messageArray = message.content.split(" ")
- let cmd = messageArray[0].toLowerCase();
- let args = messageArray.slice(1);
- if(!message.content.startsWith(prefix)) return;
- console.log(`${message.author.username}#${message.author.discriminator} used ${cmd} in ${message.guild.name} Channel: ${message.channel.name}`)
- let commandfile = bot.commands.get(cmd.slice(prefix.length)) || bot.commands.get(bot.aliases.get(cmd.slice(prefix.length)))
- if(commandfile) commandfile.run(bot,message,args)
- });
- bot.login(botconfig.token);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement