2020-03-11 10:46:13 +00:00
|
|
|
const request = require('request')
|
|
|
|
exports.run = async (client, message, args) => {
|
2020-03-16 01:14:33 +00:00
|
|
|
|
|
|
|
|
|
|
|
//NOT FINISHED
|
|
|
|
|
|
|
|
if(!args[0] || !args[1]) {
|
|
|
|
return message.channel.send(`<:error:466995152976871434> Please include two users`)
|
|
|
|
}
|
2020-03-11 10:46:13 +00:00
|
|
|
message.channel.startTyping();
|
|
|
|
|
2020-03-21 09:46:51 +00:00
|
|
|
let users = [];
|
|
|
|
let totalLength = 0;
|
|
|
|
|
|
|
|
for(let i = 0; i < args.length; i++) {
|
|
|
|
let arg = args[i];
|
|
|
|
|
|
|
|
let user = client.getUserFromMention(arg);
|
|
|
|
|
|
|
|
if(!user) {
|
|
|
|
let usersFound;
|
|
|
|
usersFound = client.searchForMembers(message.guild, arg);
|
|
|
|
if (usersFound.length > 1)
|
|
|
|
return message.channel.send(
|
|
|
|
"<:error:466995152976871434> Found multiple users! Please be more specific or mention the user instead."
|
|
|
|
);
|
|
|
|
else if (usersFound.length == 0)
|
|
|
|
return message.channel.send(
|
|
|
|
"<:error:466995152976871434> That user doesn't seem to exist. Try again!"
|
|
|
|
);
|
|
|
|
user = usersFound[0].user;
|
|
|
|
}
|
|
|
|
|
|
|
|
users.push(user);
|
|
|
|
totalLength += user.username.length;
|
|
|
|
}
|
|
|
|
|
|
|
|
let lengthPerUser = Math.floor(totalLength / users.length);
|
|
|
|
|
|
|
|
let finalName = '';
|
|
|
|
|
|
|
|
let last = -1;
|
|
|
|
|
|
|
|
for(let i = 0; i < users.length; i++) {
|
|
|
|
let user = users[i];
|
|
|
|
let l = Math.min(lengthPerUser, user.username.length);
|
|
|
|
|
|
|
|
let p = user.username.substr(last + 1, last + l);
|
|
|
|
|
|
|
|
console.log(p);
|
|
|
|
|
|
|
|
finalName = finalName + p;
|
2020-03-16 01:14:33 +00:00
|
|
|
|
2020-03-21 09:46:51 +00:00
|
|
|
last = last + l;
|
2020-03-16 01:14:33 +00:00
|
|
|
};
|
2020-03-11 10:46:13 +00:00
|
|
|
|
2020-03-21 09:46:51 +00:00
|
|
|
console.log(totalLength);
|
|
|
|
console.log(users.length);
|
|
|
|
console.log(lengthPerUser);
|
|
|
|
console.log(finalName);
|
2020-03-11 10:46:13 +00:00
|
|
|
|
|
|
|
try {
|
2020-03-21 09:46:51 +00:00
|
|
|
//var attachment = new Discord.MessageAttachment(`https://api.alexflipnote.dev/ship?user=${user.avatarURL({format: "png"})}&user2=${user2.avatarURL({format: "png"})}`)
|
|
|
|
message.channel.send(`Your ship name is **${finalName}!**`)
|
2020-03-11 10:46:13 +00:00
|
|
|
message.channel.stopTyping();
|
|
|
|
} catch(err) {
|
|
|
|
message.channel.send(`<:error:466995152976871434> API error: ${err}`);
|
|
|
|
message.channel.stopTyping();
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
exports.conf = {
|
|
|
|
enabled: true,
|
2020-03-16 01:14:33 +00:00
|
|
|
guildOnly: true,
|
2020-03-11 10:46:13 +00:00
|
|
|
aliases: [],
|
|
|
|
permLevel: "User",
|
|
|
|
requiredPerms: []
|
|
|
|
};
|
|
|
|
|
|
|
|
exports.help = {
|
|
|
|
name: "ship",
|
|
|
|
category: "Fun",
|
|
|
|
description: "Ship two people together <3",
|
|
|
|
usage: "ship name name2"
|
|
|
|
};
|
|
|
|
|