Skip to content

Instantly share code, notes, and snippets.

@michel-pi
Created December 2, 2019 05:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save michel-pi/8d00e8420b17d092fa59a1ed55e4b323 to your computer and use it in GitHub Desktop.
Save michel-pi/8d00e8420b17d092fa59a1ed55e4b323 to your computer and use it in GitHub Desktop.
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