2017-08-26 69 views
0

所以我试图做一个机器人,发布数据给hastebin。 但它并不真正表现良好。我正在使用discord.js和hastebin-gen。Discord x Hastebin命令行为不如预期

这是代码:

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,它返回:(https://a.pomf.cat/rkjqog.png)(注:不能发表图片呢,抱歉)

如果我点击。 (https://a.pomf.cat/ovcpzb.png

但是有一个令人讨厌的事实,就是它重复给定的文本,如在链接末尾和链接之后所看到的那样。

回答

0

它添加的是你传递给hastebin-gen的扩展。不要通过一个,它只会回应链接。

Hastebin根只增加扩展到的链接在这一行:

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

扩展并不在所有问题,hastebin.com/beqojuzowe.jhffyjbfft将指向相同hastebin.com/beqojuzowe

TL; DR使用:

hastebin(haste).then(r => {