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

92 lines
4.0 KiB
JavaScript

6 years ago
const { CommandoClient } = require('discord.js-commando');
const Discord = require('discord.js');
6 years ago
const path = require('path');
const { token, prefix, botID, 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()
.registerCommandsIn(path.join(__dirname, 'commands'));
6 years ago
// Ready messages
client.on('ready', async () => {
6 years ago
// 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) {
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 help" or "@me help" for help');
}
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("#FF0000")
.setTitle('Someone added me ! YAY :D')
.setDescription(`${guild.name}\n${guild.memberCount} users\nOwner: ${guild.owner.user.username}\nOwner ID: ${guild.owner}`)
.setTimestamp()
6 years ago
channel.send({ embed: addEmbed });
})
// 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 :(')
.setDescription(`${guild.name}\n${guild.memberCount} users\nOwner: ${guild.owner.user.username}\nOwner ID: ${guild.owner}`)
.setTimestamp()
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]]});
}
else if(responseObject[message_content] && reactObject[message_content]) {
6 years ago
message.channel.send(responseObject[message_content]);
6 years ago
message.react(reactObject[message_content]);
// 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]);
6 years ago
}
}});
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);