aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorame <[email protected]>2024-04-22 23:46:32 -0500
committerame <[email protected]>2024-04-22 23:46:32 -0500
commit509293de5af9bab66d624fd044e63d8962577af3 (patch)
tree9405af217212020965e68f1c97ff605cddacd2ca /src
parent6192af17619bba6066807a383375ba6178636cba (diff)
long time no commit
Diffstat (limited to 'src')
-rw-r--r--src/settings.js3
-rw-r--r--src/util.js6
-rw-r--r--src/webui.js79
3 files changed, 77 insertions, 11 deletions
diff --git a/src/settings.js b/src/settings.js
index 87ba87b..6baea47 100644
--- a/src/settings.js
+++ b/src/settings.js
@@ -11,6 +11,9 @@ module.exports = {
},
"748790869938929737":{
name: "logging",
+ },
+ "825023574221783102":{
+ name: "general"
}
}
}
diff --git a/src/util.js b/src/util.js
index 48cfa55..68f2c56 100644
--- a/src/util.js
+++ b/src/util.js
@@ -1,9 +1,9 @@
const rem_emp = function (e) {return e !== "";}
-
+const { ActivityType , PermissionsBitField} = require("discord.js");
module.exports = {
is_mod(member){
return member.permissions!=null&&
- (member.roles.cache.has("586781513471885323")||user.permissions?.has(PermissionsBitField.Flags.KickMembers))
+ (member.roles.cache.has("814558111234654258")||member.roles.cache.has("586781513471885323")||member.permissions?.has(PermissionsBitField.Flags.KickMembers))
},
generate_id(){
let config = JSON.parse(fs.readFileSync(config_loc))
@@ -118,4 +118,4 @@ module.exports = {
return target;
}
-} \ No newline at end of file
+}
diff --git a/src/webui.js b/src/webui.js
index 8a9fa56..999de2f 100644
--- a/src/webui.js
+++ b/src/webui.js
@@ -1,7 +1,8 @@
-const key = process.env.WEBUI_KEY
+const key = "0d68ac83-4214-4eb3-8b3e-fe4463f43d9d"
const bodyParser = require("body-parser");
const express = require('express');
+const fs = require('fs');
let db = require("../src/db");
const path = require("path")
const Tickets = db.Tickets
@@ -9,7 +10,8 @@ const Tickets = db.Tickets
const app = express();
app.use(bodyParser.urlencoded({ extended: false }));
app.use(bodyParser.json());
-const port = 7001;
+const port = 7003;
+
app.get('/tickets', async (req, res) => {
res.sendFile(path.join(__dirname+'/../html/tickets.html'))
})
@@ -28,13 +30,74 @@ app.post('/tickets/edit', async (req, res) => {
res.send('failed')
})
-app.get('/settings', async (req, res) => {
+
+
+
+let root_path = path.join(__dirname+"/../")
+let settings_dirs = [
+ path.join(__dirname+"/../events"),
+]
+
+fs.readdirSync(path.join(__dirname+"/../commands/")).forEach(async file => {
+ let full_path = path.join(__dirname+"/../commands/"+file)
+ let stat = fs.statSync(full_path);
+ if(stat.isDirectory()){
+ settings_dirs.push(full_path)
+ }
+})
+
+let clean_settings_dirs = [];
+for(let i = 0; i != settings_dirs.length; i++){
+ clean_settings_dirs[i] = settings_dirs[i].slice(root_path.length)
+}
+
+//console.log(settings_dirs)
+let settings_full = {};
+
+for(let dir of settings_dirs){
+ let fdir = dir.slice(root_path.length);
+
+ fs.readdirSync(dir).forEach(async file => {
+ let full_path = path.join(dir+"/"+file)
+ let stat = fs.statSync(full_path);
+ if(!stat.isDirectory() && file.endsWith(".js.json")){
+ if(settings_full[fdir] == null){
+ settings_full[fdir] = []
+ }
+
+ settings_full[fdir].push(file.slice(0,-8))
+ }
+
+ })
+}
+
+console.log(settings_full)
+app.get('/settings/', async (req, res) => {
res.sendFile(path.join(__dirname+'/../html/settings.html'))
})
-app.post('/settings/data', async (req, res) => {
- if(req.body.key == key)
- res.send('todo:P')
- else
- res.send('failed')
+
+app.post('/settings/data/', async (req, res) => {
+ if(req.body.key != key)
+ return res.send('failed')
+ let data = {data:settings_full,sel:"null"}
+ res.send(JSON.stringify(data))
})
+
+
+for(let ddir in settings_full){
+ for(let dir of settings_full[ddir]){
+ let at = ddir + "/" + dir
+ app.post('/settings/'+at+'/data', async (req, res) => {
+ if(req.body.key != key)
+ return res.send('failed')
+ let c = fs.readFileSync(path.join(__dirname+"/../"+at+".js.json"))
+ let data = {data:settings_full,sel:c.toString()}
+ res.send(JSON.stringify(data))
+ })
+ console.log('/settings/'+at)
+ app.get('/settings/'+at, async (req, res) => {
+ res.sendFile(path.join(__dirname+'/../html/settings.html'))
+ })
+ }
+}
app.listen(port, () => console.log(`listening at http://localhost:${port}`));