first commit

This commit is contained in:
danbulant 2020-09-01 21:10:40 +02:00
commit 47e3c500e1
3 changed files with 48 additions and 0 deletions

3
.gitignore vendored Normal file
View file

@ -0,0 +1,3 @@
package-lock.json
node_modules
config.json

28
index.js Normal file
View file

@ -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);

17
package.json Normal file
View file

@ -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"
}
}