aboutsummaryrefslogtreecommitdiff
path: root/events/message.js
diff options
context:
space:
mode:
authorUnknown <jtsshieh@outlook.com>2018-02-24 14:24:42 -0500
committerUnknown <jtsshieh@outlook.com>2018-02-24 14:24:42 -0500
commitb93ce2f771cfae601794739f9c2355f3d9ced577 (patch)
treed4ffadd7d0ecbbf48eb4a6955e2dbdc01659093f /events/message.js
parent6f510d3f3e8eeece0ed6c624ea6c8e87732d64f3 (diff)
downloadPokeBot-b93ce2f771cfae601794739f9c2355f3d9ced577.tar.gz
PokeBot-b93ce2f771cfae601794739f9c2355f3d9ced577.tar.bz2
PokeBot-b93ce2f771cfae601794739f9c2355f3d9ced577.zip
all events in seperate files
Diffstat (limited to 'events/message.js')
-rw-r--r--events/message.js44
1 files changed, 44 insertions, 0 deletions
diff --git a/events/message.js b/events/message.js
new file mode 100644
index 0000000..baf4983
--- /dev/null
+++ b/events/message.js
@@ -0,0 +1,44 @@
+module.exports = (bot, msg) => {
+ parseCommand(bot, msg);
+
+ if (msg.mentions != null && msg.mentions.users != null) {
+ if (msg.mentions.users.has('416637860146446346')) {
+ if (msg.content.toLowerCase().includes('hello') || (msg.content.toLowerCase().includes('hi'))) {
+ msg.reply('Hi there.');
+ } else if (msg.content.toLowerCase().includes('shut') && msg.content.toLowerCase().includes('up')) {
+ msg.reply('Excuse me?');
+ }
+ }
+ }
+};
+
+
+function parseCommand(bot, msg) {
+ if (msg.author.bot) return;
+ if (!msg.content.startsWith('p:')) return;
+
+ const args = msg.content.slice(2).trim().split(/ +/g);
+ const command = args.shift();
+
+ let cmd;
+
+ if (bot.commands.has(command)) {
+ cmd = bot.commands.get(command);
+ } else if (bot.aliases.has(command)) {
+ cmd = bot.commands.get(bot.aliases.get(command));
+ }
+
+ if (cmd) {
+ if (cmd.conf.guildOnly == true) {
+ if (!msg.channel.guild) {
+ return msg.channel.createMessage('This command can only be ran in a guild.');
+ }
+ }
+ try {
+ cmd.run(bot, msg, args);
+ }
+ catch (e) {
+ console.error('Error while running command' + e.stack);
+ }
+ }
+}