有问题的API是一个双关语,即这个。我使用的代码如下:

const superagent = require("superagent")
module.exports = {
    run: async(client, message, args) => {
    const pun = await superagent.get("https://getpuns.herokuapp.com/api/random")
    message.channel.send(pun.text);
    },
aliases: []
}


API返回{"Pun":"I'm going to stand outside, so if anyone asks I'm outstanding."}。这是预期的,但我希望能够删除某些部分以使其最终成为I'm going to stand outside, so if anyone asks I'm outstanding

最佳答案

假设pun.text保留值{"Pun":"I'm going to stand outside, so if anyone asks I'm outstanding."}

您可以尝试替换pun.text width pun.text.Pun

10-08 00:53