Skip to content
This repository was archived by the owner on Mar 23, 2025. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 9 additions & 7 deletions BlockReactions/README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
# Block Reactions
This is a simple extension that allows you to block users from reacting to messages.

(compatible with 1.3)

# Credits
- [@Hyperz](https://store.hyperz.net/discord) - *Phyiscal Programming.*
# Block Reactions

This is a simple extension that allows you to block users from reacting to messages.

(compatible with 1.3)

# Credits

- [@Hyperz](https://store.hyperz.net/discord) - _Phyiscal Programming._
27 changes: 12 additions & 15 deletions BlockReactions/blockReactions.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
let noReactions = [
"328731272497201154"
];

module.exports = async function(client, con, app) {
client.on('messageReactionAdd', async (reaction, user) => {
if(user.bot) return;
if (reaction.partial) await reaction.fetch();
if (reaction.message.partial) await reaction.message.fetch();
if(noReactions.includes(user.id)) {
await reaction.users.remove(user.id);
return;
};
});
};
const noReactions = ["328731272497201154"];

module.exports = async function (client, con, app) {
client.on("messageReactionAdd", async (reaction, user) => {
if (user.bot) return;
if (reaction.partial) await reaction.fetch();
if (reaction.message.partial) await reaction.message.fetch();
if (noReactions.includes(user.id)) {
await reaction.users.remove(user.id);
}
});
};
12 changes: 6 additions & 6 deletions BlockReactions/extension.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "Block Reactions",
"version": "1.0.0",
"author": "Hyperz#0001",
"file": "blockReactions.js"
}
{
"name": "Block Reactions",
"version": "1.0.0",
"author": "Hyperz#0001",
"file": "blockReactions.js"
}
36 changes: 20 additions & 16 deletions Darkbot API/README.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
# Darkbot API
This is a base template including Discord login for Dark Bot (1.3+). Those of you who are developers looking for more out of Dark Bot can feel free to use this as needed.

# Installation
- Drag the `Darkbot API` folder into your `extensions` folder for Darkbot.
- Run `npm i passport passport-discord-faxes multer body-parser express-session`.
- Fill out the `apiConfig.js` file for the extension.
- Add the oAuth2 redirect url to your Discord app: `https://example.com/auth/discord/callback`
- Restart Darkbot.

# Default Routes
- `/` = Go to home page.
- `/login` = Go to login page.

# Credits
- [@Hyperz](https://store.hyperz.net/discord) - *Original release.*
# Darkbot API

This is a base template including Discord login for Dark Bot (1.3+). Those of you who are developers looking for more out of Dark Bot can feel free to use this as needed.

# Installation

- Drag the `Darkbot API` folder into your `extensions` folder for Darkbot.
- Run `npm i passport passport-discord-faxes multer body-parser express-session`.
- Fill out the `apiConfig.js` file for the extension.
- Add the oAuth2 redirect url to your Discord app: `https://example.com/auth/discord/callback`
- Restart Darkbot.

# Default Routes

- `/` = Go to home page.
- `/login` = Go to login page.

# Credits

- [@Hyperz](https://store.hyperz.net/discord) - _Original release._
183 changes: 102 additions & 81 deletions Darkbot API/api.js
Original file line number Diff line number Diff line change
@@ -1,81 +1,102 @@
// You will likely need to install all of these:
// npm i passport passport-discord-faxes multer body-parser express-session
const passport = require('passport');
const DiscordStrategy = require('passport-discord-faxes').Strategy;
const multer = require('multer');
const bodyParser = require('body-parser');
const session = require('express-session');

// These are already installed:
const express = require("express");
const config = require('./apiConfig.js');
const backend = require('./backend.js');

// Actual coding part
module.exports = async function(client, con, app) {
// Express App Setup
let multerStorage = multer.memoryStorage()
app.use(multer({ storage: multerStorage }).any());
app.use(bodyParser.urlencoded({ extended: true }))
app.use(express.json());
app.use(session({
secret: 'keyboard cat',
resave: false,
saveUninitialized: false,
cookie: {maxAge: 31556952000},
}));
app.use(passport.initialize());
app.use(passport.session());
app.use(express.static('public'));
app.use('/assets', express.static(__dirname + 'public/assets'))
app.set('views', './views');
app.set('view engine', 'ejs');

// Passport Setup
passport.serializeUser(function(user, done) { done(null, user) });
passport.deserializeUser(function(obj, done) { done(null, obj) });
passport.use(new DiscordStrategy({
clientID: config.discord.oauthId,
clientSecret: config.discord.oauthToken,
callbackURL: `${(config.domain.endsWith('/') ? config.domain.slice(0, -1) : config.domain)}/auth/discord/callback`,
scope: ['identify', 'guilds', 'email'],
prompt: 'consent'
}, function(accessToken, refreshToken, profile, done) {
process.nextTick(function() {
return done(null, profile);
});
}));

// Routes
app.get('', async function(req, res) {
res.render('index.ejs');
});

app.get('/login', backend.checkAuth, function(req, res) {
res.redirect('/');
});

// Passport Routes
app.get('/auth/discord', passport.authenticate('discord'));
app.get('/auth/discord/callback', passport.authenticate('discord', {failureRedirect: '/'}), async function(req, res) {
req.session?.loginRef ? res.redirect(req.session.loginRef) : res.redirect('/');
delete req.session?.loginRef
});

// Searched the redirects for the page (must be 1 before 404 page)
config.redirects.forEach(element => {
app.get(`/${element.name}`, (req, res) => {
res.redirect(element.link);
});
});

// MAKE SURE THIS IS LAST FOR 404 PAGE REDIRECT
app.get('*', function(req, res){
res.render('404.ejs');
});

// Log initialization
setTimeout(async function() {
client.darkbot.emit('apiReady', (app, config)); // Custom event emitter
}, 1500);
};
// You will likely need to install all of these:
// npm i passport passport-discord-faxes multer body-parser express-session
const passport = require("passport");
const DiscordStrategy = require("passport-discord-faxes").Strategy;
const multer = require("multer");
const bodyParser = require("body-parser");
const session = require("express-session");

// These are already installed:
const express = require("express");
const config = require("./apiConfig.js");
const backend = require("./backend.js");

// Actual coding part
module.exports = async function (client, con, app) {
// Express App Setup
const multerStorage = multer.memoryStorage();
app.use(multer({ storage: multerStorage }).any());
app.use(bodyParser.urlencoded({ extended: true }));
app.use(express.json());
app.use(
session({
secret: "keyboard cat",
resave: false,
saveUninitialized: false,
cookie: { maxAge: 31556952000 },
})
);
app.use(passport.initialize());
app.use(passport.session());
app.use(express.static("public"));
app.use("/assets", express.static(__dirname + "public/assets"));
app.set("views", "./views");
app.set("view engine", "ejs");

// Passport Setup
passport.serializeUser(function (user, done) {
done(null, user);
});
passport.deserializeUser(function (obj, done) {
done(null, obj);
});
passport.use(
new DiscordStrategy(
{
clientID: config.discord.oauthId,
clientSecret: config.discord.oauthToken,
callbackURL: `${
config.domain.endsWith("/")
? config.domain.slice(0, -1)
: config.domain
}/auth/discord/callback`,
scope: ["identify", "guilds", "email"],
prompt: "consent",
},
function (accessToken, refreshToken, profile, done) {
process.nextTick(function () {
return done(null, profile);
});
}
)
);

// Routes
app.get("", async function (req, res) {
res.render("index.ejs");
});

app.get("/login", backend.checkAuth, function (req, res) {
res.redirect("/");
});

// Passport Routes
app.get("/auth/discord", passport.authenticate("discord"));
app.get(
"/auth/discord/callback",
passport.authenticate("discord", { failureRedirect: "/" }),
async function (req, res) {
req.session?.loginRef
? res.redirect(req.session.loginRef)
: res.redirect("/");
delete req.session?.loginRef;
}
);

// Searched the redirects for the page (must be 1 before 404 page)
config.redirects.forEach((element) => {
app.get(`/${element.name}`, (req, res) => {
res.redirect(element.link);
});
});

// MAKE SURE THIS IS LAST FOR 404 PAGE REDIRECT
app.get("*", function (req, res) {
res.render("404.ejs");
});

// Log initialization
setTimeout(async function () {
client.darkbot.emit("apiReady", (app, config)); // Custom event emitter
}, 1500);
};
28 changes: 12 additions & 16 deletions Darkbot API/apiConfig.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
const _config = {

domain: "", // A domain to use for the API (no trailing slash).

discord: {
oauthId: "", // Discord Client ID
oauthToken: "" // Discord Client Secret
},

redirects: [
{ name: `discord`, link: `https://store.hyperz.net/discord` }
]

};

module.exports = _config;
const _config = {
domain: "", // A domain to use for the API (no trailing slash).

discord: {
oauthId: "", // Discord Client ID
oauthToken: "", // Discord Client Secret
},

redirects: [{ name: "discord", link: "https://store.hyperz.net/discord" }],
};

module.exports = _config;
22 changes: 11 additions & 11 deletions Darkbot API/backend.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
async function checkAuth(req, res, next) {
if(req.isAuthenticated()){
next();
} else{
res.redirect("/auth/discord");
};
};
module.exports = {
checkAuth: checkAuth
};
async function checkAuth(req, res, next) {
if (req.isAuthenticated()) {
next();
} else {
res.redirect("/auth/discord");
}
}

module.exports = {
checkAuth,
};
12 changes: 6 additions & 6 deletions Darkbot API/extension.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "Darkbot API",
"version": "1.0.0",
"author": "Hyperz#0001",
"file": "api.js"
}
{
"name": "Darkbot API",
"version": "1.0.0",
"author": "Hyperz#0001",
"file": "api.js"
}
25 changes: 13 additions & 12 deletions Darkbot API/public/assets/main.css
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
html, body {
overflow-x: hidden !important;
}

body {
width: 100%;
height:100%;
margin: auto;
padding: 0;
background-color: rgba(0, 0, 0, .9);
color: white;
}
html,
body {
overflow-x: hidden !important;
}

body {
width: 100%;
height: 100%;
margin: auto;
padding: 0;
background-color: rgba(0, 0, 0, 0.9);
color: white;
}
Loading