node fetch

This commit is contained in:
rhearmas 2020-02-03 20:48:43 -05:00
parent 3f05cfffa2
commit 5f0fc4c05b

View file

@ -1,5 +1,6 @@
const Discord = require("discord.js"); const Discord = require("discord.js");
const got = require("got"); const got = require("got");
const fetch = require("node-fetch");
module.exports = (client) => { module.exports = (client) => {
client.permlevel = message => { client.permlevel = message => {
@ -328,4 +329,11 @@ module.exports = (client) => {
}; };
client.quoteRegex = input => `${input}`.replace(/[.?*+^$[\]\\(){}|-]/g, '\\$&'); client.quoteRegex = input => `${input}`.replace(/[.?*+^$[\]\\(){}|-]/g, '\\$&');
client.fetchURL = (url, options = {}) => {
options.headers = options.headers ? { ...options.headers, "User-Agent": client.user } : { "User-Agent": client.user };
return fetch(url, options, options.type || "json").catch(error => {
client.Logger.error(error);
});
}
}; };