mirror of
https://github.com/danbulant/redditConnector
synced 2026-05-19 03:58:37 +00:00
first commit
This commit is contained in:
commit
47e3c500e1
3 changed files with 48 additions and 0 deletions
3
.gitignore
vendored
Normal file
3
.gitignore
vendored
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
package-lock.json
|
||||
node_modules
|
||||
config.json
|
||||
28
index.js
Normal file
28
index.js
Normal 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
17
package.json
Normal 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"
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue