import { observer } from "mobx-react-lite"; 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"; 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"; interface Data { _id: string; username: string; public: boolean; interactions_url?: string; } 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 { writeClipboard } = 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 (

token:{" "} {bot.token}

); })}
); });