【问题标题】:Is there a way to make RichEmbed methods work in Heroku?有没有办法让 RichEmbed 方法在 Heroku 中工作?
【发布时间】:2019-09-13 02:08:02
【问题描述】:

尝试使用此代码时出现以下错误:

const embed = new RichEmbed();

var num = Math.floor(Math.random() * 10);
let name = part + num + ".gif";

embed.attachFiles([name]);
embed.setImage('attachment://' + name);

mess.channel.send(embed);
TypeError: embed.attachFiles is not a function

如果我删除 embed.attachFiles([name]),我会收到一条错误消息,指出 embed.setImage 也不是函数。
我能做些什么来让 Heroku 将这些注册为函数吗?值得注意的是,当我在自己的计算机上使用命令行运行它时,这在 Heroku 之外工作

【问题讨论】:

    标签: heroku discord discord.js


    【解决方案1】:

    Heroku 本身不会修改 discord.js 的行为。以下是您可以尝试的事项列表:

    • 验证您的 package.json 文件是否已更新为您想要的 discord.js 版本并运行 npm i 以确保您电脑上的版本相同*。
    • 确保RichEmbedDiscord.RichEmbed:尝试明确地编写它,看看是否有帮助。
    • 尝试console.log(embed) 并查看控制台中记录的内容:这可能会让您了解问题所在...

    * 在11.0.0 version 中添加了RichEmbed.attachFile() 方法:任何以前版本的discord.js 都不允许您使用它。

    【讨论】:

    • 我将 discord.js 的版本更改为我计算机上运行的版本,现在它给了我新的错误:npm ERR! code ETARGET npm ERR! notarget No matching version found for discord.js@6.4.1 npm ERR! notarget In most cases you or one of your dependencies are requesting npm ERR! notarget a package version that doesn't exist. npm ERR! notarget npm ERR! notarget It was specified as a dependency of 'Trojinator' npm ERR! notarget
    • 您似乎正在尝试安装 6.4.1 版本:这太旧了,您的代码无法使用该版本。试试npm i discord.js@11.4.2
    猜你喜欢
    • 1970-01-01
    • 2019-07-12
    • 1970-01-01
    • 1970-01-01
    • 2015-09-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-05-10
    相关资源
    最近更新 更多