accept user ID's

This commit is contained in:
Emily 2021-03-07 01:15:07 +11:00
parent abe8c824e3
commit c58df67896
4 changed files with 58 additions and 38 deletions

View file

@ -36,7 +36,9 @@ module.exports = class {
return;
}
if (action.toLowerCase() !== 'add' || action.toLowerCase() !== 'remove') {
action = action.toLowerCase();
if (action !== 'add' & action !== 'remove') {
return message.channel.createMessage(`${client.emojis.userError} You didn't specify a valid action. Usage: \`${this.help.usage}\``);
}
@ -44,17 +46,27 @@ module.exports = class {
`${client.emojis.userError} You didn't specify a user. Usage: \`${message.prefix + this.help.usage}\``
);
let member = message.mentions[0];
let member;
if (!member) member = await message.channel.guild.searchMembers(user.join(' '), 2);
if (message.mentions.length > 0) {
member = await client.functions.getMember(message.channel.guild, message.mentions[0].id);
} else {
member = await client.functions.validateUserID(message.channel.guild, user[0]);
if (!member) {
member = await message.channel.guild.searchMembers(user.join(' '), 2);
if (member.length === 0) return message.channel.createMessage(
`${client.emojis.userError} No users found. Check for mispellings, or ping the user instead.`
);
if (member.length > 1) return message.channel.createMessage(
`${client.emojis.userError} Found more than one user, try refining your search or pinging the user instead.`
);
action = action.toLowerCase();
member = member[0];
}
}
const blocklist = data.guild.blocklist;

View file

@ -18,30 +18,34 @@ module.exports = class {
async run (client, message, args, data) { //eslint-disable-line no-unused-vars
let user = message.author;
let member = message.member;
if (args[0]) {
user = message.mentions[0];
if (message.mentions.length > 0) {
member = await client.functions.getMember(message.channel.guild, message.mentions[0].id);
} else {
member = await client.functions.validateUserID(message.channel.guild, args[0]);
if (!user) {
user = await message.channel.guild.searchMembers(args.join(' '), 2);
if (!member) {
member = await message.channel.guild.searchMembers(args.join(' '), 2);
if (user.length < 1) return message.channel.createMessage(
if (member.length === 0) return message.channel.createMessage(
`${client.emojis.userError} No users found. Check for mispellings, or ping the user instead.`
);
if (user.length > 1) return message.channel.createMessage(
if (member.length > 1) return message.channel.createMessage(
`${client.emojis.userError} Found more than one user, try refining your search or pinging the user instead.`
);
user = user[0].user;
member = member[0];
}
}
}
const embed = new client.RichEmbed()
.setTitle(user.username + '#' + user.discriminator)
.setColour(client.functions.displayHexColour(message.channel.guild, user.id))
.setImage(user.avatarURL);
.setTitle(member.user.username + '#' + member.user.discriminator)
.setColour(client.functions.displayHexColour(message.channel.guild, member))
.setImage(member.user.avatarURL);
message.channel.createMessage({ embed: embed });
}

View file

@ -26,6 +26,9 @@ module.exports = class {
if (message.mentions.length > 0) {
member = await client.functions.getMember(message.channel.guild, message.mentions[0].id);
} else {
member = await client.functions.validateUserID(message.channel.guild, args[0]);
if (!member) {
member = await message.channel.guild.searchMembers(args.join(' '), 2);
if (member.length === 0) return message.channel.createMessage(
@ -39,6 +42,7 @@ module.exports = class {
member = member[0];
}
}
}
const badges = [];

View file

@ -72,7 +72,7 @@ class Functions {
let hexadecimal = object.color.toString(16);
while (hexadecimal.length < 6) {
hexadecimal = '0' + hexadecimal;
};
}
return '#' + hexadecimal;
}