This repository has been archived by the owner on Mar 27, 2023. It is now read-only.
generated from Gesugao-san/infrastructure-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
fbef241
commit d42a0ae
Showing
4 changed files
with
1,103 additions
and
36 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
|
||
// https://stackoverflow.com/a/64648205/8175291 | ||
const fetch = require('node-fetch'); // [email protected] | ||
//import fetch from "node-fetch"; | ||
|
||
const code_valid = 'discord-testers'; | ||
const code_invalid = 'this-is-invalid'; | ||
// https://discordapp.com/api/widget/0 | ||
// https://discordapp.com/api/invite/${code} | ||
|
||
async function check_guild_widget(id) { | ||
process.stdout.write(`guild "${id}": `); | ||
await fetch(`https://discord.com/api/guilds/${id}/widget.json`) | ||
.then((res) => res.json()) | ||
.then((json) => { | ||
if (json.message === 'Unknown Guild') { | ||
//console.log(`the invite is invalid`); | ||
return Promise.reject(`the guild is unknown`); // Error 1015... | ||
} | ||
process.stdout.write(`valid, `); | ||
if (json.message === 'Widget Disabled') { | ||
return Promise.reject(`widget is disabled`); | ||
} | ||
console.log(`widget is enabled.`); | ||
}); | ||
} | ||
|
||
async function check_invite(code) { | ||
process.stdout.write(`invite "${code}": `); | ||
await fetch(`https://discordapp.com/api/invite/${code}`) | ||
.then((res) => res.json()) | ||
.then((json) => { | ||
if (json.message === 'Unknown Invite') { | ||
console.log(`invalid`); | ||
return; | ||
} else { | ||
console.log(`valid`); | ||
} | ||
}); | ||
await check_guild_widget(json.guild.id); | ||
} | ||
|
||
|
||
(async () => { | ||
await check_invite(code_valid); | ||
await check_invite(code_invalid); | ||
})(); |
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
Oops, something went wrong.