邀请命令(discord.js)出现问题

时间:2020-01-05 14:25:56

标签: javascript node.js discord discord.js

我希望在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个邀请。

我已经查看了我的代码几次,尝试进行更改,总体上没有任何效果,如果可以确定,我之前没有联系过,但那一直没有成功。如果我能找到问题所在以及如何解决的答案,那就太好了。

0 个答案:

没有答案