Show nickname if user is in guild
This commit is contained in:
parent
2c395c6552
commit
63515aa73a
1 changed files with 13 additions and 6 deletions
|
@ -8,7 +8,7 @@ class fakebotCommand extends Command {
|
|||
clientPermissions: ['MANAGE_WEBHOOKS'],
|
||||
args: [
|
||||
{
|
||||
id: 'member',
|
||||
id: 'user',
|
||||
type: 'user',
|
||||
prompt: {
|
||||
start: 'Who should i fake?',
|
||||
|
@ -35,20 +35,25 @@ class fakebotCommand extends Command {
|
|||
async exec(message, args) {
|
||||
let Attachment = (message.attachments).array();
|
||||
let url;
|
||||
let username = args.user.username;
|
||||
// Get attachment link
|
||||
if (Attachment[0]) {
|
||||
url = Attachment[0].url;
|
||||
}
|
||||
// Show nickname if user is in guild
|
||||
if (message.guild.members.get(args.user.id)) {
|
||||
username = message.guild.members.get(args.user.id).nickname;
|
||||
}
|
||||
|
||||
message.channel.createWebhook(args.member.username, {
|
||||
avatar: args.member.displayAvatarURL(),
|
||||
message.channel.createWebhook(username, {
|
||||
avatar: args.user.displayAvatarURL(),
|
||||
reason: `Fakebot/user command triggered by: ${message.author.username}`
|
||||
})
|
||||
.then(webhook => {
|
||||
// Have to edit after creation otherwise the picture doesn't get applied
|
||||
webhook.edit({
|
||||
name: args.member.username,
|
||||
avatar: args.member.displayAvatarURL(),
|
||||
name: username,
|
||||
avatar: args.user.displayAvatarURL(),
|
||||
reason: `Fakebot/user command triggered by: ${message.author.username}`
|
||||
});
|
||||
this.client.fetchWebhook(webhook.id, webhook.token)
|
||||
|
@ -61,7 +66,9 @@ class fakebotCommand extends Command {
|
|||
webhook.send(args.message);
|
||||
|
||||
setTimeout(() => {
|
||||
webhook.delete();
|
||||
webhook.delete({
|
||||
reason: `Fakebot/user command triggered by: ${message.author.username}`
|
||||
});
|
||||
}, 3000);
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue