From 156daa1480a4beff84648f9d1515ad1ea2282d73 Mon Sep 17 00:00:00 2001 From: NotMyFault Date: Sun, 13 Jan 2019 13:51:15 +0100 Subject: [PATCH 1/6] Add IntellectualSites --- communities.json | 7 +++++++ logos/IntellectualSites.svg | 1 + 2 files changed, 8 insertions(+) create mode 100644 logos/IntellectualSites.svg diff --git a/communities.json b/communities.json index 27868eb..24da7fd 100644 --- a/communities.json +++ b/communities.json @@ -583,6 +583,13 @@ "quote": "Discord has allowed us to be more interactive with our community in resolving issues, reviewing contributions, and answering questions.", "inviteCode": "jETyjUw", "githubUrl": "https://github.com/PaperMC" + }, + { + "logo": "IntellectualSites.svg", + "title": "IntellectualSites", + "quote": "Discord provides us a platform to help people resolving issues, discussing possible features and communicating with other contributors.", + "inviteCode": "ngZCzbU", + "githubUrl": "https://github.com/IntellectualSites" } ] } diff --git a/logos/IntellectualSites.svg b/logos/IntellectualSites.svg new file mode 100644 index 0000000..1a7072f --- /dev/null +++ b/logos/IntellectualSites.svg @@ -0,0 +1 @@ + From 65f08d37fa46a14d570e73861a9680cf262c4cc1 Mon Sep 17 00:00:00 2001 From: NotMyFault Date: Tue, 29 Jan 2019 07:09:02 +0100 Subject: [PATCH 2/6] Update communities.json --- communities.json | 7 ------- 1 file changed, 7 deletions(-) diff --git a/communities.json b/communities.json index 9fe3479..45e0e82 100644 --- a/communities.json +++ b/communities.json @@ -591,13 +591,6 @@ "inviteCode": "ngZCzbU", "githubUrl": "https://github.com/IntellectualSites" }, - { - "logo": "enginehub.svg", - "title": "EngineHub", - "quote": "Discord has allowed us to massively streamline support requests, and created a dynamic community around our projects.", - "inviteCode": "enginehub", - "githubUrl": "https://github.com/EngineHub" - }, { "logo": "enginehub.svg", "title": "EngineHub", From 9aa68ad028332a47e3753155f87e0ea1c3a07313 Mon Sep 17 00:00:00 2001 From: Ivan K Date: Tue, 29 Jan 2019 12:30:04 -0800 Subject: [PATCH 3/6] travis CI tests for communities.json --- .gitignore | 4 ++++ .travis.yml | 3 +++ package.json | 9 ++++++++- 3 files changed, 15 insertions(+), 1 deletion(-) create mode 100644 .travis.yml diff --git a/.gitignore b/.gitignore index e43b0f9..d8f07bf 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,5 @@ .DS_Store +node_modules/ +yarn.lock +package-lock.json +*.log diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..9ef0fde --- /dev/null +++ b/.travis.yml @@ -0,0 +1,3 @@ +language: node_js +node_js: + - "lts/*" diff --git a/package.json b/package.json index 0d1f2e6..23d8367 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,12 @@ { "name": "discord-open-source", "version": "1.0.0", - "main": "communities.json" + "main": "communities.json", + "scripts": { + "test": "prettier -c communities.json || (npm run fmt && git diff && exit 1)", + "fmt": "prettier --write communities.json" + }, + "devDependencies": { + "prettier": "^1.16.1" + } } From d17d2d64fed3826adfa2501e12667dcd94b91a4b Mon Sep 17 00:00:00 2001 From: Ivan K Date: Tue, 29 Jan 2019 16:29:54 -0800 Subject: [PATCH 4/6] also validate codes --- package.json | 6 +++++- validate.js | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 56 insertions(+), 1 deletion(-) create mode 100644 validate.js diff --git a/package.json b/package.json index 23d8367..a2c95ed 100644 --- a/package.json +++ b/package.json @@ -3,10 +3,14 @@ "version": "1.0.0", "main": "communities.json", "scripts": { - "test": "prettier -c communities.json || (npm run fmt && git diff && exit 1)", + "test": "npm run fmt-check && npm run validate-codes", + "validate-codes": "node ./validate.js", + "fmt-check": "prettier -c communities.json || (npm run fmt && git diff && exit 1)", "fmt": "prettier --write communities.json" }, "devDependencies": { + "chalk": "^2.4.2", + "node-fetch": "^2.3.0", "prettier": "^1.16.1" } } diff --git a/validate.js b/validate.js new file mode 100644 index 0000000..71ff690 --- /dev/null +++ b/validate.js @@ -0,0 +1,51 @@ +const util = require('util'); +const chalk = require('chalk'); +const fetch = require('node-fetch'); +const discordCommunities = require('./communities.json'); + +const delay = ms => new Promise(resolve => setTimeout(resolve, ms)); + +async function validateCommunity(community) { + while (true) { + const req = await fetch(`https://discordapp.com/api/invite/${community.inviteCode}`); + const response = await req.json(); + + if (response.guild) break; + + if (response.retry_after) { + console.log(chalk.yellow(`Rate limited for ${response.retry_after}ms, waiting`)); + await delay(response.retry_after); + continue; + } + + throw new Error( + `${chalk.yellow.bold(community.title)} (${community.inviteCode}): ${util.inspect(response)}` + ); + } +} + +async function validate() { + console.log(chalk.underline.bold.white('Validating open source community invite codes')); + + const failedCommunities = []; + + for (const community of discordCommunities.data) { + console.log(`${community.title} (${community.inviteCode})`); + try { + await validateCommunity(community); + } catch (err) { + failedCommunities.push(err.message); + } + } + + if (failedCommunities.length) { + console.error(chalk.red.bold('Could not validate some community codes!\n')); + console.error(failedCommunities.join('\n') + '\n'); + throw new Error('Failed to validate invite codes'); + } +} + +validate().catch(err => { + console.error(err.message); + process.exit(1); +}); From 8e592e0edc88754f87adbe62004cc5259ad7ed84 Mon Sep 17 00:00:00 2001 From: Ivan K Date: Tue, 29 Jan 2019 16:36:53 -0800 Subject: [PATCH 5/6] adafruit: fix invite code --- communities.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/communities.json b/communities.json index 45e0e82..6184e9d 100644 --- a/communities.json +++ b/communities.json @@ -602,8 +602,8 @@ "logo": "adafruit.svg", "title": "Adafruit", "quote": "Adafruit, a USA manufacturer of educational open-source hardware and software, uses Discord for creating Code + Community.", - "quoteSourceUrl": "https://www.adafruit.com/about/.", - "inviteCode": "https://discord.gg/adafruit", + "quoteSourceUrl": "https://www.adafruit.com/about/", + "inviteCode": "adafruit", "githubUrl": "https://github.com/adafruit" } ] From dcb2490fa0d37c5ba5e6b5bdddb45090e2efe43f Mon Sep 17 00:00:00 2001 From: ivan k Date: Wed, 30 Jan 2019 12:18:18 -0800 Subject: [PATCH 6/6] Update communities.json --- communities.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/communities.json b/communities.json index 6184e9d..28bdfbe 100644 --- a/communities.json +++ b/communities.json @@ -589,7 +589,7 @@ "title": "IntellectualSites", "quote": "Discord provides us a platform to help people resolving issues, discussing possible features and communicating with other contributors.", "inviteCode": "ngZCzbU", - "githubUrl": "https://github.com/IntellectualSites" + "githubUrl": "https://github.com/IntellectualSites" }, { "logo": "enginehub.svg",