blob: d32c7651b05b6da9fd69521cee3138666a622d82 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
|
const Discord = require('discord.js');
const bot = new Discord.Client();
const config = require('./config.json');
bot.on('ready', () => {
console.log('PokeBot has finished loading.');
});
bot.on('guildMemberAdd', (member) => {
bot.channels.get('416633835216830495').send(`Welcome to the server **${member.user.tag}**! Make sure to read the rules in #rules!`);
const role = member.guild.roles.find('name', 'Trainers');
member.addRole(role);
});
bot.on('guildMemberRemove', (member) => {
bot.channels.get('416633835216830495').send(`Aww... **${member.user.tag}** just left...`);
});
bot.on('message', (msg) => {
parseCommand(msg);
});
function parseCommand(msg) {
if (msg.author.bot) return;
if (!msg.content.startsWith('p:')) return;
const args = msg.content.slice(2).split(' ');
const command = args.shift();
switch (command)
{
case 'help':
msg.channel.send(
new Discord.RichEmbed()
.setColor (0x00ae86)
.setTitle('PokeBot Command List')
.setDescription('These are the commands you can use. My prefix is `p:`')
.addField('Core', 'help\nping', true)
.addField('Utility', 'suggest', true)
.setFooter('PokeBot Beta')
);
break;
case 'ping':
msg.channel.send(':ping_pong: Pong! ' + Math.floor(bot.ping) + 'ms.');
break;
case 'suggest':
var suggestionAuthor = msg.author.id;
bot.channels.get('416726932927938570').send(
new Discord.RichEmbed()
.setColor (0x00ae86)
.setAuthor(`${suggestionAuthor.user.tag}`, msg.author.displayavatarURL)
.setDescription('This is a suggestion from a community member for something relating to the server. Please rate it based on your opinion, and a staff member will decide what to do with the suggestion.')
.addField('Suggestion Contents', args.join(' '))
).then(message => {
message.react('\u2705');
message.react('\u274E');
});
break;
}
}
bot.login(config.token);
|