From 01cdce492e17d56fdbceaa61dd73e57596b89540 Mon Sep 17 00:00:00 2001 From: Paul Date: Thu, 12 Aug 2021 16:07:41 +0100 Subject: [PATCH] Add bot invite menu. --- external/lang | 2 +- src/pages/RevoltApp.tsx | 2 + src/pages/invite/InviteBot.tsx | 80 +++++++++++++++++++++++++++++ src/pages/settings/panes/MyBots.tsx | 10 ++++ 4 files changed, 93 insertions(+), 1 deletion(-) create mode 100644 src/pages/invite/InviteBot.tsx diff --git a/external/lang b/external/lang index cec5d62b..b27044c3 160000 --- a/external/lang +++ b/external/lang @@ -1 +1 @@ -Subproject commit cec5d62b11fa52bafea39ee905a8354fb840a078 +Subproject commit b27044c332ca419d22edbe9e7bf465a665398999 diff --git a/src/pages/RevoltApp.tsx b/src/pages/RevoltApp.tsx index bc309c30..7d861746 100644 --- a/src/pages/RevoltApp.tsx +++ b/src/pages/RevoltApp.tsx @@ -20,6 +20,7 @@ import Developer from "./developer/Developer"; import Friends from "./friends/Friends"; import Home from "./home/Home"; import Invite from "./invite/Invite"; +import InviteBot from "./invite/InviteBot"; import ChannelSettings from "./settings/ChannelSettings"; import ServerSettings from "./settings/ServerSettings"; import Settings from "./settings/Settings"; @@ -119,6 +120,7 @@ export default function App() { + diff --git a/src/pages/invite/InviteBot.tsx b/src/pages/invite/InviteBot.tsx new file mode 100644 index 00000000..dd7f72a0 --- /dev/null +++ b/src/pages/invite/InviteBot.tsx @@ -0,0 +1,80 @@ +import { useParams } from "react-router-dom"; +import { Route } from "revolt.js/dist/api/routes"; + +import { useEffect, useState } from "preact/hooks"; + +import { useClient } from "../../context/revoltjs/RevoltClient"; + +import UserIcon from "../../components/common/user/UserIcon"; +import Button from "../../components/ui/Button"; +import ComboBox from "../../components/ui/ComboBox"; +import Overline from "../../components/ui/Overline"; +import Preloader from "../../components/ui/Preloader"; + +export default function InviteBot() { + const { id } = useParams<{ id: string }>(); + const client = useClient(); + const [data, setData] = + useState["response"]>(); + + useEffect(() => { + client.bots.fetchPublic(id).then(setData); + // eslint-disable-next-line + }, []); + + const [server, setServer] = useState("none"); + const [group, setGroup] = useState("none"); + + return ( +
+ {typeof data === "undefined" && } + {data && ( + <> + +

{data.username}

+ {data.description &&

{data.description}

} + Add to server + setServer(e.currentTarget.value)}> + + {[...client.servers.values()].map((server) => ( + + ))} + + + Add to group + setGroup(e.currentTarget.value)}> + + {[...client.channels.values()] + .filter((x) => x.channel_type === "Group") + .map((channel) => ( + + ))} + + + + )} +
+ ); +} diff --git a/src/pages/settings/panes/MyBots.tsx b/src/pages/settings/panes/MyBots.tsx index 14b8df9c..5e558954 100644 --- a/src/pages/settings/panes/MyBots.tsx +++ b/src/pages/settings/panes/MyBots.tsx @@ -3,6 +3,7 @@ import { Bot } from "revolt-api/types/Bots"; import { useEffect, useState } from "preact/hooks"; +import { useIntermediate } from "../../../context/intermediate/Intermediate"; import { useClient } from "../../../context/revoltjs/RevoltClient"; import UserShort from "../../../components/common/user/UserShort"; @@ -77,6 +78,7 @@ export const MyBots = observer(() => { }, []); const [name, setName] = useState(""); + const { writeClipboard } = useIntermediate(); return (
@@ -142,6 +144,14 @@ export const MyBots = observer(() => { }> delete +
); })}