fetchUsers script with discord.js

This commit is contained in:
Xetera
2019-07-27 16:01:24 -07:00
parent ee4e2c2430
commit 31a45965bd
3 changed files with 74 additions and 7 deletions
+31 -3
View File
@@ -5323,6 +5323,31 @@
}
}
},
"discord.js": {
"version": "git+https://github.com/discordjs/discord.js.git#d8516efa36f62ef8a6e33b0b35ba5f482e22d103",
"from": "git+https://github.com/discordjs/discord.js.git",
"requires": {
"form-data": "^2.3.3",
"node-fetch": "^2.3.0",
"pako": "^1.0.8",
"prism-media": "^1.0.0",
"setimmediate": "^1.0.5",
"tweetnacl": "^1.0.1",
"ws": "^6.1.3"
},
"dependencies": {
"node-fetch": {
"version": "2.6.0",
"resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.0.tgz",
"integrity": "sha512-8dG4H5ujfvFiqDmVu9fQ5bOHUC15JMjMY/Zumv26oOvvVJjM67KF8koCWIabKQ1GJIa9r2mMZscBq/TbdOcmNA=="
},
"tweetnacl": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/tweetnacl/-/tweetnacl-1.0.1.tgz",
"integrity": "sha512-kcoMoKTPYnoeS50tzoqjPY3Uv9axeuuFAZY9M/9zFnhoVvRfxz9K29IMPD7jGmt2c8SW7i3gT9WqDl2+nV7p4A=="
}
}
},
"dns-equal": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/dns-equal/-/dns-equal-1.0.0.tgz",
@@ -10875,8 +10900,7 @@
"ansi-regex": {
"version": "4.1.0",
"resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-4.1.0.tgz",
"integrity": "sha512-1apePfXM1UOSqw0o9IiFAovVz9M5S1Dg+4TrDwfMewQ6p/rmMueb7tWZjQ1rx4Loy1ArBggoqGpfqqdI4rondg==",
"optional": true
"integrity": "sha512-1apePfXM1UOSqw0o9IiFAovVz9M5S1Dg+4TrDwfMewQ6p/rmMueb7tWZjQ1rx4Loy1ArBggoqGpfqqdI4rondg=="
},
"is-fullwidth-code-point": {
"version": "2.0.0",
@@ -10897,7 +10921,6 @@
"version": "5.2.0",
"resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-5.2.0.tgz",
"integrity": "sha512-DuRs1gKbBqsMKIZlrffwlug8MHkcnpjs5VPmL1PAh+mA30U0DTotfDZ0d2UUsXpPmPmMMJ6W773MaA3J+lbiWA==",
"optional": true,
"requires": {
"ansi-regex": "^4.1.0"
}
@@ -13582,6 +13605,11 @@
"utila": "~0.4"
}
},
"prism-media": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/prism-media/-/prism-media-1.0.2.tgz",
"integrity": "sha512-KCu3SlT1EtS0lvF74NGLSTzr5jrkRajE9n+S2jnUvvdiN5SpjsGj0/HgR1QK9+985Yv8cxjwZnpFRaj+SimDGA=="
},
"prismjs": {
"version": "1.17.1",
"resolved": "https://registry.npmjs.org/prismjs/-/prismjs-1.17.1.tgz",
+7 -4
View File
@@ -4,6 +4,9 @@
"description": "A simple starter to get up and developing quickly with Gatsby",
"version": "0.1.0",
"author": "TPH",
"peerDependencies": {
"discord.js": "git+https://github.com/discordjs/discord.js.git"
},
"dependencies": {
"@types/ramda": "^0.26.18",
"axios": "^0.19.0",
@@ -37,15 +40,15 @@
},
"devDependencies": {
"@graphql-codegen/cli": "^1.4.0",
"@graphql-codegen/typescript": "1.4.0",
"@graphql-codegen/typescript-operations": "1.4.0",
"@graphql-codegen/typescript-react-apollo": "1.4.0",
"@types/react": "^16.8.23",
"@types/react-dom": "^16.8.5",
"@types/react-helmet": "^5.0.8",
"@types/react-treeview": "^0.4.2",
"@types/styled-components": "^4.1.18",
"prettier": "^1.18.2",
"@graphql-codegen/typescript": "1.4.0",
"@graphql-codegen/typescript-operations": "1.4.0",
"@graphql-codegen/typescript-react-apollo": "1.4.0"
"prettier": "^1.18.2"
},
"keywords": [
"gatsby"
+36
View File
@@ -0,0 +1,36 @@
// This script will be ran periodically through CI
// don't touch it
import Discord from "discord.js"
import fs from "fs"
import { Readable, Writable } from "stream"
const client = new Discord.Client()
const { BOT_TOKEN } = process.env
const TPH = "244230771232079873"
if (!BOT_TOKEN) {
throw Error("Missing BOT_TOKEN environment variable")
}
const writeS = <T>(content: T[], dest: Writable) => {
const source = new Readable()
source.push(JSON.stringify(content))
source.push(null)
source.pipe(dest)
}
client.once("ready", async () => {
const tph = client.guilds.get(TPH)
if (!tph) {
throw Error("Bot is not in TPH, cannot fetch users")
}
const members = await tph.members.fetch()
const memberInfo = members.map(member => ({
identifier: `${member.user.username}#${member.user.discriminator}`,
avatar: member.user.displayAvatarURL({ size: 32 }),
}))
const wrs = fs.createWriteStream("./users.json")
writeS(memberInfo, wrs)
})
client.login(process.env.BOT_TOKEN)