From 773ebdeccaef172ccfb46cf5d5bb070cee93eabe Mon Sep 17 00:00:00 2001 From: Unknown Date: Sat, 24 Feb 2018 21:22:16 -0500 Subject: try --- commands/Pokemon/claim.js | 21 +++++++++++++++++ commands/Pokemon/join.js | 60 +++++++++++++++++++++++++++++++++++++++++++++++ commands/Pokemon/leave.js | 27 +++++++++++++++++++++ 3 files changed, 108 insertions(+) create mode 100644 commands/Pokemon/claim.js create mode 100644 commands/Pokemon/join.js create mode 100644 commands/Pokemon/leave.js (limited to 'commands/Pokemon') diff --git a/commands/Pokemon/claim.js b/commands/Pokemon/claim.js new file mode 100644 index 0000000..dccbd29 --- /dev/null +++ b/commands/Pokemon/claim.js @@ -0,0 +1,21 @@ +exports.run = async (bot, msg) => { + if (!msg.channel.topic.startsWith('Current Owner:')) return msg.reply('Go into one of the gym channels and try again.'); + if (msg.channel.topic == 'Current Owner: *none*') { + msg.reply('Alright, you have claimed this gym as yours! Be ready to battle anyone who approaches you'); + msg.channel.setTopic('Current Owner: ' + msg.author.id + '/' + msg.author.tag); + } + else { + const owner = msg.channel.topic.slice(15).substring(msg.author.id.length); + msg.channel.send('<@' + owner + '>, come here as ' + msg.author + 'wants to battle you.'); + } +}; + +exports.conf = { + aliases: [], + guildOnly: true, +}; + +exports.help = { + name: 'claim', + description: 'Claim a gym.', +}; diff --git a/commands/Pokemon/join.js b/commands/Pokemon/join.js new file mode 100644 index 0000000..39bdf90 --- /dev/null +++ b/commands/Pokemon/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 'aqua': { + msg.member.addRole(msg.guild.roles.find('name', 'Aqua')); + msg.reply(`Alright, ${team ? 'you have left team ' + team + ' and ' : 'you have '}joined team Aqua.`); + break; + } + case 'rocket' : { + msg.member.addRole(msg.guild.roles.find('name', 'Rocket')); + msg.reply(`Alright, ${team ? 'you have left team ' + team + ' and ' : 'you have '}joined team Rocket.`); + break; + } + case 'magma' : { + msg.member.addRole(msg.guild.roles.find('name', 'Magma')); + msg.reply(`Alright, ${team ? 'you have left team ' + team + ' and ' : 'you have '}joined team Magma.`); + break; + } + default : { + msg.reply('You have to pick, aqua, rocket, or magma.'); + break; + } + } +}; + +function findTeam(msg, team) { + + let oldTeam; + + if (msg.member.roles.find('name', 'Aqua')) { + if (team == 'aqua') return; + msg.member.removeRole(msg.guild.roles.find('name', 'Aqua')); + oldTeam = 'Aqua'; + } + else if (msg.member.roles.find('name', 'Rocket')) { + if (team == 'rocket') return; + msg.member.removeRole(msg.guild.roles.find('name', 'Rocket')); + oldTeam = 'Rocket'; + } + else if (msg.member.roles.find('name', 'Magma')) { + if (team == 'magma') return; + msg.member.removeRole(msg.guild.roles.find('name', 'Magma')); + oldTeam = 'Magma'; + } + return oldTeam; +} + +exports.conf = { + aliases: ['pick', 'choose'], + guildOnly: true, +}; + +exports.help = { + name: 'join', + description: 'Join one of the teams!', + usage: '', +}; diff --git a/commands/Pokemon/leave.js b/commands/Pokemon/leave.js new file mode 100644 index 0000000..fb02e16 --- /dev/null +++ b/commands/Pokemon/leave.js @@ -0,0 +1,27 @@ +exports.run = async (bot, msg) => { + if (msg.member.roles.find('name', 'Aqua')) { + msg.member.removeRole(msg.guild.roles.find('name', 'Aqua')); + msg.reply('Alright, you are not longer in team Aqua.'); + } + else if (msg.member.roles.find('name', 'Rocket')) { + msg.member.removeRole(msg.guild.roles.find('name', 'Rocket')); + msg.reply('Alright, you are not longer in team Rocket.'); + } + else if (msg.member.roles.find('name', 'Magma')) { + msg.member.removeRole(msg.guild.roles.find('name', 'Magma')); + msg.reply('Alright, you are not longer in team Magma.'); + } + 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.', +}; -- cgit v1.2.3