Cleanup l.ship and improve functionality

- Improved validation
- Added responses for invalid uses
- Normalized syntax and embed formatting
- Added support for "person1 and/with person2", which also allows for multiple words in non-mentions
master
Kit Kasune 4 years ago
parent ea82f3c75f
commit d709ccd273
  1. 27
      commands/fun/ships.js

@ -9,17 +9,24 @@ module.exports = {
extra: null
},
async execute(message, msg, args, cmd, prefix, mention, client) {
const start = message.mentions.members.first().user.username || args[0];
const end = message.mentions.members.map(m => m.user.username).splice(1) || args[1];
if (!start && !end || !start || !end) return message.channel.send(this.help);
if (!args.length) {return message.channel.send(`Syntax: \`${prefix}ship <@user1/name1> <@user2/name2>\``);}
let start; let end;
if (args.length > 2 && msg.includes(/\s+(?:with|and)\s+/gm)) {
let targs = args.join(" ").split(/\s+(?:[wW][iI][tT][hH]|[aA][nN][dD])\s+/gm);
start = message.mentions.members.first() ? message.mentions.members.first().displayName : targs[0];
end = message.mentions.members.size > 1 ? message.mentions.members.map(m => m.displayName).splice(1) : targs[1];
} else {
start = message.mentions.members.first().displayName || args[0];
end = message.mentions.members.map(m => m.displayName).splice(1) || args[1];
}
if (!start || !end || !end.length) {return message.channel.send(`You have to give two people to ship! Ex. \`${prefix}ship Crescent Luno\``);}
let finalName = start.slice(0, Math.floor(start.length / 2))+end.slice(Math.floor(end.length / 1 + 1));
const Embed = new Discord.MessageEmbed()
.setColor("PURPLE")
return message.channel.send(new Discord.MessageEmbed()
.setTitle(`${start} & ${end}\'s Ship Name:`)
.setThumbnail("https://media.discordapp.net/attachments/550550810145325056/834696984605622292/unknown.png?width=551&height=418")
.setTitle(start + ` & ` + end + `\'s Ship Name:`)
.setDescription(":sparkling_heart: "+finalName+" :sparkling_heart:")
.setFooter("What a cute ship!~")
message.channel.send(Embed);
.setDescription(`:sparkling_heart: ${finalName} :sparkling_heart:`)
.setColor("d42f66")
.setFooter("What a cute ship!~", client.user.avatarURL())
);
}
}
Loading…
Cancel
Save