import { Key, Clipboard, Globe } from "@styled-icons/boxicons-regular"; import { LockAlt } from "@styled-icons/boxicons-solid"; import { observer } from "mobx-react-lite"; import { Bot } from "revolt-api/types/Bots"; import styled from "styled-components"; import styles from "./Panes.module.scss"; import { Text } from "preact-i18n"; import { useEffect, useState } from "preact/hooks"; import { stopPropagation } from "../../../lib/stopPropagation"; import { useIntermediate } from "../../../context/intermediate/Intermediate"; import { useClient } from "../../../context/revoltjs/RevoltClient"; import Tooltip from "../../../components/common/Tooltip"; import UserIcon from "../../../components/common/user/UserIcon"; import Button from "../../../components/ui/Button"; import Checkbox from "../../../components/ui/Checkbox"; import InputBox from "../../../components/ui/InputBox"; import Overline from "../../../components/ui/Overline"; import Tip from "../../../components/ui/Tip"; import CategoryButton from "../../../components/ui/fluent/CategoryButton"; interface Data { _id: string; username: string; public: boolean; interactions_url?: string; } const BotBadge = styled.div` display: inline-block; height: 1.3em; padding: 0px 4px; font-size: 0.7em; user-select: none; margin-inline-start: 2px; text-transform: uppercase; color: var(--foreground); background: var(--accent); border-radius: calc(var(--border-radius) / 2); `; function BotEditor({ bot }: { bot: Data }) { const client = useClient(); const [data, setData] = useState(bot); function save() { const changes: Record = {}; if (data.username !== bot.username) changes.name = data.username; if (data.public !== bot.public) changes.public = data.public; if (data.interactions_url !== bot.interactions_url) changes.interactions_url = data.interactions_url; client.bots.edit(bot._id, changes); } return (

setData({ ...data, username: e.currentTarget.value }) } />

setData({ ...data, public: v })}> is public

interactions url: (reserved for the future)

setData({ ...data, interactions_url: e.currentTarget.value, }) } />

); } export const MyBots = observer(() => { const client = useClient(); const [bots, setBots] = useState(undefined); useEffect(() => { client.bots.fetchOwned().then(({ bots }) => setBots(bots)); // eslint-disable-next-line }, []); const [name, setName] = useState(""); const [editMode, setEditMode] = useState(false); const { writeClipboard, openScreen } = useIntermediate(); return (
This section is under construction. create a new bot

setName(e.currentTarget.value)} />

my bots {bots?.map((bot) => { const user = client.users.get(bot._id); return (
openScreen({ id: "profile", user_id: user!._id, }) } />
{bot.public ? : } {/* */}
} onClick={() => writeClipboard(bot.token)} description={ <> {"••••••••••••••••••••••••••••••••••••"}{" "} stopPropagation( ev, openScreen({ id: "token_reveal", token: bot.token, username: user!.username, }), ) }> } action={}> Token
); })}
); });