简体   繁体   English

Discord x Hastebin命令的行为不符合预期

[英]Discord x Hastebin command doesn't behave as intended

So I'm trying to make a bot that posts given data to hastebin. 因此,我正在尝试制作一个将给定数据发布到hastebin的机器人。 But it doesn't really behave well. 但是它的表现并不理想。 I'm using discord.js and hastebin-gen. 我正在使用discord.js和hastebin-gen。

This is the code: 这是代码:

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);
}

When ran, for example bin.haste this code is awesome , it returns this:( https://a.pomf.cat/rkjqog.png ) (Note: Can't post images yet, sorry.) 当运行时,例如bin.haste this code is awesome ,它返回bin.haste this code is awesome :( https://a.pomf.cat/rkjqog.png )(注意:无法发布图像,对不起。)

If I click on the link, it successfully uploads the text given to Hastebin: ( https://a.pomf.cat/ovcpzb.png ) 如果单击链接,它将成功上传给Hastebin的文本:( https://a.pomf.cat/ovcpzb.png

But there's just that annoying fact that it repeats the given text, as seen at the end of the link, and after the link. 但是,有一个令人讨厌的事实,就是它会重复给定的文本,如在链接末尾和链接后所示。

What it's adding is the extension you're passing to hastebin-gen. 它添加的是您传递给hastebin-gen的扩展名。 Don't pass one and it will just respond with the link. 不要传递一个,它只会通过链接做出响应。

Hastebin-gen only adds the extension to the link at this line: Hastebin-gen仅将扩展名添加到此行的链接中:

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

The extension doesn't matter at all, hastebin.com/beqojuzowe.jhffyjbfft will point to the same as hastebin.com/beqojuzowe . 扩展名根本不重要, hastebin.com/beqojuzowe.jhffyjbfft指向的名称与hastebin.com/beqojuzowe相同。

TL;DR use this: TL; DR使用此:

hastebin(haste).then(r => {

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM