我希望在discord.js
上发出邀请命令,但似乎无法使其正常工作。
var targetUser = null;
var isAnotherUserLookup = false;
if(message.mentions.members.first() != null)
{
targetUser = message.mentions.members.first();
isAnotherUserLookup = true;
}
else
targetUser = message.member;
message.guild.fetchInvites()
.then
(invites =>
{var targetUser = null;
var isAnotherUserLookup = false;
if(message.mentions.members.first() != null)
{
targetUser = message.mentions.members.first().user;
console.log(targetUser.user);
isAnotherUserLookup = true;
}
else
targetUser = message.author;
message.guild.fetchInvites()
.then
(invites =>
{
const userInvites = invites.array().filter(o => o.inviter.id === targetUser.id);
var userInviteCount = 0;
if(isAnotherUserLookup)
message.channel.send(`User _${targetUser.username}_ has invited ${userInviteCount} user(s) to this server.`);
else
message.reply(`You have invited ${userInviteCount} user(s) to this server. Keep up the good work!`);
return;
}
)
}
)
}
它一直在提出消息,但我有0个邀请。
我已经查看了我的代码几次,尝试进行更改,总体上没有任何效果,如果可以确定,我之前没有联系过,但那一直没有成功。如果我能找到问题所在以及如何解决的答案,那就太好了。