Haha-Yes/index.js

76 lines
3 KiB
JavaScript
Raw Normal View History

2018-09-18 21:33:52 +02:00
const { CommandoClient } = require('discord.js-commando');
2018-09-07 00:24:03 +02:00
const path = require('path');
2018-09-18 21:33:52 +02:00
const { token, prefix, botID, statsChannel, ownerID, supportServer } = require('./config.json');
const responseObject = require("./reply.json");
2018-09-08 02:25:58 +02:00
const fs = require("fs");
2018-09-07 00:24:03 +02:00
2018-09-07 21:28:42 +02:00
// Prefix and ownerID and invite to support server
2018-09-07 00:24:03 +02:00
const client = new CommandoClient({
commandPrefix: prefix,
owner: ownerID,
invite: supportServer,
2018-09-10 18:52:19 +02:00
unknownCommandResponse: false,
disableEveryone: true,
2018-09-07 00:24:03 +02:00
});
2018-09-07 21:28:42 +02:00
// Command groups
2018-09-07 00:24:03 +02:00
client.registry
2018-09-07 19:07:10 +02:00
.registerDefaultTypes()
.registerGroups([
['fun', 'Fun'],
['utility', 'Utility'],
['admin', 'Admins'],
['owner', 'Owner'],
2018-09-07 19:07:10 +02:00
])
.registerDefaultGroups()
.registerDefaultCommands()
.registerCommandsIn(path.join(__dirname, 'commands'));
2018-09-18 21:33:52 +02:00
// Ready messages
client.on('ready', () => {
// Send stats to the console
console.log(`Logged in as ${client.user.tag}! (${client.user.id})`);
console.log(`Ready to serve in ${client.channels.size} channels on ${client.guilds.size} servers, for a total of ${client.users.size} users. ${client.readyAt}`);
// Send stats to the "stats" channel in the support server if its not the test bot
if (client.user.id == botID) {
const channel = client.channels.get(statsChannel);
channel.send(`Ready to serve in ${client.channels.size} channels on ${client.guilds.size} servers, for a total of ${client.users.size} users. ${client.readyAt}`);
}
client.user.setActivity('"haha help" or "@me help" for help');
});
// When bot join a guild send embeds with details about it.
client.on("guildCreate", guild => {
console.log(`${guild.name}\n${guild.memberCount} users\nOwner: ${guild.owner}`);
const channel = client.channels.get(statsChannel);
const addEmbed = {
color: 0x008000,
title: 'Someone added the bot! :D YAY',
description: `${guild.name}\n${guild.memberCount} users\nOwner: ${guild.owner}`,
timestamp: new Date(),
};
channel.send({ embed: addEmbed });
})
// When bot get kicked from a guild send embeds with details about it.
client.on("guildDelete", guild => {
console.log(`***BOT KICKED***\n${guild.name}\n${guild.memberCount} users\nOwner: ${guild.owner}\n***BOT KICKED***`);
const channel = client.channels.get(statsChannel);
const kickEmbed = {
color: 0xFF0000,
title: 'Someone removed the bot :(',
description: `${guild.name}\n${guild.memberCount} users\nOwner: ${guild.owner}`,
timestamp: new Date(),
};
channel.send({ embed: kickEmbed });
})
2018-09-08 23:34:08 +02:00
2018-09-18 21:33:52 +02:00
// Auto respond to messages
client.on("message", (message) => {
let message_content = message.content.toLowerCase();
if(responseObject[message_content]) {
message.channel.send(responseObject[message_content]);
}
});
2018-09-08 01:37:16 +02:00
2018-09-07 19:07:10 +02:00
client.on('error', console.error);
2018-09-07 00:24:03 +02:00
2018-09-07 19:07:10 +02:00
client.login(token);