diff --git a/modules/functions.js b/modules/functions.js index 1284449..4d75bb5 100644 --- a/modules/functions.js +++ b/modules/functions.js @@ -1,5 +1,6 @@ const Discord = require("discord.js"); const got = require("got"); +const fetch = require("node-fetch"); module.exports = (client) => { client.permlevel = message => { @@ -328,4 +329,11 @@ module.exports = (client) => { }; 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); + }); + } }; \ No newline at end of file