From c6c08d09a7ffcc8e37f814b367581eb04eecd991 Mon Sep 17 00:00:00 2001 From: aronmal Date: Sat, 20 Jan 2024 16:41:30 +0100 Subject: [PATCH] Showcase ref bug --- README.md | 23 ++- package.json | 7 - pnpm-lock.yaml | 83 -------- src/app.tsx | 2 +- src/components/FontAwesomeIcon.tsx | 151 -------------- src/components/NavBar.tsx | 6 +- src/components/NavUser.tsx | 92 ++++----- src/routes/[...404].tsx | 23 --- src/routes/about.tsx | 78 -------- src/routes/acknowledgements.tsx | 196 ------------------ src/routes/api/auth/[...solidauth].ts | 4 - src/routes/config/[guildId].tsx | 275 +++++++++++++++++--------- src/routes/config/index.tsx | 196 +++++++++--------- src/routes/contact.tsx | 26 --- src/routes/features.tsx | 51 ----- src/routes/how-do-i.tsx | 62 ------ src/routes/imprint.tsx | 62 ------ src/routes/privacy-policy.tsx | 178 ----------------- src/routes/stack.tsx | 55 ------ src/routes/terms-of-service.tsx | 95 --------- src/types/env.d.ts | 4 +- 21 files changed, 339 insertions(+), 1330 deletions(-) delete mode 100644 src/components/FontAwesomeIcon.tsx delete mode 100644 src/routes/[...404].tsx delete mode 100644 src/routes/about.tsx delete mode 100644 src/routes/acknowledgements.tsx delete mode 100644 src/routes/api/auth/[...solidauth].ts delete mode 100644 src/routes/contact.tsx delete mode 100644 src/routes/features.tsx delete mode 100644 src/routes/how-do-i.tsx delete mode 100644 src/routes/imprint.tsx delete mode 100644 src/routes/privacy-policy.tsx delete mode 100644 src/routes/stack.tsx delete mode 100644 src/routes/terms-of-service.tsx diff --git a/README.md b/README.md index 94099da..1fa87ab 100644 --- a/README.md +++ b/README.md @@ -49,23 +49,30 @@ To get started with li'l Judd, follow the instructions below. VITE_DISCORD_CLIENT=your_discord_client_id VITE_DISCORD_CLIENT_SECRET=your_discord_client_secret VITE_DISCORD_BOT_TOKEN=your_discord_bot_token + VITE_DISCORD_BOT_PERMISSIONS=18977581952080 VITE_AUTH_SECRET=your_auth_secret VITE_DATABASE_URL=your_database_url ``` - #### Development +Recieve your discord applications client id & secret, as well as the bot token from the [Applications dashboard](https://discord.com/developers/applications/). - Specify `VITE_AUTH_REDIRECT_PROXY_URL` only if necessary, particularly when setting up a reverse proxy to test authentication with callbacks to your development box. [Auth.js Docs Reference](https://authjs.dev/reference/nextjs/#redirectproxyurl) +How to generate your `VITE_AUTH_SECRET` with [`openssl rand -base64 32`](https://authjs.dev/reference/core#secret). - The duplicate `DATABASE_URL` is only needed for Drizzle Studio. +Composite your `VITE_DATABASE_URL` like [`postgres://postgres:adminadmin@0.0.0.0:5432/db`](https://orm.drizzle.team/docs/get-started-postgresql#postgresjs). - ``` - VITE_AUTH_REDIRECT_PROXY_URL=your_auth_redirect_proxy_url +#### Development - DATABASE_URL=your_database_url - ``` +Specify `VITE_AUTH_REDIRECT_PROXY_URL` only if necessary, particularly when setting up a reverse proxy to test authentication with callbacks to your development box. [Auth.js Docs Reference](https://authjs.dev/reference/nextjs/#redirectproxyurl) + +The duplicate `DATABASE_URL` is only needed for Drizzle Studio. + +``` +VITE_AUTH_REDIRECT_PROXY_URL=your_auth_redirect_proxy_url + +DATABASE_URL=your_database_url +``` ### Usage @@ -120,6 +127,6 @@ If you'd like to contribute to li'l Judd, feel free to open an issue or submit a ## License -This project is licensed under the [MIT License](LICENSE). +This project is licensed under the [GPL v3 License](LICENSE). Happy splatting! 🦑🎮 diff --git a/package.json b/package.json index c6d0a6c..6fbf7e9 100644 --- a/package.json +++ b/package.json @@ -16,13 +16,6 @@ "@auth/core": "^0.19.0", "@auth/drizzle-adapter": "^0.3.12", "@auth/solid-start": "0.1.2", - "@fortawesome/fontawesome-svg-core": "^6.5.1", - "@fortawesome/pro-duotone-svg-icons": "^6.5.1", - "@fortawesome/pro-light-svg-icons": "^6.5.1", - "@fortawesome/pro-regular-svg-icons": "^6.5.1", - "@fortawesome/pro-solid-svg-icons": "^6.5.1", - "@fortawesome/pro-thin-svg-icons": "^6.5.1", - "@fortawesome/sharp-solid-svg-icons": "^6.5.1", "@solidjs/meta": "^0.29.2", "@solidjs/router": "^0.10.9", "@solidjs/start": "^0.4.9", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index abde40e..0760584 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -14,27 +14,6 @@ dependencies: '@auth/solid-start': specifier: 0.1.2 version: 0.1.2(@auth/core@0.19.1)(solid-js@1.8.11)(solid-start@0.2.32) - '@fortawesome/fontawesome-svg-core': - specifier: ^6.5.1 - version: 6.5.1 - '@fortawesome/pro-duotone-svg-icons': - specifier: ^6.5.1 - version: 6.5.1 - '@fortawesome/pro-light-svg-icons': - specifier: ^6.5.1 - version: 6.5.1 - '@fortawesome/pro-regular-svg-icons': - specifier: ^6.5.1 - version: 6.5.1 - '@fortawesome/pro-solid-svg-icons': - specifier: ^6.5.1 - version: 6.5.1 - '@fortawesome/pro-thin-svg-icons': - specifier: ^6.5.1 - version: 6.5.1 - '@fortawesome/sharp-solid-svg-icons': - specifier: ^6.5.1 - version: 6.5.1 '@solidjs/meta': specifier: ^0.29.2 version: 0.29.3(solid-js@1.8.11) @@ -2048,68 +2027,6 @@ packages: resolution: {integrity: sha512-+KpH+QxZU7O4675t3mnkQKcZZg56u+K/Ct2K+N2AZYNVK8kyeo/bI18tI8aPm3tvNNRyTWfj6s5tnGNlcbQRsA==} engines: {node: '>=14'} - /@fortawesome/fontawesome-common-types@6.5.1: - resolution: {integrity: sha512-GkWzv+L6d2bI5f/Vk6ikJ9xtl7dfXtoRu3YGE6nq0p/FFqA1ebMOAWg3XgRyb0I6LYyYkiAo+3/KrwuBp8xG7A==, tarball: https://npm.fontawesome.com/@fortawesome/fontawesome-common-types/-/6.5.1/fontawesome-common-types-6.5.1.tgz} - engines: {node: '>=6'} - requiresBuild: true - dev: false - - /@fortawesome/fontawesome-svg-core@6.5.1: - resolution: {integrity: sha512-MfRCYlQPXoLlpem+egxjfkEuP9UQswTrlCOsknus/NcMoblTH2g0jPrapbcIb04KGA7E2GZxbAccGZfWoYgsrQ==, tarball: https://npm.fontawesome.com/@fortawesome/fontawesome-svg-core/-/6.5.1/fontawesome-svg-core-6.5.1.tgz} - engines: {node: '>=6'} - requiresBuild: true - dependencies: - '@fortawesome/fontawesome-common-types': 6.5.1 - dev: false - - /@fortawesome/pro-duotone-svg-icons@6.5.1: - resolution: {integrity: sha512-ywRh7WpcUD4To4TBFZc2EzbFblWiccNf9wwLFK56J7t8mO9ITQJAIPpT8x7DBrqejfbw9B4F6aH5fY6mfi0egg==, tarball: https://npm.fontawesome.com/@fortawesome/pro-duotone-svg-icons/-/6.5.1/pro-duotone-svg-icons-6.5.1.tgz} - engines: {node: '>=6'} - requiresBuild: true - dependencies: - '@fortawesome/fontawesome-common-types': 6.5.1 - dev: false - - /@fortawesome/pro-light-svg-icons@6.5.1: - resolution: {integrity: sha512-qcBN5RESCPhbWRvHL5N5ovxvYzj2KbpKoSWPJ1TRce1jSsQgBx6hN4SCzzzYJkoiIO43L1/n+NjEQHb0YYtg6g==, tarball: https://npm.fontawesome.com/@fortawesome/pro-light-svg-icons/-/6.5.1/pro-light-svg-icons-6.5.1.tgz} - engines: {node: '>=6'} - requiresBuild: true - dependencies: - '@fortawesome/fontawesome-common-types': 6.5.1 - dev: false - - /@fortawesome/pro-regular-svg-icons@6.5.1: - resolution: {integrity: sha512-Rd7Q7Vff68l/YtFKB4EJW/YJ5eXYk7TqejyDTapOI1sn3/AFMEc8CVCOsPfi4+6qGrJy16hlNvgpigIy5gkW7A==, tarball: https://npm.fontawesome.com/@fortawesome/pro-regular-svg-icons/-/6.5.1/pro-regular-svg-icons-6.5.1.tgz} - engines: {node: '>=6'} - requiresBuild: true - dependencies: - '@fortawesome/fontawesome-common-types': 6.5.1 - dev: false - - /@fortawesome/pro-solid-svg-icons@6.5.1: - resolution: {integrity: sha512-UnJzqw7w+RVtEnQ2Bqg09bGYkJEZRkTnbgweZDTznHjtxsJzQdJkD3hJPL6N00c8GbWpRYslNDnTNDGVSd94cQ==, tarball: https://npm.fontawesome.com/@fortawesome/pro-solid-svg-icons/-/6.5.1/pro-solid-svg-icons-6.5.1.tgz} - engines: {node: '>=6'} - requiresBuild: true - dependencies: - '@fortawesome/fontawesome-common-types': 6.5.1 - dev: false - - /@fortawesome/pro-thin-svg-icons@6.5.1: - resolution: {integrity: sha512-tVb+5q+QQiSG3enV9+PpeFKe7wd+TK5zZ9q9iqr4Zj2UbxdV2o6SGcA5h0oeWVH2eHVqiIHxfEf7XbB8/ZioAQ==, tarball: https://npm.fontawesome.com/@fortawesome/pro-thin-svg-icons/-/6.5.1/pro-thin-svg-icons-6.5.1.tgz} - engines: {node: '>=6'} - requiresBuild: true - dependencies: - '@fortawesome/fontawesome-common-types': 6.5.1 - dev: false - - /@fortawesome/sharp-solid-svg-icons@6.5.1: - resolution: {integrity: sha512-IYRaD4FKokprj63Qu+blYXgLioPFQx3ecimYk8ENd4cpySOYgP8tPRy5TSSq0udkXKAjfkeYUAXhQ88OD0qyiw==, tarball: https://npm.fontawesome.com/@fortawesome/sharp-solid-svg-icons/-/6.5.1/sharp-solid-svg-icons-6.5.1.tgz} - engines: {node: '>=6'} - requiresBuild: true - dependencies: - '@fortawesome/fontawesome-common-types': 6.5.1 - dev: false - /@hapi/hoek@9.3.0: resolution: {integrity: sha512-/c6rf4UJlmHlC9b5BaNvzAcFv7HZ2QHaV0D4/HNlBdvFnvQq8RI4kYdhyPCl7Xj+oWvTWQ8ujhqS53LIgAe6KQ==} dev: false diff --git a/src/app.tsx b/src/app.tsx index bb7de6e..74c7ccd 100644 --- a/src/app.tsx +++ b/src/app.tsx @@ -1,5 +1,5 @@ // @refresh reload -import "@fortawesome/fontawesome-svg-core/styles.css"; +// import "@fortawesome/fontawesome-svg-core/styles.css"; import { Meta, MetaProvider, Title } from "@solidjs/meta"; import { Router } from "@solidjs/router"; import { FileRoutes } from "@solidjs/start"; diff --git a/src/components/FontAwesomeIcon.tsx b/src/components/FontAwesomeIcon.tsx deleted file mode 100644 index 536a4bc..0000000 --- a/src/components/FontAwesomeIcon.tsx +++ /dev/null @@ -1,151 +0,0 @@ -import { - FaSymbol, - FlipProp, - IconDefinition, - IconProp, - PullProp, - RotateProp, - SizeProp, - Transform, -} from "@fortawesome/fontawesome-svg-core"; -import { type JSX } from "solid-js"; - -export interface FontAwesomeIconProps - extends Omit< - JSX.SvgSVGAttributes, - "children" | "mask" | "transform" - > { - icon: IconDefinition; - mask?: IconProp; - maskId?: string; - color?: string; - spin?: boolean; - spinPulse?: boolean; - spinReverse?: boolean; - pulse?: boolean; - beat?: boolean; - fade?: boolean; - beatFade?: boolean; - bounce?: boolean; - shake?: boolean; - flash?: boolean; - border?: boolean; - fixedWidth?: boolean; - inverse?: boolean; - listItem?: boolean; - flip?: FlipProp; - size?: SizeProp; - pull?: PullProp; - rotation?: RotateProp; - transform?: string | Transform; - symbol?: FaSymbol; - style?: JSX.CSSProperties; - tabIndex?: number; - title?: string; - titleId?: string; - swapOpacity?: boolean; -} - -const idPool = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"; -function nextUniqueId() { - let size = 12; - let id = ""; - - while (size-- > 0) { - id += idPool[(Math.random() * 62) | 0]; - } - - return id; -} - -function Path(props: { d: string | string[] }) { - return ( - <> - {typeof props.d === "string" ? ( - - ) : ( - <> - - - - )} - - ); -} - -export function FontAwesomeIcon(props: FontAwesomeIconProps) { - const titleId = () => - props.title - ? "svg-inline--fa-title-".concat(props.titleId || nextUniqueId()) - : undefined; - // Get CSS class list from the props object - function attributes() { - const defaultClasses = { - "svg-inline--fa": true, - [`fa-${props.icon.iconName}`]: true, - [props.class ?? ""]: - typeof props.class !== "undefined" && props.class !== null, - ...props.classList, - }; - - // map of CSS class names to properties - const faClasses = { - "fa-beat": props.beat, - "fa-fade": props.fade, - "fa-beat-fade": props.beatFade, - "fa-bounce": props.bounce, - "fa-shake": props.shake, - "fa-flash": props.flash, - "fa-spin": props.spin, - "fa-spin-reverse": props.spinReverse, - "fa-spin-pulse": props.spinPulse, - "fa-pulse": props.pulse, - "fa-fw": props.fixedWidth, - "fa-inverse": props.inverse, - "fa-border": props.border, - "fa-li": props.listItem, - "fa-flip": typeof props.flip !== "undefined" && props.flip !== null, - "fa-flip-horizontal": - props.flip === "horizontal" || props.flip === "both", - "fa-flip-vertical": props.flip === "vertical" || props.flip === "both", - [`fa-${props.size}`]: - typeof props.size !== "undefined" && props.size !== null, - [`fa-rotate-${props.rotation}`]: - typeof props.rotation !== "undefined" && props.size !== null, - [`fa-pull-${props.pull}`]: - typeof props.pull !== "undefined" && props.pull !== null, - "fa-swap-opacity": props.swapOpacity, - }; - - const attributes = { - focusable: !!props.title, - "aria-hidden": !props.title, - role: "img", - xmlns: "http://www.w3.org/2000/svg", - "aria-labelledby": titleId(), - "data-prefix": props.icon.prefix, - "data-icon": props.icon.iconName, - "data-fa-transform": props.transform, - "data-fa-mask": props.mask, - "data-fa-mask-id": props.maskId, - "data-fa-symbol": props.symbol, - tabIndex: props.tabIndex, - classList: { ...defaultClasses, ...faClasses }, - color: props.color, - style: props.style, - viewBox: `0 0 ${props.icon.icon[0]} ${props.icon.icon[1]}`, - } as const; - - // return the complete class list - return attributes; - } - - return ( - - {/* - {props.title} - */} - - - ); -} diff --git a/src/components/NavBar.tsx b/src/components/NavBar.tsx index bdd9cf2..4e524fa 100644 --- a/src/components/NavBar.tsx +++ b/src/components/NavBar.tsx @@ -1,7 +1,5 @@ -import { faCirclePlus } from "@fortawesome/pro-regular-svg-icons"; import { JSX, Show, Suspense } from "solid-js"; import "../styles/components/NavBar.scss"; -import { FontAwesomeIcon } from "./FontAwesomeIcon"; import NavUser from "./NavUser"; export function Li(props: { @@ -40,10 +38,10 @@ function NavBar() {
  • - + {/* */}
  • diff --git a/src/components/NavUser.tsx b/src/components/NavUser.tsx index 6fd3fa9..b851f0a 100644 --- a/src/components/NavUser.tsx +++ b/src/components/NavUser.tsx @@ -1,84 +1,74 @@ -import { getSession } from "@auth/solid-start"; import { signIn, signOut } from "@auth/solid-start/client"; -import { - faArrowRightFromBracket, - faArrowRightToBracket, - faGear, -} from "@fortawesome/pro-regular-svg-icons"; -import { eq } from "drizzle-orm"; -import { Show, createResource } from "solid-js"; -import { getRequestEvent } from "solid-js/web"; -import db from "~/drizzle"; -import { users } from "~/drizzle/schema"; -import { authOptions } from "~/server/auth"; -import { FontAwesomeIcon } from "./FontAwesomeIcon"; +import { Show } from "solid-js"; import { Li } from "./NavBar"; -const initialUser = { - id: "", - name: null as string | null, - email: "", - emailVerified: null as Date | null, - image: null as string | null, -}; +// const initialUser = { +// id: "", +// name: null as string | null, +// email: "", +// emailVerified: null as Date | null, +// image: null as string | null, +// }; -async function getUser() { - "use server"; +// async function getUser() { +// "use server"; - const event = getRequestEvent(); - if (!event) - return { success: false, message: "No request event!", ...initialUser }; +// const event = getRequestEvent(); +// if (!event) +// return { success: false, message: "No request event!", ...initialUser }; - const session = await getSession(event.request, authOptions); - if (!session?.user?.id) - return { success: false, message: "No user with id!", ...initialUser }; +// const session = await getSession(event.request, authOptions); +// if (!session?.user?.id) +// return { success: false, message: "No user with id!", ...initialUser }; - const user = ( - await db - .selectDistinct() - .from(users) - .where(eq(users.id, session.user?.id)) - .limit(1) - .execute() - )[0]; +// const user = ( +// await db +// .selectDistinct() +// .from(users) +// .where(eq(users.id, session.user?.id)) +// .limit(1) +// .execute() +// )[0]; - return { success: true, message: "", ...user }; -} +// return { success: true, message: "", ...user }; +// } function NavUser() { - const [user] = createResource(() => - getUser().then((e) => { - if (!e.success) console.log(1, e.message); - console.log(2, e); - return e; - }), - ); + // const location = useLocation(); + + // const [user] = createResource(() => + // getUser().then((e) => { + // if (!e.success) console.log(1, location.pathname, e.message); + // console.log(2, location.pathname, e); + // return e; + // }), + // ); return ( signIn("discord", { callbackUrl: "/config" })} > - + /> */} } >
  • - User pfp - + {/* User pfp */} + {/* */}
  • signOut({ callbackUrl: "/" })}> - + {/* */}
  • ); diff --git a/src/routes/[...404].tsx b/src/routes/[...404].tsx deleted file mode 100644 index ef4ef50..0000000 --- a/src/routes/[...404].tsx +++ /dev/null @@ -1,23 +0,0 @@ -import { Title } from "@solidjs/meta"; -import { HttpStatusCode } from "@solidjs/start"; -import Layout from "~/components/Layout"; -import "../styles/pages/index.scss"; - -export default function NotFound() { - return ( - - Not Found - -
    -

    404 - Whoops, ink spill!

    -
    li'l Judd couldn't find this turf.
    -
    -

    - Head back to base and splat into action from there! - 🦑🕹️ -

    -
    -
    -
    - ); -} diff --git a/src/routes/about.tsx b/src/routes/about.tsx deleted file mode 100644 index 046e9ae..0000000 --- a/src/routes/about.tsx +++ /dev/null @@ -1,78 +0,0 @@ -import Layout from "~/components/Layout"; -import "../styles/pages/about.scss"; - -function about() { - return ( - -

    About

    -
    -

    Why does this bot exist?

    -

    - We had a person in our team, who sent{" "} - - these planning messages - {" "} - and I thought that this should be automated. Some time later the first - version of li'l Judd was born. Today the bot has more features and - keeps getting more of them! It is designed to actually improve the - Splatoon experience and not be the 10000th moderation and general - utility bot with the same features as all bots. -

    -
    -
    -

    Who is behind this?

    -

    - The bot is currently being developed by{" "} - moonleay (hey that's me!) with occasional - help from his friends! -

    -
    -
    -

    How can I trust you?

    -

    - The bot only requests permissions, which are needed for it to work. - Additionally, if you want to check how the bot works under the hood, - you can - - read the code - - and if you still don't trust me, you can always host the bot yourself! - A guide on how to do that can be found in the README of the git - project. -

    -
    -
    -

    Where is my data stored?

    -

    - Your data is stored on a VPS from Contabo in Germany. The bot used to - be hosted on a server in my basement, but I moved it to a VPS, because - my internet connection was not stable enough. -

    -
    -
    -

    So whats in the future?

    -

    - I plan on adding features, which are aimed to improve your and your - teams competitive experience! You can check out my public todo list{" "} - - here - - . -

    -
    -
    -

    Hey, there is this really cool idea I have! Can you add it?

    -

    - Just message me! I can't promise anything, but I am always open to new - ideas and improvements! You can find ways to contact me{" "} - here. -

    -
    -
    - ); -} - -export default about; diff --git a/src/routes/acknowledgements.tsx b/src/routes/acknowledgements.tsx deleted file mode 100644 index 4f225c5..0000000 --- a/src/routes/acknowledgements.tsx +++ /dev/null @@ -1,196 +0,0 @@ -import Layout from "~/components/Layout"; -import "../styles/pages/acknowledgements.scss"; - -function acknowledgements() { - return ( - -

    Acknowledgements

    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -

    tool

    -
    -

    license

    -
    -

    page

    -
    -

    Kotlin

    -
    - - Apache license 2.0 - - - - website - -
    -

    Kord

    -
    - - MIT license - - - - website - -
    -

    Kord Extensions

    -
    - - Mozilla Public License 2.0 - - - - website - -
    -

    PostgreSQL

    -
    - - PostgreSQL license - - - - website - -
    -

    kotlinx-coroutines-core

    -
    - - Apache license 2.0 - - - - repo - -
    -

    slf4j

    -
    - - MIT license - - - - website - -
    -

    Exposed

    -
    - - Apache license 2.0 - - - - repo - -
    -

    Krontab

    -
    - - Apache license 2.0 - - - - repo - -
    -

    Splatoon3.ink

    -
    - - MIT License - - - - website - -
    -
    -
    - ); -} - -export default acknowledgements; diff --git a/src/routes/api/auth/[...solidauth].ts b/src/routes/api/auth/[...solidauth].ts deleted file mode 100644 index 724f269..0000000 --- a/src/routes/api/auth/[...solidauth].ts +++ /dev/null @@ -1,4 +0,0 @@ -import { SolidAuth } from "@auth/solid-start" -import { authOptions } from "~/server/auth" - -export const { GET, POST } = SolidAuth(authOptions) diff --git a/src/routes/config/[guildId].tsx b/src/routes/config/[guildId].tsx index 3b18b70..112c28f 100644 --- a/src/routes/config/[guildId].tsx +++ b/src/routes/config/[guildId].tsx @@ -1,18 +1,14 @@ -import { getSession } from "@auth/solid-start"; -import { faToggleOff, faToggleOn } from "@fortawesome/pro-regular-svg-icons"; -import { useNavigate, useParams } from "@solidjs/router"; -import { eq } from "drizzle-orm"; +import { useLocation, useNavigate, useParams } from "@solidjs/router"; import moment from "moment-timezone"; -import createClient from "openapi-fetch"; -import { Index, createEffect, createResource, createSignal } from "solid-js"; +import { + For, + Index, + createEffect, + createResource, + createSignal, +} from "solid-js"; import { createStore } from "solid-js/store"; -import { getRequestEvent } from "solid-js/web"; -import { FontAwesomeIcon } from "~/components/FontAwesomeIcon"; import Layout from "~/components/Layout"; -import db from "~/drizzle"; -import { accounts } from "~/drizzle/schema"; -import { authOptions } from "~/server/auth"; -import { paths } from "~/types/discord"; import "../../styles/pages/config.scss"; const guessTZ = () => Intl.DateTimeFormat().resolvedOptions().timeZone; @@ -23,6 +19,8 @@ const initialValue = (params: ReturnType) => ({ id: params.guildId, name: undefined as string | undefined, icon: undefined as string | null | undefined, + channel: "", + channels: [] as { id: string; name: string }[], }, tzNames: [guessTZ()], }); @@ -34,101 +32,155 @@ const getPayload = async ( | (ReturnType & { success: true }) > => { "use server"; - const event = getRequestEvent(); - if (!event) return { success: false, message: "No request event!" }; + console.log("request for", id); + // const event = getRequestEvent(); + // const location = useLocation(); + // if (!event) return { success: false, message: "No request event!" }; - const session = await getSession(event.request, authOptions); - if (!session?.user?.id) - return { success: false, message: "No user with id!" }; + // const session = await getSession(event.request, authOptions); + // if (!session?.user?.id) + // return { success: false, message: "No user with id!" }; - const { DISCORD_ACCESS_TOKEN } = ( - await db - .selectDistinct({ DISCORD_ACCESS_TOKEN: accounts.access_token }) - .from(accounts) - .where(eq(accounts.userId, session.user?.id)) - .limit(1) - .execute() - )[0]; - if (!DISCORD_ACCESS_TOKEN) - return { success: false, message: "No discord access token!" }; + // const { DISCORD_ACCESS_TOKEN } = ( + // await db + // .selectDistinct({ DISCORD_ACCESS_TOKEN: accounts.access_token }) + // .from(accounts) + // .where(eq(accounts.userId, session.user?.id)) + // .limit(1) + // .execute() + // )[0]; + // if (!DISCORD_ACCESS_TOKEN) + // return { success: false, message: "No discord access token!" }; - // const guilds = await fetch("https://discord.com/api/users/@me/guilds", { + // const { GET } = createClient({ + // baseUrl: "https://discord.com/api/v10", + // }); + // const guildsRequest = await GET("/users/@me/guilds", { // headers: { Authorization: `Bearer ${DISCORD_ACCESS_TOKEN}` }, - // }).then((res) => res.json()); - const { GET } = createClient({ - baseUrl: "https://discord.com/api/v10", - }); - const { data: guilds, error } = await GET("/users/@me/guilds", { - headers: { Authorization: `Bearer ${DISCORD_ACCESS_TOKEN}` }, - }); + // }); + // const channelsRequest = await GET("/guilds/{guild_id}/channels", { + // params: { + // path: { + // guild_id: id, + // }, + // }, + // headers: { Authorization: `Bot ${import.meta.env.VITE_DISCORD_BOT_TOKEN}` }, + // }); - if (error) { - console.log(error); - return { success: false, message: "Error on discord api request!" }; - } + // if (guildsRequest.error || channelsRequest.error) { + // console.log(guildsRequest.error, channelsRequest.error, location.pathname); + // return { + // success: false, + // message: "Error on one of the discord api requests!", + // }; + // } - const guild = guilds?.find((e) => e.id === id); + // const guild = guildsRequest.data?.find((e) => e.id === id); + // const guild = [].find((e) => e.id === id); - if (!guild) - return { - success: false, - message: "User is in no such guild with requested id!", - }; - if (!(parseInt(guild.permissions) & (1 << 5))) - return { - success: false, - message: - "User is no MANAGE_GUILD permissions on this guild with requested id!", - }; + // if (!guild) + // return { + // success: false, + // message: "User is in no such guild with requested id!", + // }; + // if (!(parseInt(guild.permissions) & (1 << 5))) + // return { + // success: false, + // message: + // "User is no MANAGE_GUILD permissions on this guild with requested id!", + // }; - return { - success: true, - guild: { - id: guild.id, - name: guild.name, - icon: guild.icon, + // let channels: ReturnType["guild"]["channels"] = []; + // channelsRequest.data?.forEach((channel) => { + // if (channel.type !== 0) return; + // channels.push({ + // id: channel.id, + // name: channel.name, + // }); + // }); + + const channels = [ + { + id: "1", + name: "first", }, - // guild: guilds - // .filter((e: any) => e.permissions & (1 << 5)) - // .map((e: any) => e.name), - tzNames: moment.tz.names(), - }; + + { + id: "2", + name: "second", + }, + { + id: "3", + name: "third", + }, + ]; + + return new Promise((res) => { + setTimeout( + () => + res({ + success: true, + guild: { + id: "598539452343648256", + name: "test Server", + icon: undefined, + channel: "1162917335275950180", + channels, + }, + tzNames: moment.tz.names(), + }), + 3000, + ); + }); }; function config() { const params = useParams(); const navigator = useNavigate(); + const location = useLocation(); let timezoneRef: HTMLInputElement; let timePlanningRef: HTMLInputElement; + let channelRef: HTMLSelectElement; let pingableRolesRef: HTMLInputElement; const [timezone, setTimezone] = createSignal(guessTZ()); - const [payload] = createResource(params.guildId, async (id) => { - const payload = await getPayload(id); + const [payload] = createResource( + params.guildId, + async (id) => { + const payload = await getPayload(id); - if (!payload.success) { - console.log(payload.message, "No success"); - navigator("/config", { replace: false }); - return initialValue(params); - } - return payload; - }); - const guild = () => payload()?.guild ?? initialValue(params).guild; - const tzNames = () => payload()?.tzNames ?? []; + if (!payload.success) { + console.log(location.pathname, payload.message, "No success"); + navigator("/config", { replace: false }); + return initialValue(params); + } + return payload; + }, + { initialValue: initialValue(params) }, + ); + const guild = () => payload().guild; + const tzNames = () => payload().tzNames; const [config, setConfig] = createStore({ features: { timePlanning: { enabled: false, + channelId: "833442323160891452", pingableRoles: false, }, }, }); - createEffect(() => console.log(payload())); + createEffect(() => console.log(payload.loading, payload())); createEffect(() => console.log("timezone", timezone())); createEffect(() => console.log("timePlanning.enabled", config.features.timePlanning.enabled), ); + createEffect(() => + console.log( + "timePlanning.channelId", + config.features.timePlanning.channelId, + ), + ); createEffect(() => console.log( "timePlanning.pingableRoles", @@ -136,14 +188,28 @@ function config() { ), ); - createEffect(() => (timezoneRef.value = timezone())); - createEffect( - () => (timePlanningRef.checked = config.features.timePlanning.enabled), - ); - createEffect( - () => - (pingableRolesRef.checked = config.features.timePlanning.pingableRoles), - ); + createEffect(() => { + timezoneRef.value = timezone(); + }); + createEffect(() => { + timePlanningRef.checked = config.features.timePlanning.enabled; + }); + createEffect(() => { + const channelId = payload().guild.channel; + setConfig("features", "timePlanning", "channelId", channelId); + console.log(channelId, payload()); + if ( + !channelRef || + !channelId || + !payload().guild.channels.find((e) => e.id === channelId) + ) + return; + channelRef.value = channelId; + }); + createEffect(() => { + if (!pingableRolesRef) return; + pingableRolesRef.checked = config.features.timePlanning.pingableRoles; + }); return ( @@ -154,14 +220,15 @@ function config() { Server pfp -

    {guild()?.name ?? "li'l Judds home base"}

    +

    {guild().name}

    @@ -200,12 +267,12 @@ function config() {

    Configure the features of the bot

    - + setConfig( + "features", + "timePlanning", + "channelId", + e.target.value, + ) + } + > + + + {(channel) => ( + + )} +
    ({ - success: null as boolean | null, - guilds: [] as { - id: string; - name: string; - icon: string | null | undefined; - }[], -}); +// const initialValue = () => ({ +// success: null as boolean | null, +// guilds: [] as { +// id: string; +// name: string; +// icon: string | null | undefined; +// }[], +// }); -const getPayload = async (): Promise< - | { success: false; message: string } - | (ReturnType & { success: true }) -> => { - ("use server"); - const event = getRequestEvent(); - if (!event) return { success: false, message: "No request event!" }; +// const getPayload = async (): Promise< +// | { success: false; message: string } +// | (ReturnType & { success: true }) +// > => { +// "use server"; +// const location = useLocation(); +// const event = getRequestEvent(); +// if (!event) return { success: false, message: "No request event!" }; - const session = await getSession(event.request, authOptions); - if (!session?.user?.id) - return { success: false, message: "No user with id!" }; +// const session = await getSession(event.request, authOptions); +// if (!session?.user?.id) +// return { success: false, message: "No user with id!" }; - const { DISCORD_ACCESS_TOKEN } = ( - await db - .selectDistinct({ DISCORD_ACCESS_TOKEN: accounts.access_token }) - .from(accounts) - .where(eq(accounts.userId, session.user?.id)) - .limit(1) - .execute() - )[0]; - if (!DISCORD_ACCESS_TOKEN) - return { success: false, message: "No discord access token!" }; +// const { DISCORD_ACCESS_TOKEN } = ( +// await db +// .selectDistinct({ DISCORD_ACCESS_TOKEN: accounts.access_token }) +// .from(accounts) +// .where(eq(accounts.userId, session.user?.id)) +// .limit(1) +// .execute() +// )[0]; +// if (!DISCORD_ACCESS_TOKEN) +// return { success: false, message: "No discord access token!" }; - const { GET } = createClient({ - baseUrl: "https://discord.com/api/v10", - }); - const { data: guilds, error } = await GET("/users/@me/guilds", { - headers: { Authorization: `Bearer ${DISCORD_ACCESS_TOKEN}` }, - }); +// const { GET } = createClient({ +// baseUrl: "https://discord.com/api/v10", +// }); +// const { data: guilds, error } = await GET("/users/@me/guilds", { +// headers: { Authorization: `Bearer ${DISCORD_ACCESS_TOKEN}` }, +// }); - console.log("guilds", guilds); +// console.log("guilds", guilds, location.pathname); - if (error) { - console.log(error); - return { success: false, message: "Error on discord api request!" }; - } +// if (error) { +// console.log(error, location.pathname); +// return { success: false, message: "Error on discord api request!" }; +// } - return { - success: true, - guilds: - guilds - ?.filter((e) => parseInt(e.permissions) & (1 << 5)) - .map(({ id, name, icon }) => ({ id, name, icon })) ?? [], - }; -}; +// return { +// success: true, +// guilds: +// guilds +// ?.filter((e) => parseInt(e.permissions) & (1 << 5)) +// .map(({ id, name, icon }) => ({ id, name, icon })) ?? [], +// }; +// }; function index() { - const navigator = useNavigate(); + // const navigator = useNavigate(); + // const location = useLocation(); - const [payload] = createResource(async () => { - const payload = await getPayload(); + // const [payload] = createResource(async () => { + // const payload = await getPayload(); - if (!payload.success) { - console.log(payload.message, "No success"); - navigator("/", { replace: false }); - return initialValue(); - } - console.log("success"); - return payload; - }); + // if (!payload.success) { + // console.log(location.pathname, payload.message, "No success"); + // navigator("/", { replace: false }); + // return initialValue(); + // } + // console.log(location.pathname, "success"); + // return payload; + // }); + // createEffect(() => console.log(payload()?.guilds, payload()?.guilds.length)); + // createRenderEffect(() => + // console.log(payload()?.guilds, payload()?.guilds.length), + // ); - const icons = [faPlus, faCircleExclamation, faBadgeCheck]; - const colors = [undefined, "orange", "green"]; + // const icons = [faPlus, faCircleExclamation, faBadgeCheck]; + // const colors = [undefined, "orange", "green"]; return (

    Configure li'l Judd in

    - - {(guild, i) => ( - - Server pfp -

    {guild.name}

    - -
    - )} -
    + {/* + + {(guild, i) => { + return ( + + Server pfp +

    {guild.name}

    +
    + ); + }} +
    +
    */}
    ); diff --git a/src/routes/contact.tsx b/src/routes/contact.tsx deleted file mode 100644 index cc3508c..0000000 --- a/src/routes/contact.tsx +++ /dev/null @@ -1,26 +0,0 @@ -import Layout from "~/components/Layout"; -import "../styles/pages/contact.scss"; - -function contact() { - return ( - -

    Contact

    -
    - - Email - contact@moonleay.net - - - Discord - @moonleay - - - discord - li'l Judd's home base - -
    -
    - ); -} - -export default contact; diff --git a/src/routes/features.tsx b/src/routes/features.tsx deleted file mode 100644 index 936fbf5..0000000 --- a/src/routes/features.tsx +++ /dev/null @@ -1,51 +0,0 @@ -import ImageSection from "~/components/ImageSection"; -import Layout from "~/components/Layout"; -import "../styles/pages/features.scss"; - -function features() { - return ( - -

    Features

    -
    - - - - - -
    -
    - ); -} - -export default features; diff --git a/src/routes/how-do-i.tsx b/src/routes/how-do-i.tsx deleted file mode 100644 index 4765849..0000000 --- a/src/routes/how-do-i.tsx +++ /dev/null @@ -1,62 +0,0 @@ -import Layout from "~/components/Layout"; -import "../styles/pages/how-do-i.scss"; - -function howDoI() { - return ( - -

    How do I...?

    -
    -

    .. enable / disable certain features?

    -

    - Features can be enabled and disables using the /feature - command. -
    - Example: -

    -
    - A screenshot of the example in Discord. - A screenshot of the example in Discord. - {/*

    /feature feature:Time Planning Feature set:Enable channel:#ich-kann-heute

    */} -
    -
    -
    -

    .. create a match?

    -

    - You can create a match time using the /match command. -
    - Example: -

    -
    - A screenshot of the example in Discord. - A screenshot of the example in Discord. - {/*

    /match match:Ladder Match timestamp:24.12.2069 04:20 opponent:Forbidden

    */} -
    -
    -
    -

    - Is something missing here? -
    - Please contact me! -

    -
    -
    - ); -} - -export default howDoI; diff --git a/src/routes/imprint.tsx b/src/routes/imprint.tsx deleted file mode 100644 index 094eb3e..0000000 --- a/src/routes/imprint.tsx +++ /dev/null @@ -1,62 +0,0 @@ -import Layout from "~/components/Layout"; -import "../styles/pages/imprint.scss"; - -function imprint() { - return ( - -
    -

    Imprint

    -
    - -

    Contact me

    -
    -
    -
    -

    Liability for contents

    -

    - As a service provider, we are responsible for our own content on - these pages in accordance with general legislation pursuant to - Section 7 (1) of the German Telemedia Act (TMG). According to §§ 8 - to 10 TMG, however, we are not obligated as a service provider to - monitor transmitted or stored third-party information or to - investigate circumstances that indicate illegal activity. - Obligations to remove or block the use of information under the - general laws remain unaffected. However, liability in this regard is - only possible from the point in time at which a concrete - infringement of the law becomes known. If we become aware of any - such infringements, we will remove the relevant content immediately. -

    -
    - Source:{" "} - - eRecht24 - -
    -
    -
    -

    Liability for links

    -

    - Our offer contains links to external websites of third parties, on - whose contents we have no influence. Therefore, we cannot assume any - liability for these external contents. The respective provider or - operator of the pages is always responsible for the content of the - linked pages. The linked pages were checked for possible legal - violations at the time of linking. Illegal contents were not - recognizable at the time of linking. However, a permanent control of - the contents of the linked pages is not reasonable without concrete - evidence of a violation of the law. If we become aware of any - infringements, we will remove such links immediately.{" "} -

    -
    - Source:{" "} - - eRecht24 - -
    -
    -
    -
    - ); -} - -export default imprint; diff --git a/src/routes/privacy-policy.tsx b/src/routes/privacy-policy.tsx deleted file mode 100644 index 874fa78..0000000 --- a/src/routes/privacy-policy.tsx +++ /dev/null @@ -1,178 +0,0 @@ -import Layout from "~/components/Layout"; -import "../styles/pages/privacy-policy.scss"; - -function privacyPolicy() { - return ( - -
    -

    Privacy Policy for li'l Judd

    -

    Last updated: 2023-12-05

    -
    -
    -

    1. Introduction

    -

    - Welcome to li'l Judd! This Privacy Policy explains how we - collect, use, disclose, and safeguard your personal information when - you use our Discord bot service. -

    -
    -
    -

    2. Data Controller

    -

    - The data controller for the processing of your personal data is - moonleay. -
    - Please note that "moonleay" is primarily used as a username and may - not directly reflect my legal or real-world identity. -
    - You can reach me here. -

    -
    -
    -

    3. Information We Collect

    -

    3.1 Discord User Data

    -

    - We may collect and process the following (personal) data related to - your Discord account & guilds: -

    -
      -
    • -

      - Discord User ID

      -
    • -
    • -

      - Discord username, discriminator and IDs of users

      -
    • -
    • -

      - Guild name and ID

      -
    • -
    • -

      - Channel names and IDs of channels with active features

      -
    • -
    • -

      - Message IDs of the bot messages

      -
    • -
    • -

      - Role IDs of created roles

      -
    • -
    -

    3.2 Usage Data

    -

    - We may collect information on how you interact with our bot, including - but not limited to: -

    -
      -
    • -

      - Commands issued

      -
    • -
    • -

      - Server and channel information

      -
    • -
    • -

      - Timestamps of interactions

      -
    • -
    -
    -
    -

    4. How we use your Information

    -

    We process your personal data for the following purposes:

    -
      -
    • -

      - To provide and maintain the bot service.

      -
    • -
    • -

      - To improve, customize, and optimize our bot.

      -
    • -
    • -

      - To respond to your requests, comments, or inquiries.

      -
    • -
    • -

      - To comply with legal obligations.

      -
    • -
    -
    -
    -

    5. Legal Basis for Processing

    -

    We process your personal data on the following legal bases:

    -
      -
    • -

      - - Consent: You have given your consent for the processing of your - personal data for one or more specific purposes. -

      -
    • -
    • -

      - - Performance of a contract: The processing is necessary for the - performance of the agreement between you and us. -

      -
    • -
    -
    -
    -

    6. Data Sharing

    -

    - We do not sell, trade, or otherwise transfer your personal information - to third parties. However, we may share your information with: -

    -
      -
    • -

      - - Third-party service providers involved in the operation and - maintenance of the bot. -

      -
    • -
    -
    -
    -

    7. Data Security

    -

    - We implement reasonable security measures to protect your personal - information from unauthorized access, disclosure, alteration, and - destruction. -

    -
    -
    -

    8. Your Rights

    -

    You have the following rights regarding your personal data:

    -
      -
    • -

      - - Right to withdraw consent: You have the right to withdraw your - consent at any time. You can do this by contacting us at - contact@moonleay.net. -

      -
    • -
    • -

      - - Right to rectification: You can request corrections to - inaccurate or incomplete information. -

      -
    • -
    • -

      - - Right to erasure: You can request the deletion of your personal - data. -

      -
    • -
    -
    -
    -

    9. Changes to this Privacy Policy

    -

    - We may update this Privacy Policy to reflect changes in our practices. - The updated version will be posted on - https://liljudd.ink/privacy-policy. -

    -
    -
    -

    10. Contact Information

    -

    - If you have any questions or concerns about this Privacy Policy, - please contact us at contact@moonleay.net. -

    -
    -
    - ); -} - -export default privacyPolicy; diff --git a/src/routes/stack.tsx b/src/routes/stack.tsx deleted file mode 100644 index 380d4e4..0000000 --- a/src/routes/stack.tsx +++ /dev/null @@ -1,55 +0,0 @@ -import Layout from "~/components/Layout"; -import "../styles/pages/stack.scss"; - -function stack() { - return ( - -

    The Stack

    -
    - Kotlin 'K' logo -
    -

    The Kotlin programming language

    -

    - A programming language, which runs in the JVM. Also my main - language. -

    -
    -
    -
    - The Kord logo -
    -

    The Kord library

    -

    A Kotlin library for creating Discord bots. Pretty bare bones.

    -
    -
    -
    - The Kord-Extensions logo -
    -

    The Kord Extensions library

    -

    A Kotlin library to improve the Kord experience.

    -
    -
    -
    - The PostgreSQL elephant -
    -

    The PostgreSQL database

    -

    - A fast and reliable database. Also something, which I already used - beforehand. -

    -
    -
    -
    -

    - To view all used libraries and their licenses, check the{" "} - Acknowledgements. -

    -
    -
    - ); -} - -export default stack; diff --git a/src/routes/terms-of-service.tsx b/src/routes/terms-of-service.tsx deleted file mode 100644 index 8e78359..0000000 --- a/src/routes/terms-of-service.tsx +++ /dev/null @@ -1,95 +0,0 @@ -import Layout from "~/components/Layout"; -import "../styles/pages/terms-of-service.scss"; - -function termsOfService() { - return ( - -

    Terms of Service

    -
    -

    Usage Agreement

    -

    - By inviting the bot and using its features (commands, planning system) - are you agreeing to the below mentioned Terms and Privacy Policy - (Policy) of the bot. -
    - You acknowledge that you have the privilege to use the bot freely on - any Discord Server (Server) you share with it, that you can invite it - to any Server that you have "Manage Server" rights for and that this - privilege might get revoked for you, if you're subject of breaking the - terms and/or policy of this bot, or the{" "} - - Terms of Service - - ,{" "} - - Privacy Policy - {" "} - and/or{" "} - - Community Guidelines - {" "} - of{" "} - - Discord Inc - - .
    - Through Inviting the bot may it collect specific data as described in - its Policy. -
    - The intended usage of this data is for core functionalities of the bot - such as command handling, guild-specific settings and the - time-planning system. -
    -

    -
    -
    -

    Intended Age

    -

    - The bot may not be used by individuals under the minimal age described - in Discord's Terms of Service. -
    - Doing so will be seen as a violation of these terms and will result in - a removal of the bot from any servers you own. -
    -

    -
    -
    -

    Affiliation

    -

    - The Bot is not affiliated with, supported or made by Discord Inc. -
    - Any direct connection to Discord or any of its Trademark objects is - purely coincidental. We do not claim to have the copyright ownership - of any of Discord's assets, trademarks or other intellectual property. -
    -

    -
    -
    -

    Liability

    -

    - The owner of the bot may not be made liable for individuals breaking - these Terms at any given time. -
    - He has faith in the end users being truthfull about their information - and not misusing this bot or the services of Discord Inc in a - malicious way. -
    - We reserve the right to update these terms at our own discretion, - giving you a 1-Week (7 days) period to opt out of these terms if - you're not agreeing with the new changes. You may opt out by Removing - the bot from any Server you have the rights for. -

    -
    -
    -

    Contact

    -

    - People may get in contact through e-mail at contact@moonleay.net, or - through the official Support Discord of the Bot. Other ways of support - may be provided but aren't guaranteed. -

    -
    -
    - ); -} - -export default termsOfService; diff --git a/src/types/env.d.ts b/src/types/env.d.ts index 506c5b4..9395712 100644 --- a/src/types/env.d.ts +++ b/src/types/env.d.ts @@ -1,9 +1,10 @@ /// interface ImportMetaEnv { - readonly VITE_DISCORD_CLIENT: string; + readonly VITE_DISCORD_CLIENT_ID: string; readonly VITE_DISCORD_CLIENT_SECRET: string; readonly VITE_DISCORD_BOT_TOKEN: string; + readonly VITE_DISCORD_BOT_PERMISSIONS: string; readonly VITE_AUTH_SECRET: string; readonly VITE_AUTH_REDIRECT_PROXY_URL: string | undefined; @@ -11,6 +12,7 @@ interface ImportMetaEnv { readonly VITE_DATABASE_URL: string; } +// eslint-disable-next-line no-unused-vars interface ImportMeta { readonly env: ImportMetaEnv; }