aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Lee <andrew@alee14.me>2025-03-24 01:29:33 -0400
committerAndrew Lee <andrew@alee14.me>2025-03-24 01:29:33 -0400
commit0453bafa63ccd1057279a1be9286b3e7ebcb62d2 (patch)
tree0a71e0c06912a81ac009b196c5fee8dc9037cb60
parenta19b6ed4ef829697fd0be153af5e27c99f267787 (diff)
downloadAleeBot-0453bafa63ccd1057279a1be9286b3e7ebcb62d2.tar.gz
AleeBot-0453bafa63ccd1057279a1be9286b3e7ebcb62d2.tar.bz2
AleeBot-0453bafa63ccd1057279a1be9286b3e7ebcb62d2.zip
Depcreating web server, returning back to using Discord as settings
-rw-r--r--bot/bun.lockbbin124855 -> 124855 bytes
-rw-r--r--bot/package.json2
-rw-r--r--bot/src/api/routes/settings.js22
-rw-r--r--web/bun.lockbbin154951 -> 154951 bytes
-rw-r--r--web/package.json8
-rw-r--r--web/src/app/components/Guilds.jsx12
-rw-r--r--web/src/app/dashboard/page.js18
-rw-r--r--web/src/lib/auth.js7
8 files changed, 36 insertions, 33 deletions
diff --git a/bot/bun.lockb b/bot/bun.lockb
index 13af9e0..a14de88 100644
--- a/bot/bun.lockb
+++ b/bot/bun.lockb
Binary files differ
diff --git a/bot/package.json b/bot/package.json
index 72568aa..5a0f631 100644
--- a/bot/package.json
+++ b/bot/package.json
@@ -16,7 +16,7 @@
"discord.js": "^14.18.0",
"express": "^4.21.2",
"ollama": "^0.5.14",
- "sequelize": "^6.37.5",
+ "sequelize": "^6.37.6",
"sqlite3": "^5.1.7"
},
"devDependencies": {
diff --git a/bot/src/api/routes/settings.js b/bot/src/api/routes/settings.js
index 8757874..ce28acd 100644
--- a/bot/src/api/routes/settings.js
+++ b/bot/src/api/routes/settings.js
@@ -5,22 +5,12 @@ import { guildSettings } from '../../models/guild-settings.js';
export function settingsRouter(client) {
const router = Router();
- router.get('/settings/guild', async (req, res) => {
- try {
- const { guildID } = req.body;
- if (!guildID) return res.status(400).send('Guild ID not provided');
- const settings = await guildSettings.findOne({ where: { guildID: guildID } });
- res.json(settings);
- } catch (e) {
- console.error('Error fetching settings:', e);
- res.status(500).send('Internal Server Error');
- }
- });
-
router.get('/settings/guild/:id', async (req, res) => {
try {
const settings = await guildSettings.findOne({ where: { guildID: req.params.id } });
+ if (!settings) return res.sendStatus(404);
+
let channels = [];
client.guilds.cache.get(settings.guildID).channels.cache
@@ -29,6 +19,7 @@ export function settingsRouter(client) {
const channelInfo = {
name: channel.name,
id: channel.id,
+ position: channel.position,
category: channel.parent ? channel.parent.name : 'No Category'
};
@@ -36,6 +27,13 @@ export function settingsRouter(client) {
});
res.json({
+ settings: settings,
+ guild: [
+ {
+ name: client.guilds.cache.get(settings.guildID).name,
+ id: settings.guildID
+ }
+ ],
channels: channels
});
} catch (e) {
diff --git a/web/bun.lockb b/web/bun.lockb
index 4a7df2d..8f54964 100644
--- a/web/bun.lockb
+++ b/web/bun.lockb
Binary files differ
diff --git a/web/package.json b/web/package.json
index 5bac297..8e69990 100644
--- a/web/package.json
+++ b/web/package.json
@@ -9,16 +9,16 @@
"lint": "next lint"
},
"dependencies": {
- "next": "15.2.3",
+ "next": "^15.2.3",
"next-auth": "^5.0.0-beta.25",
"react": "^19.0.0",
"react-dom": "^19.0.0"
},
"devDependencies": {
- "@tailwindcss/postcss": "^4",
- "tailwindcss": "^4",
+ "@eslint/eslintrc": "^3",
+ "@tailwindcss/postcss": "^4.0.15",
"eslint": "^9",
"eslint-config-next": "15.2.3",
- "@eslint/eslintrc": "^3"
+ "tailwindcss": "^4.0.15"
}
}
diff --git a/web/src/app/components/Guilds.jsx b/web/src/app/components/Guilds.jsx
index 50baa98..38626e4 100644
--- a/web/src/app/components/Guilds.jsx
+++ b/web/src/app/components/Guilds.jsx
@@ -8,18 +8,18 @@ export default async function Guilds({session}) {
});
const guilds = await response.json();
+ const ADMINISTRATOR = 0x0000000000000008;
const MANAGE_GUILD = 0x00000020;
const filteredGuilds = guilds.filter((guild) => {
// Convert permissions string to a BigInt for bitwise operations
const permissions = BigInt(guild.permissions);
- // Check if MANAGE_GUILD bit is set
- return (permissions & BigInt(MANAGE_GUILD)) === BigInt(MANAGE_GUILD);
- });
+ // Check if user is owner, has ADMINISTRATOR or MANAGE_GUILD permissions
+ return guild.owner ||
+ (permissions & BigInt(ADMINISTRATOR)) === BigInt(ADMINISTRATOR) ||
+ (permissions & BigInt(MANAGE_GUILD)) === BigInt(MANAGE_GUILD); });
return filteredGuilds.map((guild) => (
- <div key={guild.id}>
- <h2>{guild.name}</h2>
- </div>
+ <div key={guild.id} className="p-1">{guild.name}</div>
))
}
diff --git a/web/src/app/dashboard/page.js b/web/src/app/dashboard/page.js
index d6e3a41..bab3bd8 100644
--- a/web/src/app/dashboard/page.js
+++ b/web/src/app/dashboard/page.js
@@ -8,7 +8,7 @@ export default async function Home() {
if (!session) redirect("/");
return (
- <div>
+ <>
<nav className="bg-gray-900 text-white">
<div className="max-w-screen-xl flex items-center justify-between mx-auto p-4">
<div className="flex items-center">
@@ -21,7 +21,19 @@ export default async function Home() {
</div>
</div>
</nav>
- <Guilds session={session} />
- </div>
+ <div className="flex">
+ <div>
+ <div>Settings</div>
+ <Guilds session={session} />
+ </div>
+ <div>
+ <h1 className="text-2xl">Logging</h1>
+ <h2>Channel 1</h2>
+ <h2>Channel 2</h2>
+ <h1 className="text-2xl">Quote of the Day</h1>
+ <h1 className="text-2xl">LLM Chatbot</h1>
+ </div>
+ </div>
+ </>
)
}
diff --git a/web/src/lib/auth.js b/web/src/lib/auth.js
index 3f78f94..28c34f1 100644
--- a/web/src/lib/auth.js
+++ b/web/src/lib/auth.js
@@ -4,13 +4,6 @@ import Discord from "next-auth/providers/discord"
export const { handlers, signIn, signOut, auth } = NextAuth({
providers: [Discord({
authorization: {
- profile(profile) {
- return {
- id: profile.id,
- name: profile.username,
- image: profile.image_url
- }
- },
url: "https://discord.com/api/oauth2/authorize",
params: { scope: "identify guilds" },
}