Skip to content

Commit

Permalink
ohhhhh here we go again
Browse files Browse the repository at this point in the history
cookiiiieeeessssss, evil google tracking, moar languages, fixed gypo cunts spelling and shit
  • Loading branch information
MattheousDT committed Nov 15, 2018
1 parent 02d3be6 commit 2dee533
Show file tree
Hide file tree
Showing 13 changed files with 102 additions and 368 deletions.
2 changes: 1 addition & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"type": "node",
"request": "launch",
"name": "Launch Program",
"program": "${workspaceFolder}\\bot\\index.js"
"program": "${workspaceFolder}\\web\\index.js"
}
]
}
4 changes: 2 additions & 2 deletions bot/scripts/binding.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,8 @@ const binding = new Command({
author_id: message.author.id,

name,
description: "auto generated using script bindings",
thumbnail: "https://cdn.discordapp.com/attachments/209040403918356481/487658989069402112/pjiicjez.png",
description: "Auto-generated by the Feinwaru Binder™",
thumbnail: "https://cdn.discordapp.com/attachments/379432139856412682/512772131835084802/81KPFcRQKkL.png",
marketplace_enabled: false,

type: "json",
Expand Down
6 changes: 3 additions & 3 deletions bot/scripts/music.js
Original file line number Diff line number Diff line change
Expand Up @@ -272,15 +272,15 @@ const music = new Script({
name: "AWESOM-O Music",
description: "*wip*",
thumbnail: "https://media.discordapp.net/attachments/379432139856412682/504362169165414417/unknown.png?width=545&height=497",
marketplace_enabled: true,
marketplace_enabled: false,

type: "js",
match_type: "command",
match: "join;leave;play;skip;stop;np",

featured: true,
featured: false,

preload: true,
preload: false,

cb: async function(client, message, guild, user, script, match) {

Expand Down
30 changes: 28 additions & 2 deletions web/helpers/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,32 @@ const discord = require("discord.js");
const config = require("../config.json");

const client = new discord.Client();
client.login(config.token);
const login = client.login(config.token);

module.exports = client;
const wait = ms => new Promise((resolve, reject) => setTimeout(() => resolve(), ms));

let ready = false;

client.on("ready", () => {

ready = true;
});

const getClient = () => {
return new Promise(async (resolve, reject) => {

await login;

while(!ready) {

await wait(50);
}

resolve(client);
});
}

module.exports = {

getClient
};
26 changes: 24 additions & 2 deletions web/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,28 @@ const app = express();

const config = require("./config.json");

//
mongoose.connect(`mongodb://${config.mongo_user === null && config.mongo_pass === null ? "" : `${config.mongo_user}:${config.mongo_pass}@`}localhost/rawrxd`, {
useNewUrlParser: true,
...(config.mongo_user === null && config.mongo_pass === null ? {} : {
auth: {
authdb: "admin"
}
})
});
mongoose.Promise = global.Promise;

const db = mongoose.connection;
db.on("error", err => {

error(`error connecting to mongo: ${err}`);
});
db.on("open", () => {

info("connected to mongo");
});
//

app.enable("trust proxy");

app.use(morgan(config.env === "dev" ? "combined" : "combined", { stream: new stream.Writable({
Expand All @@ -43,9 +65,9 @@ app.use(express.json());
app.use(cookieParser(config.rawrxd));

app.use(i18n({
defaultLang: "en-gb",
defaultLang: "en",
translationsPath: path.join(__dirname, 'translations'),
siteLangs: ["en-gb","de","pt", "pl", "en-ni", "en-us"],
siteLangs: ["en","de","pt", "pl", "en-ni"],
paramLangName: "hl",
textsVarName: 'trans'
}));
Expand Down
6 changes: 4 additions & 2 deletions web/routes/api/scripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const schemas = require("../../../db");
const { authUser } = require("../../middlewares");
const { getUserData, getUserDataNoSession } = require("../../helpers");

const client = require("../../helpers/client");
const { getClient } = require("../../helpers/client");

const router = express.Router();
const { log: { info, warn, error } } = require("../../../utils");
Expand All @@ -21,7 +21,9 @@ const defaultValue = (param, def) => {
return param === undefined ? def : param;
}

router.route("/").get(authUser, (req, res) => {
router.route("/").get(authUser, async (req, res) => {

const client = await getClient();

// + cond user data
const extended = req.query.extended === "true" ? true : req.query.extended === "false" ? false : undefined;
Expand Down
4 changes: 3 additions & 1 deletion web/routes/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const express = require("express");
const showdown = require("showdown");
const jwt = require("jsonwebtoken");

const client = require("../helpers/client");
const { getClient } = require("../helpers/client");
const schemas = require("../../db");
const { log: { info, warn, error } } = require("../../utils");
const api = require("./api");
Expand Down Expand Up @@ -66,6 +66,8 @@ router.get("/api/v3/stats", async (req, res) => {
// status + ping
// latest update

const client = await getClient();

if (cachedStats.expire < Date.now()) {

cachedStats.stats = {};
Expand Down
21 changes: 21 additions & 0 deletions web/templates/partials/headers.ejs
Original file line number Diff line number Diff line change
@@ -1,3 +1,24 @@
<link rel="stylesheet" type="text/css" href="//cdnjs.cloudflare.com/ajax/libs/cookieconsent2/3.1.0/cookieconsent.min.css" />
<script src="//cdnjs.cloudflare.com/ajax/libs/cookieconsent2/3.1.0/cookieconsent.min.js"></script>
<script>
window.addEventListener("load", function(){
window.cookieconsent.initialise({
"palette": {
"popup": {
"background": "#454545"
},
"button": {
"background": "#ff5b4f",
"text": "#ffffff"
}
},
"content": {
"message": "<%= trans.COOKIE_MESSAGE %>",
"dismiss": "<%= trans.DISMISS %>",
"link": "<%= trans.LEARN_MORE %>"
}
})});
</script>
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-124885614-4"></script>
<script>
Expand Down
5 changes: 4 additions & 1 deletion web/translations/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -332,5 +332,8 @@
"OTHER_SERVERS_DESC": "Du musst der **Besitzer** sein oder zumindest **Admin** Berechtigungen auf dem Server haben damit es angezeigt wird",
"AWESOMO_ADDED":"AWESOM-O wurde hinzugefügt",
"AWESOMO_NOT_ADDED" : "AWESOM-O wurde nicht zum Server hinzugefügt",
"ACTIVATE": "Aktivieren"
"ACTIVATE": "Aktivieren",


"COOKIE_MESSAGE": "AWESOM-O nutzt Cookies um euch die bestmöglichste Erfahrung auf unserer Website zu ermöglichen."
}

0 comments on commit 2dee533

Please sign in to comment.