【问题标题】:Bot has roblem with sending/editing embed messagesBot 在发送/编辑嵌入消息时遇到问题
【发布时间】:2020-08-09 20:53:03
【问题描述】:

所以我已经到处问了,但我不知道如何修复 eroor:ReferenceError: send is not defined 在非嵌入版本中一切正常,但在这里它不会。

module.exports = {
        name: 'lat2',
        description: 'Let the Bot display latency/Response Time and API latency/"Remote Response time"',
        execute(message, args) {
            const Discord = require('discord.js');
            let Embed1 = new Discord.MessageEmbed()
                .setColor(0x0099ff)
                .setDescription("Pinging...")

            let Embed2 = new Discord.MessageEmbed()
                .setColor(0x0099ff)
                .setTitle("Latencies")
                .setDescription(`Latency/Response Time: ${send.createdTimestamp - message.createdTimestamp}ms\nAPI latency/"Remote Response time": ${Math.round(message.client.ws.ping)}ms`)

            msg.channel.send(Embed1).then(msg => {
                msg.edit(Embed2);
            });
        }
    };

【问题讨论】:

    标签: javascript bots discord.js send defined


    【解决方案1】:

    问题不在于发送消息,而是在抱怨${send.createdTimestamp},因为您没有在任何地方定义“发送”。 尝试用message.createdAt替换它

    要仍然获得延迟,请尝试以下操作:

    module.exports = {
            name: 'lat2',
            description: 'Let the Bot display latency/Response Time and API latency/"Remote Response time"',
            execute(message, args) {
                const Discord = require('discord.js');
                let Embed1 = new Discord.MessageEmbed()
                    .setColor(0x0099ff)
                    .setDescription("Pinging...")
    
                msg.channel.send(Embed1).then(m => {
    
                let Embed2 = new Discord.MessageEmbed()
                    .setColor(0x0099ff)
                    .setTitle("Latencies")
                    .setDescription(`Latency/Response Time: ${m.createdTimestamp - message.createdTimestamp}ms\nAPI latency/"Remote Response time": ${Math.round(message.client.ws.ping)}ms`)
                    m.edit(Embed2);
                });
            }
        };
    

    【讨论】:

    • 你是对的,非常感谢,但除了 message.createdAt 之外你还知道什么吗,因为那时它将是 0ms
    • 您只能在编辑后获得延迟,因此您必须在编辑消息的部分中定义第二个嵌入。我编辑了我的答案以表明我的意思
    猜你喜欢
    • 2020-11-07
    • 2020-08-09
    • 1970-01-01
    • 2012-12-07
    • 2021-08-31
    • 1970-01-01
    • 2023-03-07
    • 2021-06-24
    • 1970-01-01
    相关资源
    最近更新 更多