Skip to content

Commit

Permalink
🎉 feat: add simple output for Discord bot command
Browse files Browse the repository at this point in the history
  • Loading branch information
casperiv0 committed Nov 29, 2022
1 parent 564111a commit 5164569
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { SettingsFormField } from "components/form/SettingsFormField";
import { SettingsTabs } from "src/pages/admin/manage/cad-settings";
import { toastMessage } from "lib/toastMessage";
import type { DeleteCADApiTokenData, PutCADApiTokenData } from "@snailycad/types/api";
import { getAPIUrl } from "@snailycad/utils/api-url";

export function ApiTokenTab() {
const common = useTranslations("Common");
Expand Down Expand Up @@ -65,6 +66,9 @@ export function ApiTokenTab() {
token: cad?.apiToken?.token ?? "",
};

const apiURL = getAPIUrl();
const discordCommand = `/config set api-url: ${apiURL} api-token: ${cad?.apiToken?.token ?? ""}`;

return (
<TabsContent aria-label="API Token" value={SettingsTabs.APIToken}>
<h2 className="mt-2 text-2xl font-semibold">Public API access</h2>
Expand All @@ -79,6 +83,26 @@ export function ApiTokenTab() {
<PasswordInput onClick={handleClick} readOnly value={values.token} />
</SettingsFormField>

<SettingsFormField
description={
<>
This command can be used when using the{" "}
<a
rel="noreferrer"
target="_blank"
href="https://cad-docs.caspertheghost.me/docs/discord-integration/discord-bot"
className="underline"
>
Discord bot integration
</a>
. Simply paste it into Discord.
</>
}
label={"Discord bot integration command"}
>
<PasswordInput onClick={handleClick} readOnly value={discordCommand} />
</SettingsFormField>

<SettingsFormField
action="checkbox"
description={
Expand Down
2 changes: 1 addition & 1 deletion apps/client/src/pages/admin/manage/cad-settings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export default function CadSettings() {
{ name: t("FEATURES"), value: SettingsTabs.Features },
{ name: t("MISC_SETTINGS"), value: SettingsTabs.MiscSettings },
{ name: "Auto set user properties", value: SettingsTabs.AutoSetProperties },
{ name: "Api Token", value: SettingsTabs.APIToken },
{ name: "API Token", value: SettingsTabs.APIToken },
{ name: "Discord Roles", value: SettingsTabs.DiscordRoles },
{ name: "Discord Webhooks", value: SettingsTabs.DiscordWebhooks },
];
Expand Down

0 comments on commit 5164569

Please sign in to comment.