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'],
|
clientPermissions: ['MANAGE_WEBHOOKS'],
|
||||||
args: [
|
args: [
|
||||||
{
|
{
|
||||||
id: 'member',
|
id: 'user',
|
||||||
type: 'user',
|
type: 'user',
|
||||||
prompt: {
|
prompt: {
|
||||||
start: 'Who should i fake?',
|
start: 'Who should i fake?',
|
||||||
|
@ -35,20 +35,25 @@ class fakebotCommand extends Command {
|
||||||
async exec(message, args) {
|
async exec(message, args) {
|
||||||
let Attachment = (message.attachments).array();
|
let Attachment = (message.attachments).array();
|
||||||
let url;
|
let url;
|
||||||
|
let username = args.user.username;
|
||||||
// Get attachment link
|
// Get attachment link
|
||||||
if (Attachment[0]) {
|
if (Attachment[0]) {
|
||||||
url = Attachment[0].url;
|
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, {
|
message.channel.createWebhook(username, {
|
||||||
avatar: args.member.displayAvatarURL(),
|
avatar: args.user.displayAvatarURL(),
|
||||||
reason: `Fakebot/user command triggered by: ${message.author.username}`
|
reason: `Fakebot/user command triggered by: ${message.author.username}`
|
||||||
})
|
})
|
||||||
.then(webhook => {
|
.then(webhook => {
|
||||||
// Have to edit after creation otherwise the picture doesn't get applied
|
// Have to edit after creation otherwise the picture doesn't get applied
|
||||||
webhook.edit({
|
webhook.edit({
|
||||||
name: args.member.username,
|
name: username,
|
||||||
avatar: args.member.displayAvatarURL(),
|
avatar: args.user.displayAvatarURL(),
|
||||||
reason: `Fakebot/user command triggered by: ${message.author.username}`
|
reason: `Fakebot/user command triggered by: ${message.author.username}`
|
||||||
});
|
});
|
||||||
this.client.fetchWebhook(webhook.id, webhook.token)
|
this.client.fetchWebhook(webhook.id, webhook.token)
|
||||||
|
@ -61,7 +66,9 @@ class fakebotCommand extends Command {
|
||||||
webhook.send(args.message);
|
webhook.send(args.message);
|
||||||
|
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
webhook.delete();
|
webhook.delete({
|
||||||
|
reason: `Fakebot/user command triggered by: ${message.author.username}`
|
||||||
|
});
|
||||||
}, 3000);
|
}, 3000);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue