generated from sapphiredev/sapphire-template
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: switch to `undici` * chore(deps): update * fix: wrong filename * docs: use https://contrib.rocks for the contributors image
- Loading branch information
Tomio
committed
Jan 28, 2023
1 parent
8d772ac
commit ca45be8
Showing
10 changed files
with
173 additions
and
191 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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,27 @@ | ||
name: Check Botlists | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
pull_request: | ||
schedule: | ||
- cron: '0 0 * * *' | ||
|
||
jobs: | ||
check-botlists: | ||
name: Check Botlists | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout Project | ||
uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b # tag=v3 | ||
- name: Use Node.js v18 | ||
uses: actions/setup-node@56337c425554a6be30cdef71bf441f15be286854 # tag=v3 | ||
with: | ||
node-version: 18 | ||
cache: yarn | ||
registry-url: https://registry.npmjs.org/ | ||
- name: Install Dependencies | ||
run: yarn --immutable | ||
- name: Check botlists | ||
run: yarn check-botlists |
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
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
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,55 @@ | ||
import { fetch } from 'undici'; | ||
import { bold, green, red } from 'colorette'; | ||
|
||
/** @type {[string, number | undefined, string | undefined][]} */ | ||
const sites = [ | ||
['https://top.gg'], | ||
['https://top.gg/api', 418 /* I'm a teapot */], | ||
['https://discordbotlist.com'], | ||
['https://bots.ondiscord.xyz'], | ||
['https://discords.com'], | ||
['https://discords.com/bots/api'], | ||
['https://bots.discordlabs.org'], | ||
['https://botlist.me'], | ||
['https://discord.bots.gg'], | ||
['https://discord.bots.gg/api/v1', undefined, 'GET'], | ||
['https://discordextremelist.xyz'], | ||
['https://api.discordextremelist.xyz/v2/health'], | ||
['https://blist.xyz'], | ||
['https://blist.xyz/api/v2'], | ||
['https://discordservices.net'], | ||
['https://api.discordservices.net'], | ||
['https://disforge.com'], | ||
['https://disforge.com/api'], | ||
['https://infinitybots.gg'], | ||
['https://api.infinitybots.gg'], | ||
['https://voidbots.net'], | ||
['https://discordlist.gg'], | ||
['https://api.discordlist.gg/developers'] | ||
]; | ||
|
||
/** @type {[Promise<import('undici').Response>, string, number][]} */ | ||
const responses = sites.map(([url, expectedStatusCode, method]) => { | ||
expectedStatusCode ??= 200; | ||
method ??= 'GET'; | ||
|
||
return [fetch(url, { method }), url, expectedStatusCode]; | ||
}); | ||
|
||
let hasFailure = false; | ||
|
||
for (let [response, url, expectedStatusCode] of responses) { | ||
response = await response; | ||
|
||
if (!response || expectedStatusCode !== response.status) { | ||
hasFailure = true; | ||
|
||
console.log(`${bold(url)} ${bold(red('failed.'))}`); | ||
continue; | ||
} | ||
|
||
console.log(`${bold(url)} ${bold(green('ok.'))}`); | ||
} | ||
|
||
if (hasFailure) process.exit(1); | ||
else process.exit(0); |
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
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.