mirror of
https://github.com/Technicolor-creamsicle/Osselbot.git
synced 2025-02-21 05:07:16 -05:00
ah
this sucks
This commit is contained in:
parent
816118633d
commit
2aa12d057c
235
npm-shrinkwrap.json
generated
235
npm-shrinkwrap.json
generated
@ -27,11 +27,34 @@
|
||||
"event-target-shim": "^5.0.0"
|
||||
}
|
||||
},
|
||||
"agent-base": {
|
||||
"version": "4.3.0",
|
||||
"resolved": "https://registry.npmjs.org/agent-base/-/agent-base-4.3.0.tgz",
|
||||
"integrity": "sha512-salcGninV0nPrwpGNn4VTXBb1SOuXQBiqbrNXoeizJsHrsL6ERFM2Ne3JUSBWRE6aeNJI2ROP/WEEIDUiDe3cg==",
|
||||
"requires": {
|
||||
"es6-promisify": "^5.0.0"
|
||||
}
|
||||
},
|
||||
"asynckit": {
|
||||
"version": "0.4.0",
|
||||
"resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz",
|
||||
"integrity": "sha1-x57Zf380y48robyXkLzDZkdLS3k="
|
||||
},
|
||||
"base64-js": {
|
||||
"version": "1.3.1",
|
||||
"resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.3.1.tgz",
|
||||
"integrity": "sha512-mLQ4i2QO1ytvGWFWmcngKO//JXAQueZvwEKtjgQFM4jIK0kU+ytMfplL8j+n5mspOfjHwoAg+9yhb7BwAHm36g=="
|
||||
},
|
||||
"bignumber.js": {
|
||||
"version": "7.2.1",
|
||||
"resolved": "https://registry.npmjs.org/bignumber.js/-/bignumber.js-7.2.1.tgz",
|
||||
"integrity": "sha512-S4XzBk5sMB+Rcb/LNcpzXr57VRTxgAvaAEDAl1AwRx27j00hT84O6OkteE7u8UB3NuaaygCRrEpqox4uDOrbdQ=="
|
||||
},
|
||||
"buffer-equal-constant-time": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/buffer-equal-constant-time/-/buffer-equal-constant-time-1.0.1.tgz",
|
||||
"integrity": "sha1-+OcRMvf/5uAaXJaXpMbz5I1cyBk="
|
||||
},
|
||||
"combined-stream": {
|
||||
"version": "1.0.8",
|
||||
"resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz",
|
||||
@ -40,6 +63,14 @@
|
||||
"delayed-stream": "~1.0.0"
|
||||
}
|
||||
},
|
||||
"debug": {
|
||||
"version": "3.2.6",
|
||||
"resolved": "https://registry.npmjs.org/debug/-/debug-3.2.6.tgz",
|
||||
"integrity": "sha512-mel+jf7nrtEl5Pn1Qx46zARXKDpBbvzezse7p7LqINmdoIk8PYP5SySaxEmYv6TZ0JyEKA1hsCId6DIhgITtWQ==",
|
||||
"requires": {
|
||||
"ms": "^2.1.1"
|
||||
}
|
||||
},
|
||||
"delayed-stream": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz",
|
||||
@ -60,6 +91,14 @@
|
||||
"ws": "^7.2.1"
|
||||
}
|
||||
},
|
||||
"ecdsa-sig-formatter": {
|
||||
"version": "1.0.11",
|
||||
"resolved": "https://registry.npmjs.org/ecdsa-sig-formatter/-/ecdsa-sig-formatter-1.0.11.tgz",
|
||||
"integrity": "sha512-nagl3RYrbNv6kQkeJIpt6NJZy8twLB/2vtz6yN9Z4vRKHN4/QZJIEbqohALSgwKdnksuY3k5Addp5lg8sVoVcQ==",
|
||||
"requires": {
|
||||
"safe-buffer": "^5.0.1"
|
||||
}
|
||||
},
|
||||
"encoding": {
|
||||
"version": "0.1.12",
|
||||
"resolved": "https://registry.npmjs.org/encoding/-/encoding-0.1.12.tgz",
|
||||
@ -73,11 +112,117 @@
|
||||
"resolved": "https://registry.npmjs.org/es6-promise/-/es6-promise-4.2.8.tgz",
|
||||
"integrity": "sha512-HJDGx5daxeIvxdBxvG2cb9g4tEvwIk3i8+nhX0yGrYmZUzbkdg8QbDevheDB8gd0//uPj4c1EQua8Q+MViT0/w=="
|
||||
},
|
||||
"es6-promisify": {
|
||||
"version": "5.0.0",
|
||||
"resolved": "https://registry.npmjs.org/es6-promisify/-/es6-promisify-5.0.0.tgz",
|
||||
"integrity": "sha1-UQnWLz5W6pZ8S2NQWu8IKRyKUgM=",
|
||||
"requires": {
|
||||
"es6-promise": "^4.0.3"
|
||||
}
|
||||
},
|
||||
"event-target-shim": {
|
||||
"version": "5.0.1",
|
||||
"resolved": "https://registry.npmjs.org/event-target-shim/-/event-target-shim-5.0.1.tgz",
|
||||
"integrity": "sha512-i/2XbnSz/uxRCU6+NdVJgKWDTM427+MqYbkQzD321DuCQJUqOuJKIA0IM2+W2xtYHdKOmZ4dR6fExsd4SXL+WQ=="
|
||||
},
|
||||
"extend": {
|
||||
"version": "3.0.2",
|
||||
"resolved": "https://registry.npmjs.org/extend/-/extend-3.0.2.tgz",
|
||||
"integrity": "sha512-fjquC59cD7CyW6urNXK0FBufkZcoiGG80wTuPujX590cB5Ttln20E2UB4S/WARVqhXffZl2LNgS+gQdPIIim/g=="
|
||||
},
|
||||
"fast-text-encoding": {
|
||||
"version": "1.0.2",
|
||||
"resolved": "https://registry.npmjs.org/fast-text-encoding/-/fast-text-encoding-1.0.2.tgz",
|
||||
"integrity": "sha512-5rQdinSsycpzvAoHga2EDn+LRX1d5xLFsuNG0Kg61JrAT/tASXcLL0nf/33v+sAxlQcfYmWbTURa1mmAf55jGw=="
|
||||
},
|
||||
"gaxios": {
|
||||
"version": "1.8.4",
|
||||
"resolved": "https://registry.npmjs.org/gaxios/-/gaxios-1.8.4.tgz",
|
||||
"integrity": "sha512-BoENMnu1Gav18HcpV9IleMPZ9exM+AvUjrAOV4Mzs/vfz2Lu/ABv451iEXByKiMPn2M140uul1txXCg83sAENw==",
|
||||
"requires": {
|
||||
"abort-controller": "^3.0.0",
|
||||
"extend": "^3.0.2",
|
||||
"https-proxy-agent": "^2.2.1",
|
||||
"node-fetch": "^2.3.0"
|
||||
}
|
||||
},
|
||||
"gcp-metadata": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/gcp-metadata/-/gcp-metadata-1.0.0.tgz",
|
||||
"integrity": "sha512-Q6HrgfrCQeEircnNP3rCcEgiDv7eF9+1B+1MMgpE190+/+0mjQR8PxeOaRgxZWmdDAF9EIryHB9g1moPiw1SbQ==",
|
||||
"requires": {
|
||||
"gaxios": "^1.0.2",
|
||||
"json-bigint": "^0.3.0"
|
||||
}
|
||||
},
|
||||
"google-auth-library": {
|
||||
"version": "3.1.2",
|
||||
"resolved": "https://registry.npmjs.org/google-auth-library/-/google-auth-library-3.1.2.tgz",
|
||||
"integrity": "sha512-cDQMzTotwyWMrg5jRO7q0A4TL/3GWBgO7I7q5xGKNiiFf9SmGY/OJ1YsLMgI2MVHHsEGyrqYnbnmV1AE+Z6DnQ==",
|
||||
"requires": {
|
||||
"base64-js": "^1.3.0",
|
||||
"fast-text-encoding": "^1.0.0",
|
||||
"gaxios": "^1.2.1",
|
||||
"gcp-metadata": "^1.0.0",
|
||||
"gtoken": "^2.3.2",
|
||||
"https-proxy-agent": "^2.2.1",
|
||||
"jws": "^3.1.5",
|
||||
"lru-cache": "^5.0.0",
|
||||
"semver": "^5.5.0"
|
||||
}
|
||||
},
|
||||
"google-p12-pem": {
|
||||
"version": "1.0.4",
|
||||
"resolved": "https://registry.npmjs.org/google-p12-pem/-/google-p12-pem-1.0.4.tgz",
|
||||
"integrity": "sha512-SwLAUJqUfTB2iS+wFfSS/G9p7bt4eWcc2LyfvmUXe7cWp6p3mpxDo6LLI29MXdU6wvPcQ/up298X7GMC5ylAlA==",
|
||||
"requires": {
|
||||
"node-forge": "^0.8.0",
|
||||
"pify": "^4.0.0"
|
||||
}
|
||||
},
|
||||
"googleapis": {
|
||||
"version": "39.2.0",
|
||||
"resolved": "https://registry.npmjs.org/googleapis/-/googleapis-39.2.0.tgz",
|
||||
"integrity": "sha512-66X8TG1B33zAt177sG1CoKoYHPP/B66tEpnnSANGCqotMuY5gqSQO8G/0gqHZR2jRgc5CHSSNOJCnpI0SuDxMQ==",
|
||||
"requires": {
|
||||
"google-auth-library": "^3.0.0",
|
||||
"googleapis-common": "^0.7.0"
|
||||
}
|
||||
},
|
||||
"googleapis-common": {
|
||||
"version": "0.7.2",
|
||||
"resolved": "https://registry.npmjs.org/googleapis-common/-/googleapis-common-0.7.2.tgz",
|
||||
"integrity": "sha512-9DEJIiO4nS7nw0VE1YVkEfXEj8x8MxsuB+yZIpOBULFSN9OIKcUU8UuKgSZFU4lJmRioMfngktrbkMwWJcUhQg==",
|
||||
"requires": {
|
||||
"gaxios": "^1.2.2",
|
||||
"google-auth-library": "^3.0.0",
|
||||
"pify": "^4.0.0",
|
||||
"qs": "^6.5.2",
|
||||
"url-template": "^2.0.8",
|
||||
"uuid": "^3.2.1"
|
||||
}
|
||||
},
|
||||
"gtoken": {
|
||||
"version": "2.3.3",
|
||||
"resolved": "https://registry.npmjs.org/gtoken/-/gtoken-2.3.3.tgz",
|
||||
"integrity": "sha512-EaB49bu/TCoNeQjhCYKI/CurooBKkGxIqFHsWABW0b25fobBYVTMe84A8EBVVZhl8emiUdNypil9huMOTmyAnw==",
|
||||
"requires": {
|
||||
"gaxios": "^1.0.4",
|
||||
"google-p12-pem": "^1.0.0",
|
||||
"jws": "^3.1.5",
|
||||
"mime": "^2.2.0",
|
||||
"pify": "^4.0.0"
|
||||
}
|
||||
},
|
||||
"https-proxy-agent": {
|
||||
"version": "2.2.4",
|
||||
"resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-2.2.4.tgz",
|
||||
"integrity": "sha512-OmvfoQ53WLjtA9HeYP9RNrWMJzzAz1JGaSFr1nijg0PVR1JaD/xbJq1mdEIIlxGpXp9eSe/O2LgU9DJmTPd0Eg==",
|
||||
"requires": {
|
||||
"agent-base": "^4.3.0",
|
||||
"debug": "^3.1.0"
|
||||
}
|
||||
},
|
||||
"iconv-lite": {
|
||||
"version": "0.4.24",
|
||||
"resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz",
|
||||
@ -111,6 +256,46 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"json-bigint": {
|
||||
"version": "0.3.0",
|
||||
"resolved": "https://registry.npmjs.org/json-bigint/-/json-bigint-0.3.0.tgz",
|
||||
"integrity": "sha1-DM2RLEuCcNBfBW+9E4FLU9OCWx4=",
|
||||
"requires": {
|
||||
"bignumber.js": "^7.0.0"
|
||||
}
|
||||
},
|
||||
"jwa": {
|
||||
"version": "1.4.1",
|
||||
"resolved": "https://registry.npmjs.org/jwa/-/jwa-1.4.1.tgz",
|
||||
"integrity": "sha512-qiLX/xhEEFKUAJ6FiBMbes3w9ATzyk5W7Hvzpa/SLYdxNtng+gcurvrI7TbACjIXlsJyr05/S1oUhZrc63evQA==",
|
||||
"requires": {
|
||||
"buffer-equal-constant-time": "1.0.1",
|
||||
"ecdsa-sig-formatter": "1.0.11",
|
||||
"safe-buffer": "^5.0.1"
|
||||
}
|
||||
},
|
||||
"jws": {
|
||||
"version": "3.2.2",
|
||||
"resolved": "https://registry.npmjs.org/jws/-/jws-3.2.2.tgz",
|
||||
"integrity": "sha512-YHlZCB6lMTllWDtSPHz/ZXTsi8S00usEV6v1tjq8tOUZzw7DpSDWVXjXDre6ed1w/pd495ODpHZYSdkRTsa0HA==",
|
||||
"requires": {
|
||||
"jwa": "^1.4.1",
|
||||
"safe-buffer": "^5.0.1"
|
||||
}
|
||||
},
|
||||
"lru-cache": {
|
||||
"version": "5.1.1",
|
||||
"resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-5.1.1.tgz",
|
||||
"integrity": "sha512-KpNARQA3Iwv+jTA0utUVVbrh+Jlrr1Fv0e56GGzAFOXN7dk/FviaDW8LHmK52DlcH4WP2n6gI8vN1aesBFgo9w==",
|
||||
"requires": {
|
||||
"yallist": "^3.0.2"
|
||||
}
|
||||
},
|
||||
"mime": {
|
||||
"version": "2.4.5",
|
||||
"resolved": "https://registry.npmjs.org/mime/-/mime-2.4.5.tgz",
|
||||
"integrity": "sha512-3hQhEUF027BuxZjQA3s7rIv/7VCQPa27hN9u9g87sEkWaKwQPuXOkVKtOeiyUrnWqTDiOs8Ed2rwg733mB0R5w=="
|
||||
},
|
||||
"mime-db": {
|
||||
"version": "1.44.0",
|
||||
"resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.44.0.tgz",
|
||||
@ -124,6 +309,11 @@
|
||||
"mime-db": "1.44.0"
|
||||
}
|
||||
},
|
||||
"ms": {
|
||||
"version": "2.1.2",
|
||||
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz",
|
||||
"integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w=="
|
||||
},
|
||||
"n": {
|
||||
"version": "6.5.1",
|
||||
"resolved": "https://registry.npmjs.org/n/-/n-6.5.1.tgz",
|
||||
@ -134,11 +324,21 @@
|
||||
"resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.0.tgz",
|
||||
"integrity": "sha512-8dG4H5ujfvFiqDmVu9fQ5bOHUC15JMjMY/Zumv26oOvvVJjM67KF8koCWIabKQ1GJIa9r2mMZscBq/TbdOcmNA=="
|
||||
},
|
||||
"node-forge": {
|
||||
"version": "0.8.5",
|
||||
"resolved": "https://registry.npmjs.org/node-forge/-/node-forge-0.8.5.tgz",
|
||||
"integrity": "sha512-vFMQIWt+J/7FLNyKouZ9TazT74PRV3wgv9UT4cRjC8BffxFbKXkgIWR42URCPSnHm/QDz6BOlb2Q0U4+VQT67Q=="
|
||||
},
|
||||
"parse-ms": {
|
||||
"version": "2.1.0",
|
||||
"resolved": "https://registry.npmjs.org/parse-ms/-/parse-ms-2.1.0.tgz",
|
||||
"integrity": "sha512-kHt7kzLoS9VBZfUsiKjv43mr91ea+U05EyKkEtqp7vNbHxmaVuEqN7XxeEVnGrMtYOAxGrDElSi96K7EgO1zCA=="
|
||||
},
|
||||
"pify": {
|
||||
"version": "4.0.1",
|
||||
"resolved": "https://registry.npmjs.org/pify/-/pify-4.0.1.tgz",
|
||||
"integrity": "sha512-uB80kBFb/tfd68bVleG9T5GGsGPjJrLAUpR5PZIrhBnIaRTQRjqdJSsIKkOP6OAIFbj7GOrcudc5pNjZ+geV2g=="
|
||||
},
|
||||
"pretty-ms": {
|
||||
"version": "6.0.1",
|
||||
"resolved": "https://registry.npmjs.org/pretty-ms/-/pretty-ms-6.0.1.tgz",
|
||||
@ -152,11 +352,31 @@
|
||||
"resolved": "https://registry.npmjs.org/prism-media/-/prism-media-1.2.2.tgz",
|
||||
"integrity": "sha512-I+nkWY212lJ500jLe4tN9tWO7nRiBAVdMv76P9kffZjYhw20raMlW1HSSvS+MLXC9MmbNZCazMrAr+5jEEgTuw=="
|
||||
},
|
||||
"qs": {
|
||||
"version": "6.9.4",
|
||||
"resolved": "https://registry.npmjs.org/qs/-/qs-6.9.4.tgz",
|
||||
"integrity": "sha512-A1kFqHekCTM7cz0udomYUoYNWjBebHm/5wzU/XqrBRBNWectVH0QIiN+NEcZ0Dte5hvzHwbr8+XQmguPhJ6WdQ=="
|
||||
},
|
||||
"readline": {
|
||||
"version": "1.3.0",
|
||||
"resolved": "https://registry.npmjs.org/readline/-/readline-1.3.0.tgz",
|
||||
"integrity": "sha1-xYDXfvLPyHUrEySYBg3JeTp6wBw="
|
||||
},
|
||||
"safe-buffer": {
|
||||
"version": "5.2.1",
|
||||
"resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz",
|
||||
"integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ=="
|
||||
},
|
||||
"safer-buffer": {
|
||||
"version": "2.1.2",
|
||||
"resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz",
|
||||
"integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg=="
|
||||
},
|
||||
"semver": {
|
||||
"version": "5.7.1",
|
||||
"resolved": "https://registry.npmjs.org/semver/-/semver-5.7.1.tgz",
|
||||
"integrity": "sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ=="
|
||||
},
|
||||
"setimmediate": {
|
||||
"version": "1.0.5",
|
||||
"resolved": "https://registry.npmjs.org/setimmediate/-/setimmediate-1.0.5.tgz",
|
||||
@ -167,6 +387,16 @@
|
||||
"resolved": "https://registry.npmjs.org/tweetnacl/-/tweetnacl-1.0.3.tgz",
|
||||
"integrity": "sha512-6rt+RN7aOi1nGMyC4Xa5DdYiukl2UWCbcJft7YhxReBGQD7OAM8Pbxw6YMo4r2diNEA8FEmu32YOn9rhaiE5yw=="
|
||||
},
|
||||
"url-template": {
|
||||
"version": "2.0.8",
|
||||
"resolved": "https://registry.npmjs.org/url-template/-/url-template-2.0.8.tgz",
|
||||
"integrity": "sha1-/FZaPMy/93MMd19WQflVV5FDnyE="
|
||||
},
|
||||
"uuid": {
|
||||
"version": "3.4.0",
|
||||
"resolved": "https://registry.npmjs.org/uuid/-/uuid-3.4.0.tgz",
|
||||
"integrity": "sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A=="
|
||||
},
|
||||
"whatwg-fetch": {
|
||||
"version": "3.0.0",
|
||||
"resolved": "https://registry.npmjs.org/whatwg-fetch/-/whatwg-fetch-3.0.0.tgz",
|
||||
@ -176,6 +406,11 @@
|
||||
"version": "7.3.0",
|
||||
"resolved": "https://registry.npmjs.org/ws/-/ws-7.3.0.tgz",
|
||||
"integrity": "sha512-iFtXzngZVXPGgpTlP1rBqsUK82p9tKqsWRPg5L56egiljujJT3vGAYnHANvFxBieXrTFavhzhxW52jnaWV+w2w=="
|
||||
},
|
||||
"yallist": {
|
||||
"version": "3.1.1",
|
||||
"resolved": "https://registry.npmjs.org/yallist/-/yallist-3.1.1.tgz",
|
||||
"integrity": "sha512-a4UGQaWPH59mOXUYnAG2ewncQS4i4F43Tv3JoAM+s2VDAmS9NsK8GpDMLrCHPksFT7h3K6TOoUNn2pb7RoXx4g=="
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -6,9 +6,11 @@
|
||||
"dependencies": {
|
||||
"discord.js": "^12.1.1",
|
||||
"es6-promise": "^4.2.8",
|
||||
"googleapis": "^39.2.0",
|
||||
"isomorphic-fetch": "^2.2.1",
|
||||
"n": "^6.4.0",
|
||||
"pretty-ms": "^6.0.1"
|
||||
"pretty-ms": "^6.0.1",
|
||||
"readline": "^1.3.0"
|
||||
},
|
||||
"publishConfig": {
|
||||
"registry": "https://npm.pkg.github.com/"
|
||||
|
1
src/credentials.json
Normal file
1
src/credentials.json
Normal file
@ -0,0 +1 @@
|
||||
{"web":{"client_id":"289545260373-sqqg3f3en0b4s0rfk8fjgbg8val24e2g.apps.googleusercontent.com","project_id":"quickstart-1590299030402","auth_uri":"https://accounts.google.com/o/oauth2/auth","token_uri":"https://oauth2.googleapis.com/token","auth_provider_x509_cert_url":"https://www.googleapis.com/oauth2/v1/certs","client_secret":"W_nnjyJZ8NeHFBLyLGyxBY5c","redirect_uris":["http://127.0.0.1"]}}
|
90
src/googletest.js
Normal file
90
src/googletest.js
Normal file
@ -0,0 +1,90 @@
|
||||
const fs = require('fs');
|
||||
const readline = require('readline');
|
||||
const {google} = require('googleapis');
|
||||
|
||||
// If modifying these scopes, delete token.json.
|
||||
const SCOPES = ['https://www.googleapis.com/auth/drive.metadata.readonly'];
|
||||
// The file token.json stores the user's access and refresh tokens, and is
|
||||
// created automatically when the authorization flow completes for the first
|
||||
// time.
|
||||
const TOKEN_PATH = 'token.json';
|
||||
|
||||
// Load client secrets from a local file.
|
||||
fs.readFile('credentials.json', (err, content) => {
|
||||
if (err) return console.log('Error loading client secret file:', err);
|
||||
// Authorize a client with credentials, then call the Google Drive API.
|
||||
authorize(JSON.parse(content), listFiles);
|
||||
});
|
||||
|
||||
/**
|
||||
* Create an OAuth2 client with the given credentials, and then execute the
|
||||
* given callback function.
|
||||
* @param {Object} credentials The authorization client credentials.
|
||||
* @param {function} callback The callback to call with the authorized client.
|
||||
*/
|
||||
function authorize(credentials, callback) {
|
||||
const {client_secret, client_id, redirect_uris} = credentials.installed;
|
||||
const oAuth2Client = new google.auth.OAuth2(
|
||||
client_id, client_secret, redirect_uris[0]);
|
||||
|
||||
// Check if we have previously stored a token.
|
||||
fs.readFile(TOKEN_PATH, (err, token) => {
|
||||
if (err) return getAccessToken(oAuth2Client, callback);
|
||||
oAuth2Client.setCredentials(JSON.parse(token));
|
||||
callback(oAuth2Client);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Get and store new token after prompting for user authorization, and then
|
||||
* execute the given callback with the authorized OAuth2 client.
|
||||
* @param {google.auth.OAuth2} oAuth2Client The OAuth2 client to get token for.
|
||||
* @param {getEventsCallback} callback The callback for the authorized client.
|
||||
*/
|
||||
function getAccessToken(oAuth2Client, callback) {
|
||||
const authUrl = oAuth2Client.generateAuthUrl({
|
||||
access_type: 'offline',
|
||||
scope: SCOPES,
|
||||
});
|
||||
console.log('Authorize this app by visiting this url:', authUrl);
|
||||
const rl = readline.createInterface({
|
||||
input: process.stdin,
|
||||
output: process.stdout,
|
||||
});
|
||||
rl.question('Enter the code from that page here: ', (code) => {
|
||||
rl.close();
|
||||
oAuth2Client.getToken(code, (err, token) => {
|
||||
if (err) return console.error('Error retrieving access token', err);
|
||||
oAuth2Client.setCredentials(token);
|
||||
// Store the token to disk for later program executions
|
||||
fs.writeFile(TOKEN_PATH, JSON.stringify(token), (err) => {
|
||||
if (err) return console.error(err);
|
||||
console.log('Token stored to', TOKEN_PATH);
|
||||
});
|
||||
callback(oAuth2Client);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Lists the names and IDs of up to 10 files.
|
||||
* @param {google.auth.OAuth2} auth An authorized OAuth2 client.
|
||||
*/
|
||||
function listFiles(auth) {
|
||||
const drive = google.drive({version: 'v3', auth});
|
||||
drive.files.list({
|
||||
pageSize: 10,
|
||||
fields: 'nextPageToken, files(id, name)',
|
||||
}, (err, res) => {
|
||||
if (err) return console.log('The API returned an error: ' + err);
|
||||
const files = res.data.files;
|
||||
if (files.length) {
|
||||
console.log('Files:');
|
||||
files.map((file) => {
|
||||
console.log(`${file.name} (${file.id})`);
|
||||
});
|
||||
} else {
|
||||
console.log('No files found.');
|
||||
}
|
||||
});
|
||||
}
|
13
src/index.js
13
src/index.js
@ -2,15 +2,15 @@
|
||||
// Load up the libraries
|
||||
const Discord = require("discord.js");
|
||||
const prettyMilliseconds = require('pretty-ms');
|
||||
const config = require("./config.json");
|
||||
|
||||
const readline = require('readline');
|
||||
const {google} = require('googleapis');
|
||||
const fetch = require('isomorphic-fetch');
|
||||
|
||||
const TOKEN_PATH = 'token.json';
|
||||
const config = require("./config.json");
|
||||
// This is making clients
|
||||
const client = new Discord.Client();
|
||||
const YOUR_ROOT_FOLDER = '1YmJULtf9q1FwY_sZGc8s5WlY2VnfHx1Q',
|
||||
PATH_TO_CREDENTIALS = path.resolve(`./google.json`);
|
||||
const creds_service_user = require(PATH_TO_CREDENTIALS);
|
||||
|
||||
|
||||
|
||||
function activity() {
|
||||
@ -155,7 +155,8 @@ client.on("message", async message => {
|
||||
}
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
if (command === "version") {
|
||||
return message.channel.send("``` ________________________________________\n \
|
||||
return message.channel.send("```\
|
||||
________________________________________\n \
|
||||
< @technicolor-creamsicle/osselbot@2.1.0 >\n \
|
||||
----------------------------------------\n \
|
||||
\\ ^__^\n \
|
||||
|
Loading…
x
Reference in New Issue
Block a user