由服务器托管漫游器时发送嵌入消息时发生错误

问题描述 投票:0回答:1

(node:24) UnhandledPromiseRejectionWarning: TypeError: fields.flat is not a function

有人知道如何在服务器上托管Bot时解决此错误,因为当新用户加入Disord Server时该错误会出现,并且该Bot通常会发送embed dm welcome消息,但现在它只是给我这个错误,当我在PC上启动了bot,它的工作原理非常好,当我使用非嵌入版本时,它也可以在服务器上运行,因此它与嵌入消息有关。

我的整个代码顺便说一句:

const Discord = require('discord.js');
const { prefix, token } = require('./config.json');
const client = new Discord.Client();

client.on('ready', () => {
    console.log('Ready!');
    client.user.setPresence({ activity: { name: 'with servers!📁' }, status: 'online' })
})

client.on("guildMemberAdd", member => {
    try {
        const Embed = {
            color: 0x0099ff,
            title: 'Welcome!',
            url: 'https://potatohost.cc',
            description: 'We offer Budget Minecraft, Minecraft Bedrock, Rust, Deticated Servers, Discord Bot and VPS Servers. We also sell domains and web designs!',
            thumbnail: {
                "url": 'attachment://ironnode.png',
            },
            fields: [
                {
                    name: `Hey!`,
                    value: `I want to help you and so my question is: Do you want to buy a server or do you need more information first? \n
                    A: I want to buy a server
                    B: I need more information first \n
                    Please react to this message with A or B.`,
                },
            ],
            image: {
                url: "attachment://ironnode.png",
            },
            timestamp: new Date(),
            footer: {
                text: 'Have a great time!',
                icon_url: "attachment://ironnode.png",
            },
        };

        member.send({ embed: Embed, files: [{
            attachment:'/home/container/ironnode.png',
            name:'ironnode.png'
          }] })

        .then(function (message) {
            message.react("🇦")
            message.react("🇧")
            const filter = (reaction, user) => {
                return ['🇦', '🇧'].includes(reaction.emoji.name) && user.id === member.id;
        };

        message.awaitReactions(filter, { max: 1 })
                .then(collected => {
                    const reaction = collected.first();

                    if (reaction.emoji.name === '🇦') {
                        const Embed = {
                            color: 0x0099ff,
                            description: 'Ok, so you want to buy a server. Let me recommend you to create a ticket in <#700601793750499348>.',
                        };
                        message.channel.send({ embed: Embed })
                    }
                    else {
                        const Embed = {
                            color: 0x0099ff,
                            description: 'Ok, so you need more information first. Let me recommend you to visit <#700610172879634472>.',
                        };
                        message.channel.send({ embed: Embed })
                    }    
                })
        });
    }catch (err) {
         console.log(err)
    }
})

client.on('message', message => {
    if (message.content === `${prefix}ping`) {
        message.channel.send('Pong.');
    }
});

client.login(token);
javascript server bots discord.js vps
1个回答
0
投票

您需要将node.js更新到v12 +

© www.soinside.com 2019 - 2024. All rights reserved.