简体   繁体   中英

discord.js Read data from URL

I can't figure out how to read data from a url like get the text from it such as

url = "https://pastebin.com/raw/k4dEkXCz"

andI want to read data from it like what it says

Answer:

const Discord = require("discord.js");
let snekfetch = require("snekfetch")

module.exports.run = async (bot, message, args) => {
let url = "https://pastebin.com/raw/k4dEkXCz"
snekfetch.get(url).then(r => console.log(decodeURIComponent(r.body)));
}

module.exports.help = {
name: "test"
} 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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