mirror of
https://github.com/revoltchat/revite.git
synced 2025-01-11 23:11:23 -05:00
Add bot invite menu.
This commit is contained in:
parent
237a0024df
commit
01cdce492e
4 changed files with 93 additions and 1 deletions
2
external/lang
vendored
2
external/lang
vendored
|
@ -1 +1 @@
|
|||
Subproject commit cec5d62b11fa52bafea39ee905a8354fb840a078
|
||||
Subproject commit b27044c332ca419d22edbe9e7bf465a665398999
|
|
@ -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() {
|
|||
<Route path="/dev" component={Developer} />
|
||||
<Route path="/friends" component={Friends} />
|
||||
<Route path="/open/:id" component={Open} />
|
||||
<Route path="/bot/:id" component={InviteBot} />
|
||||
<Route path="/invite/:code" component={Invite} />
|
||||
<Route path="/" component={Home} />
|
||||
</Switch>
|
||||
|
|
80
src/pages/invite/InviteBot.tsx
Normal file
80
src/pages/invite/InviteBot.tsx
Normal file
|
@ -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<Route<"GET", "/bots/id/invite">["response"]>();
|
||||
|
||||
useEffect(() => {
|
||||
client.bots.fetchPublic(id).then(setData);
|
||||
// eslint-disable-next-line
|
||||
}, []);
|
||||
|
||||
const [server, setServer] = useState("none");
|
||||
const [group, setGroup] = useState("none");
|
||||
|
||||
return (
|
||||
<div style={{ padding: "6em" }}>
|
||||
{typeof data === "undefined" && <Preloader type="spinner" />}
|
||||
{data && (
|
||||
<>
|
||||
<UserIcon size={64} attachment={data.avatar} />
|
||||
<h1>{data.username}</h1>
|
||||
{data.description && <p>{data.description}</p>}
|
||||
<Overline type="subtle">Add to server</Overline>
|
||||
<ComboBox
|
||||
value={server}
|
||||
onChange={(e) => setServer(e.currentTarget.value)}>
|
||||
<option value="none">un selected</option>
|
||||
{[...client.servers.values()].map((server) => (
|
||||
<option value={server._id} key={server._id}>
|
||||
{server.name}
|
||||
</option>
|
||||
))}
|
||||
</ComboBox>
|
||||
<Button
|
||||
contrast
|
||||
onClick={() =>
|
||||
group !== "none" &&
|
||||
client.bots.invite(data._id, { server })
|
||||
}>
|
||||
add
|
||||
</Button>
|
||||
<Overline type="subtle">Add to group</Overline>
|
||||
<ComboBox
|
||||
value={group}
|
||||
onChange={(e) => setGroup(e.currentTarget.value)}>
|
||||
<option value="none">un selected</option>
|
||||
{[...client.channels.values()]
|
||||
.filter((x) => x.channel_type === "Group")
|
||||
.map((channel) => (
|
||||
<option value={channel._id} key={channel._id}>
|
||||
{channel.name}
|
||||
</option>
|
||||
))}
|
||||
</ComboBox>
|
||||
<Button
|
||||
contrast
|
||||
onClick={() =>
|
||||
group !== "none" &&
|
||||
client.bots.invite(data._id, { group })
|
||||
}>
|
||||
add
|
||||
</Button>
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
|
@ -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 (
|
||||
<div>
|
||||
|
@ -142,6 +144,14 @@ export const MyBots = observer(() => {
|
|||
}>
|
||||
delete
|
||||
</Button>
|
||||
<Button
|
||||
onClick={() =>
|
||||
writeClipboard(
|
||||
`${window.origin}/bot/${bot._id}`,
|
||||
)
|
||||
}>
|
||||
copy invite link
|
||||
</Button>
|
||||
</div>
|
||||
);
|
||||
})}
|
||||
|
|
Loading…
Reference in a new issue