commit 47e3c500e192dcbc2a4b7f8447cb913262106f88 Author: danbulant Date: Tue Sep 1 21:10:40 2020 +0200 first commit 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" + } +}