diff options
| author | Unknown <jtsshieh@outlook.com> | 2018-02-24 14:59:35 -0500 |
|---|---|---|
| committer | Unknown <jtsshieh@outlook.com> | 2018-02-24 14:59:35 -0500 |
| commit | c484753ee15dbe2a5ce9c6297f22fabb52ce3b7e (patch) | |
| tree | 93fd74f30abbd3c8206321b9d9c20b2571ed84ca /commands/Teams | |
| parent | 3d36bcf0591f2694c3a2472a157ecca0de8d35fc (diff) | |
| download | PokeBot-c484753ee15dbe2a5ce9c6297f22fabb52ce3b7e.tar.gz PokeBot-c484753ee15dbe2a5ce9c6297f22fabb52ce3b7e.tar.bz2 PokeBot-c484753ee15dbe2a5ce9c6297f22fabb52ce3b7e.zip | |
New Command system
Diffstat (limited to 'commands/Teams')
| -rw-r--r-- | commands/Teams/join.js | 60 | ||||
| -rw-r--r-- | commands/Teams/leave.js | 27 |
2 files changed, 87 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>', +}; diff --git a/commands/Teams/leave.js b/commands/Teams/leave.js new file mode 100644 index 0000000..c22a1f2 --- /dev/null +++ b/commands/Teams/leave.js @@ -0,0 +1,27 @@ +exports.run = async (bot, msg) => { + if (msg.member.roles.find('name', 'Mystic')) { + msg.member.removeRole(msg.guild.roles.find('name', 'Mystic')); + msg.reply('Alright, you are not longer in team Mystic.'); + } + else if (msg.member.roles.find('name', 'Valor')) { + msg.member.removeRole(msg.guild.roles.find('name', 'Valor')); + msg.reply('Alright, you are not longer in team Valor.'); + } + else if (msg.member.roles.find('name', 'Instinct')) { + msg.member.removeRole(msg.guild.roles.find('name', 'Instinct')); + msg.reply('Alright, you are not longer in team Instinct.'); + } + else { + msg.reply('You are not in a team.'); + } +}; + +exports.conf = { + aliases: [], + guildOnly: true, +}; + +exports.help = { + name: 'leave', + description: 'Leave the team you currently are in.', +}; |
