aboutsummaryrefslogtreecommitdiff
path: root/commands/join.js
diff options
context:
space:
mode:
Diffstat (limited to 'commands/join.js')
-rw-r--r--commands/join.js45
1 files changed, 27 insertions, 18 deletions
diff --git a/commands/join.js b/commands/join.js
index 3b8239c..b7fd916 100644
--- a/commands/join.js
+++ b/commands/join.js
@@ -1,35 +1,22 @@
exports.run = async (bot, msg, args) => {
if (args.length < 1) return msg.reply('Please choose a team to join');
- let team;
-
- if (msg.member.roles.find('name', 'Mystic')) {
- msg.member.removeRole(msg.guild.roles.find('name', 'Mystic'));
- team = 'Mystic';
- }
- else if (msg.member.roles.find('name', 'Valor')) {
- msg.member.removeRole(msg.guild.roles.find('name', 'Valor'));
- team = 'Valor';
- }
- else if (msg.member.roles.find('name', 'Instinct')) {
- msg.member.removeRole(msg.guild.roles.find('name', 'Instinct'));
- team = 'Instinct';
- }
+ 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 are have '}joined team Mystic.`);
+ msg.reply(`Alright, ${team ? 'you have left team ' + team + ' and ' : 'you are 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 are have '}joined team Valor.`);
+ msg.reply(`Alright, ${team ? 'you have left team ' + team + ' and ' : 'you are 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 are have '}joined team Instinct.`);
+ msg.reply(`Alright, ${team ? 'you have left team ' + team + ' and ' : 'you are have '}joined team Instinct.`);
break;
}
default : {
@@ -39,8 +26,30 @@ exports.run = async (bot, msg, args) => {
}
};
+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'],
+ aliases: ['pick', 'choose'],
guildOnly: true,
};