Created
December 2, 2019 05:43
-
-
Save michel-pi/8d00e8420b17d092fa59a1ed55e4b323 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function DiscordWidgetData() { | |
this.load = async function (guildId) { | |
return new Promise(function (resolve, reject) { | |
fetch("https://discordapp.com/api/v6/guilds/" + guildId + "/widget.json", { | |
method: "GET", | |
mode: "cors", | |
cache: "reload", | |
redirect: "follow" | |
}).then(response => { | |
if (!response.ok) { | |
reject(new Error(response.statusText)); | |
return; | |
} | |
resolve(response.json()); | |
}).catch(e => { | |
console.log(e); | |
reject(e); | |
}); | |
}); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment