From 47e3c500e192dcbc2a4b7f8447cb913262106f88 Mon Sep 17 00:00:00 2001 From: danbulant Date: Tue, 1 Sep 2020 21:10:40 +0200 Subject: [PATCH] first commit --- .gitignore | 3 +++ index.js | 28 ++++++++++++++++++++++++++++ package.json | 17 +++++++++++++++++ 3 files changed, 48 insertions(+) create mode 100644 .gitignore create mode 100644 index.js create mode 100644 package.json diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..dec192c --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +package-lock.json +node_modules +config.json \ No newline at end of file diff --git a/index.js b/index.js new file mode 100644 index 0000000..e3592e9 --- /dev/null +++ b/index.js @@ -0,0 +1,28 @@ +const express = require("express"); +const discord = require("discord.js"); +const Auth = require("discord-oauth2"); +const crypto = require('crypto'); +const config = require("./config.json"); + +const client = new discord.Client(); +const app = express(); +const auth = new Auth({ + clientId: config.cid, + clientSecret: config.secret +}); + +app.get("/login", (req, res) => { + var state = crypto.randomBytes(64).toString('hex'); + res.cookie("state", state); + res.redirect(auth.generateAuthUrl({ + scope: ["connections", "identify"], + state + })); +}); + +app.get("/callback", (req, res) => { + +}); + + +client.login(config.token); \ No newline at end of file diff --git a/package.json b/package.json new file mode 100644 index 0000000..3d7f886 --- /dev/null +++ b/package.json @@ -0,0 +1,17 @@ +{ + "name": "redditConnector", + "version": "1.0.0", + "description": "", + "main": "index.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "keywords": [], + "author": "", + "license": "ISC", + "dependencies": { + "discord-oauth2": "^2.3.0", + "discord.js": "^12.3.1", + "express": "^4.17.1" + } +}