forked from Supositware/Haha-Yes
Merge branch 'master' of https://gitlab.com/loicbersier/discordbot
This commit is contained in:
commit
8dd5eae487
3 changed files with 31 additions and 22 deletions
|
@ -5,21 +5,22 @@ module.exports = class ServerCommand extends Command {
|
||||||
super(client, {
|
super(client, {
|
||||||
name: 'server',
|
name: 'server',
|
||||||
group: 'utility',
|
group: 'utility',
|
||||||
|
guildOnly: 'true',
|
||||||
memberName: 'server',
|
memberName: 'server',
|
||||||
description: 'very yes',
|
description: 'Show some stats about the server',
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
async run(message) {
|
async run(message) {
|
||||||
const serverStatsEmbed = new Discord.RichEmbed()
|
const addEmbed = {
|
||||||
.setColor('#0099ff')
|
color: 0x0099ff,
|
||||||
.setTitle('Stats of the server')
|
title: 'Stats of the server',
|
||||||
.setDescription('Some description here')
|
thumbnail: {
|
||||||
.setThumbnail(message.guild.iconURL)
|
url: `${message.guild.iconURL}`,
|
||||||
.addField(`Member: **${message.guild.memberCount}** \n Channel: **${message.guild.channels}**`)
|
},
|
||||||
.addBlankField()
|
description: `Member: **${message.guild.memberCount}** \nChannel number: **${message.guild.channels.size}**\nGuild created at **${message.guild.createdAt}**\nOwner: **${message.guild.owner}**`,
|
||||||
.setTimestamp()
|
};
|
||||||
|
|
||||||
message.say(serverStatsEmbed);
|
message.say({ embed: addEmbed });
|
||||||
}
|
}
|
||||||
};
|
};
|
|
@ -10,6 +10,13 @@ module.exports = class MeowCommand extends Command {
|
||||||
}
|
}
|
||||||
|
|
||||||
async run(message) {
|
async run(message) {
|
||||||
return message.channel.send(`Servers: \`${this.client.guilds.size}\`\nChannels: \`${this.client.channels.size}\`\nUsers: \`${this.client.users.size}\`\nBot uptime: \`${process.uptime()}\``);
|
let totalSeconds = (this.client.uptime / 1000);
|
||||||
|
let days = Math.floor(totalSeconds / 86400);
|
||||||
|
let hours = Math.floor(totalSeconds / 3600);
|
||||||
|
totalSeconds %= 3600;
|
||||||
|
let minutes = Math.floor(totalSeconds / 60);
|
||||||
|
let seconds = totalSeconds % 60;
|
||||||
|
let uptime = `${days} days, ${hours} hours, ${minutes} minutes and ${seconds} seconds`;
|
||||||
|
return message.channel.send(`Servers: \`${this.client.guilds.size}\`\nChannels: \`${this.client.channels.size}\`\nUsers: \`${this.client.users.size}\`\nBot uptime: \`${uptime}\``);
|
||||||
}
|
}
|
||||||
};
|
};
|
21
index.js
21
index.js
|
@ -16,10 +16,10 @@ const client = new CommandoClient({
|
||||||
client.registry
|
client.registry
|
||||||
.registerDefaultTypes()
|
.registerDefaultTypes()
|
||||||
.registerGroups([
|
.registerGroups([
|
||||||
['fun', 'Fun commands'],
|
['fun', 'Fun'],
|
||||||
['utility', 'Some useful commands'],
|
['utility', 'Utility'],
|
||||||
['admin', 'Commands to make admin life easier'],
|
['admin', 'Admins'],
|
||||||
['owner', 'Commands the owner can use to manage the bot'],
|
['owner', 'Owner'],
|
||||||
])
|
])
|
||||||
.registerDefaultGroups()
|
.registerDefaultGroups()
|
||||||
.registerDefaultCommands()
|
.registerDefaultCommands()
|
||||||
|
@ -40,33 +40,34 @@ client.registry
|
||||||
client.on("guildCreate", guild => {
|
client.on("guildCreate", guild => {
|
||||||
console.log(`${guild.name}\n${guild.memberCount} users\nOwner: ${guild.owner}`);
|
console.log(`${guild.name}\n${guild.memberCount} users\nOwner: ${guild.owner}`);
|
||||||
const channel = client.channels.get('487766113292124160');
|
const channel = client.channels.get('487766113292124160');
|
||||||
const exampleEmbed = {
|
const addEmbed = {
|
||||||
color: 0x008000,
|
color: 0x008000,
|
||||||
title: 'Someone added the bot! :D YAY',
|
title: 'Someone added the bot! :D YAY',
|
||||||
description: `${guild.name}\n${guild.memberCount} users\nOwner: ${guild.owner}`,
|
description: `${guild.name}\n${guild.memberCount} users\nOwner: ${guild.owner}`,
|
||||||
timestamp: new Date(),
|
timestamp: new Date(),
|
||||||
};
|
};
|
||||||
|
|
||||||
channel.send({ embed: exampleEmbed });
|
channel.send({ embed: addEmbed });
|
||||||
})
|
})
|
||||||
// When bot get kicked from a guild send embeds with details about it.
|
// When bot get kicked from a guild send embeds with details about it.
|
||||||
client.on("guildDelete", guild => {
|
client.on("guildDelete", guild => {
|
||||||
console.log(`***BOT KICKED***\n${guild.name}\n${guild.memberCount} users\nOwner: ${guild.owner}\n***BOT KICKED***`);
|
console.log(`***BOT KICKED***\n${guild.name}\n${guild.memberCount} users\nOwner: ${guild.owner}\n***BOT KICKED***`);
|
||||||
const channel = client.channels.get('487766113292124160');
|
const channel = client.channels.get('487766113292124160');
|
||||||
const exampleEmbed = {
|
const kickEmbed = {
|
||||||
color: 0xFF0000,
|
color: 0xFF0000,
|
||||||
title: 'Someone removed the bot :(',
|
title: 'Someone removed the bot :(',
|
||||||
description: `${guild.name}\n${guild.memberCount} users\nOwner: ${guild.owner}`,
|
description: `${guild.name}\n${guild.memberCount} users\nOwner: ${guild.owner}`,
|
||||||
timestamp: new Date(),
|
timestamp: new Date(),
|
||||||
};
|
};
|
||||||
|
|
||||||
channel.send({ embed: exampleEmbed });
|
channel.send({ embed: kickEmbed });
|
||||||
})
|
})
|
||||||
|
|
||||||
// Auto respond to messages
|
// Auto respond to messages
|
||||||
client.on("message", (message) => {
|
client.on("message", (message) => {
|
||||||
if(responseObject[message.content]) {
|
let message_content = message.content.toLowerCase();
|
||||||
message.channel.send(responseObject[message.content]);
|
if(responseObject[message_content]) {
|
||||||
|
message.channel.send(responseObject[message_content]);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue