discord.js机器人即使与用户共享服务器,也无法向用户发送消息

时间:2019-02-11 19:13:39

标签: node.js discord.js

我正在尝试为我和一些朋友制作一个令人毛骨悚然的缠扰者机器人,但我有多个朋友。所以我有2台服务器,其中有2套不同的人。现在我不完全知道我在做什么,我只是从互联网上偷东西,然后对整个事情进行科学怪人的准备,但是我似乎遇到了麻烦。问题是我的机器人似乎无法从其中一台服务器向我的一组朋友发送任何消息,即使它与他们共享一台服务器。每次尝试时,都会出现此错误:

   (node:12780) UnhandledPromiseRejectionWarning: DiscordAPIError: Cannot send messages to this user
    at item.request.gen.end (C:\Users\creep\Downloads\bots\node_modules\discord.js\src\client\rest\RequestHandlers\Sequential.js:79:15)
    at then (C:\Users\creep\Downloads\bots\node_modules\snekfetch\src\index.js:215:21)
    at process.internalTickCallback (internal/process/next_tick.js:77:7)
(node:12780) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 2)

它不会使机器人或其他任何东西崩溃,但idk意味着什么,我也找不到答案。这是运行它的代码(是的,id是正确的)。 第一个是调用该函数的行,第二个是实际的函数,该函数找出对谁说些什么:

else if (msg === "!they.move") {
                        message.channel.send("They shift their attention, although unwillingly.");
                        if (message.guild.id === '*this is a server id*' || message.guild.id === '*this a another serverid*') {
                                console.log ("they move 1");
                                theymove1();
                        }
                        else if (message.guild.id === '*this is also a server id*') {
                                console.log ("they move 2");
                                theymove2();
                        }
                }

function theymove1() {

        spew = (random(10, 4));
    if (spew === 6 || spew === 7) {
            spew = (random(3, 1));
            if (spew === 1) {
                    client.users.get('360550551383179267').send("They Stare");
                    client.users.get('360550551383179267').send(new Discord.Attachment('./they watch they listen they wisper/They Watch.png', 'They Watch.png'));
            }
            else if (spew === 2) {
                    client.users.get('360550551383179267').send("They Mutter");
                    client.users.get('360550551383179267').send(new Discord.Attachment('./they watch they listen they wisper/They Wisper.png', 'They Wisper.png'));
            }
            else if (spew === 3) {
                    client.users.get('360550551383179267').send("They Listen");
                    client.users.get('360550551383179267').send(new Discord.Attachment('./they watch they listen they wisper/They Listen.png', 'They Listen.png'));
            }
            console.log('kreket');
    }
    else if (spew === 5 || spew === 8) {
            spew = (random(3, 1));

            if (spew === 1) {
                    client.users.get('360550959115534346').send("They Stare");
                    client.users.get('360550959115534346').send(new Discord.Attachment('./they watch they listen they wisper/They Watch.png', 'They Watch.png'));
            }
            else if (spew === 2) {
                    client.users.get('360550959115534346').send("They Mutter");
                    client.users.get('360550959115534346').send(new Discord.Attachment('./they watch they listen they wisper/They Wisper.png', 'They Wisper.png'));
            }
            else if (spew === 3) {
                    client.users.get('360550959115534346').send("They Listen");
                    client.users.get('360550959115534346').send(new Discord.Attachment('./they watch they listen they wisper/They Listen.png', 'They Listen.png'));
            }
            console.log('autini');
    }
    else if (spew === 4 || spew === 9) {
            spew = (random(3, 1));
            if (spew === 1) {
                    client.users.get('353429296901259275').send("They Stare");
                    client.users.get('353429296901259275').send(new Discord.Attachment('./they watch they listen they wisper/They Watch.png', 'They Watch.png'));
            }
            else if (spew === 2) {
                    client.users.get('353429296901259275').send("They Mutter");
                    client.users.get('353429296901259275').send(new Discord.Attachment('./they watch they listen they wisper/They Wisper.png', 'They Wisper.png'));
            }
            else if (spew === 3) {
                    client.users.get('353429296901259275').send("They Listen");
                    client.users.get('353429296901259275').send(new Discord.Attachment('./they watch they listen they wisper/They Listen.png', 'They Listen.png'));
            }
                console.log('avertask');
        }
}

function theymove2() {
    spew = (random(3, 1));

    if (spew === 3) {
            spew = (random(3, 1));
            if (spew === 1) {
                    client.users.get('194606572893241344').send("They Stare");
                    client.users.get('194606572893241344').send(new Discord.Attachment('./they watch they listen they wisper/They Watch.png', 'They Watch.png'));
            }
            else if (spew === 2) {
                    client.users.get('194606572893241344').send("They Mutter");
                    client.users.get('194606572893241344').send(new Discord.Attachment('./they watch they listen they wisper/They Wisper.png', 'They Wisper.png'));
            }
            else if (spew === 3) {
                    client.users.get('194606572893241344').send("They Listen");
                    client.users.get('194606572893241344').send(new Discord.Attachment('./they watch they listen they wisper/They Listen.png', 'They Listen.png'));
            }
            console.log('arky');
    }
    else if (spew === 2) {
            spew = (random(3, 1));
            if (spew === 1) {
                    client.users.get('328590989931577354').send("They Stare");
                    client.users.get('328590989931577354').send(new Discord.Attachment('./they watch they listen they wisper/They Watch.png', 'They Watch.png'));
            }
            else if (spew === 2) {
                    client.users.get('328590989931577354').send("They Mutter");
                    client.users.get('328590989931577354').send(new Discord.Attachment('./they watch they listen they wisper/They Wisper.png', 'They Wisper.png'));
            }
            else if (spew === 3) {
                    client.users.get('328590989931577354').send("They Listen");
                    client.users.get('328590989931577354').send(new Discord.Attachment('./they watch they listen they wisper/They Listen.png', 'They Listen.png'));
            }
            console.log('muffin');
    }
    else if (spew === 1) {
            spew = (random(3, 1));
            if (spew === 1) {
                    client.users.get('442822494982766592').send("They Stare");
                    client.users.get('442822494982766592').send(new Discord.Attachment('./they watch they listen they wisper/They Watch.png', 'They Watch.png'));
            }
            else if (spew === 2) {
                    client.users.get('442822494982766592').send("They Mutter");
                    client.users.get('442822494982766592').send(new Discord.Attachment('./they watch they listen they wisper/They Wisper.png', 'They Wisper.png'));
            }
            else if (spew === 3) {
                    client.users.get('442822494982766592').send("They Listen");
                    client.users.get('442822494982766592').send(new Discord.Attachment('./they watch they listen they wisper/They Listen.png', 'They Listen.png'));
            }
            console.log('china');
    }
    return;

}

0 个答案:

没有答案