0

I have a webpage, and on that webpage is a file called b.txt, (http://#####.###/b.txt), how am I able to get my DiscordJS bot to display the contents of b.txt (the file just says hilly in plaintext")

Currently I just have const txtfile = "http://example.ml/b.txt";

And have a simple command to output the variable.

      client.on('message', message => {
          if (message.content === 'b') {
            message.channel.send(mcdonal);

          }
         });

Any help would be appreciated.

1 Answers1

1

Install node fetch to your project with

npm install node-fetch

include it with

const fetch = require('node-fetch'); than you can in either load the file once if it is static in your variable or load every time in your message event handler with e.g.

fetch('http://example.ml/b.txt')
    .then(res => res.text())

See also https://www.npmjs.com/package/node-fetch

overflowed
  • 1,773
  • 10
  • 13