You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Haha-Yes/index.js

101 lines
4.4 KiB
JavaScript

6 years ago
const { CommandoClient } = require('discord.js-commando');
const Discord = require('discord.js');
6 years ago
const path = require('path');
6 years ago
const { token, prefix, statsChannel, ownerID, supportServer } = require('./config.json');
6 years ago
const responseObject = require("./json/reply.json");
const reactObject = require("./json/react.json");
const imgResponseObject = require("./json/imgreply.json");
6 years ago
// Prefix and ownerID and invite to support server
const client = new CommandoClient({
commandPrefix: prefix,
owner: ownerID,
invite: supportServer,
unknownCommandResponse: false,
disableEveryone: true,
});
6 years ago
// Command groups
client.registry
6 years ago
.registerDefaultTypes()
.registerGroups([
['fun', 'Fun'],
['utility', 'Utility'],
['admin', 'Admins'],
['owner', 'Owner'],
6 years ago
])
.registerDefaultGroups()
.registerDefaultCommands({
help: false,
ping: false
})
6 years ago
.registerCommandsIn(path.join(__dirname, 'commands'));
6 years ago
// Ready messages
client.on('ready', async () => {
6 years ago
// Send stats to the console
console.log(`\x1b[32mLogged in as \x1b[34m${client.user.tag}\x1b[0m! (\x1b[33m${client.user.id}\x1b[0m)`);
console.log(`Ready to serve in \x1b[33m${client.channels.size}\x1b[0m channels on \x1b[33m${client.guilds.size}\x1b[0m servers, for a total of \x1b[33m${client.users.size}\x1b[0m users. \x1b${client.readyAt}\x1b[0m`);
6 years ago
// Send stats to the "stats" channel in the support server if its not the test bot
6 years ago
if (client.user.id == 377563711927484418) {
6 years ago
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 feedback <feedback> to tell me what you think of the bot! | haha help'); }
6 years ago
});
6 years ago
// When bot join a guild send embeds with details about it.
client.on("guildCreate", async guild => {
console.log(`${guild.name}\n${guild.memberCount} users\nOwner: ${guild.owner.user.username}\nOwner ID: ${guild.owner}`);
6 years ago
const channel = client.channels.get(statsChannel);
const addEmbed = new Discord.RichEmbed()
.setColor("#52e80d")
.setTitle('Someone added me ! YAY :D')
.setURL('https://www.youtube.com/watch?v=6n3pFFPSlW4')
.setThumbnail(guild.iconURL)
6 years ago
.setDescription(`${guild.name}\n${guild.id}\n${guild.memberCount} users\nOwner: ${guild.owner.user.username}\n(${guild.owner})`)
.setTimestamp()
6 years ago
channel.send({ embed: addEmbed });
});
6 years ago
// When bot get kicked from a guild send embeds with details about it.
client.on("guildDelete", async guild => {
console.log(`***BOT KICKED***\n${guild.name}\n${guild.memberCount} users\nOwner: ${guild.owner.user.username}\nOwner ID: ${guild.owner}\n***BOT KICKED***`);
6 years ago
const channel = client.channels.get(statsChannel);
const kickEmbed = new Discord.RichEmbed()
.setColor("#FF0000")
.setTitle('They kicked me out :(')
.setURL('https://www.youtube.com/watch?v=6n3pFFPSlW4')
.setThumbnail(guild.iconURL)
6 years ago
.setDescription(`${guild.name}\n${guild.id}\n${guild.memberCount} users\nOwner: ${guild.owner.user.username}\n(${guild.owner})`)
.setTimestamp()
console.log('***BOT KICKED***')
6 years ago
channel.send({ embed: kickEmbed });
});
client.on("message", async (message) => {
6 years ago
let message_content = message.content.toLowerCase();
// React to the message and send an auto response with it
if (message.author.bot) return; {
// Reply with images as attachement
if(imgResponseObject[message_content]) {
message.channel.send({files: [imgResponseObject[message_content]]});
6 years ago
}
// React only to the messages
6 years ago
else if(reactObject[message_content]) {
message.react(reactObject[message_content]);
6 years ago
}
// auto respond to messages
6 years ago
else if(responseObject[message_content]) {
6 years ago
message.channel.send(responseObject[message_content]);
} else if (message_content.includes("like if")) {
message.react("\u{1F44D}")
} else if (message_content.includes("jeff")) {
message.react("496028845967802378")
}
}});
6 years ago
6 years ago
client.on('error', console.error);
process.on('unhandledRejection', error => console.error('Uncaught Promise Rejection', error));
6 years ago
client.login(token);