aboutsummaryrefslogtreecommitdiff
path: root/commands/Teams/join.js
diff options
context:
space:
mode:
authorUnknown <jtsshieh@outlook.com>2018-02-24 14:59:35 -0500
committerUnknown <jtsshieh@outlook.com>2018-02-24 14:59:35 -0500
commitc484753ee15dbe2a5ce9c6297f22fabb52ce3b7e (patch)
tree93fd74f30abbd3c8206321b9d9c20b2571ed84ca /commands/Teams/join.js
parent3d36bcf0591f2694c3a2472a157ecca0de8d35fc (diff)
downloadPokeBot-c484753ee15dbe2a5ce9c6297f22fabb52ce3b7e.tar.gz
PokeBot-c484753ee15dbe2a5ce9c6297f22fabb52ce3b7e.tar.bz2
PokeBot-c484753ee15dbe2a5ce9c6297f22fabb52ce3b7e.zip
New Command system
Diffstat (limited to 'commands/Teams/join.js')
-rw-r--r--commands/Teams/join.js60
1 files changed, 60 insertions, 0 deletions
diff --git a/commands/Teams/join.js b/commands/Teams/join.js
new file mode 100644
index 0000000..c9ba26e
--- /dev/null
+++ b/commands/Teams/join.js
@@ -0,0 +1,60 @@
+exports.run = async (bot, msg, args) => {
+ if (args.length < 1) return msg.reply('Please choose a team to join');
+
+ const team = findTeam(msg, args[0]);
+ switch(args[0])
+ {
+ case 'mystic': {
+ msg.member.addRole(msg.guild.roles.find('name', 'Mystic'));
+ msg.reply(`Alright, ${team ? 'you have left team ' + team + ' and ' : 'you have '}joined team Mystic.`);
+ break;
+ }
+ case 'valor' : {
+ msg.member.addRole(msg.guild.roles.find('name', 'Valor'));
+ msg.reply(`Alright, ${team ? 'you have left team ' + team + ' and ' : 'you have '}joined team Valor.`);
+ break;
+ }
+ case 'instinct' : {
+ msg.member.addRole(msg.guild.roles.find('name', 'Instinct'));
+ msg.reply(`Alright, ${team ? 'you have left team ' + team + ' and ' : 'you have '}joined team Instinct.`);
+ break;
+ }
+ default : {
+ msg.reply('You have to pick, mystic, valor, or instinct.');
+ break;
+ }
+ }
+};
+
+function findTeam(msg, team) {
+
+ let oldTeam;
+
+ if (msg.member.roles.find('name', 'Mystic')) {
+ if (team == 'mystic') return;
+ msg.member.removeRole(msg.guild.roles.find('name', 'Mystic'));
+ oldTeam = 'Mystic';
+ }
+ else if (msg.member.roles.find('name', 'Valor')) {
+ if (team == 'valor') return;
+ msg.member.removeRole(msg.guild.roles.find('name', 'Valor'));
+ oldTeam = 'Valor';
+ }
+ else if (msg.member.roles.find('name', 'Instinct')) {
+ if (team == 'instinct') return;
+ msg.member.removeRole(msg.guild.roles.find('name', 'Instinct'));
+ oldTeam = 'Instinct';
+ }
+ return oldTeam;
+}
+
+exports.conf = {
+ aliases: ['pick', 'choose'],
+ guildOnly: true,
+};
+
+exports.help = {
+ name: 'join',
+ description: 'Join one of the teams!',
+ usage: '<mystic/valor/instinct>',
+};