Discord x Hastebin 命令未按预期运行

Discord x Hastebin command doesn't behave as intended

所以我正在尝试制作一个 post 向 hastebin 提供数据的机器人。 但它确实表现不佳。我正在使用 discord.js 和 hastebin-gen.

这是代码:

const hastebin = require('hastebin-gen');
exports.run = (client, msg, args) => {
    let haste = args.slice(0).join(" ")
    let type = args.slice(1).join(" ")
    if (!args[0]) { return msg.channel.send("Usage: bin.haste yourmsghere.") }
        hastebin(haste, type).then(r => {
        msg.channel.send(":white_check_mark: Posted text to Hastebin at this URL: " + r);
    }).catch(console.error);
}

当运行时,比如bin.haste this code is awesome,它returns这个:(https://a.pomf.cat/rkjqog.png) (注:还不能post图片,sorry .)

如果我点击 link,它会成功上传给 Hastebin 的文本:(https://a.pomf.cat/ovcpzb.png)

但有一个令人讨厌的事实,即它会重复给定的文本,如 link 末尾和 link 之后所见。

它添加的是您传递给 hastebin-gen 的扩展。不要传递一个,它只会用 link.

响应

Hastebin-gen 仅在这一行添加 link 的扩展名:

res("https://hastebin.com/" + body.body.key + ((extension) ? "." + extension : ""));

扩展名根本不重要,hastebin.com/beqojuzowe.jhffyjbfft 将指向与 hastebin.com/beqojuzowe 相同的内容。

TL;DR 使用这个:

hastebin(haste).then(r => {