diff --git a/website/src/app/page.module.css b/website/src/app/page.module.css index 935f731..244a3e8 100644 --- a/website/src/app/page.module.css +++ b/website/src/app/page.module.css @@ -281,6 +281,67 @@ width: 100%; padding: 1rem; } + + .typeSection { + padding: 4rem 2rem; + } + + .typeContainer { + flex-direction: column; + gap: 2rem; + } + + .typeCode { + width: 100%; + } + + .typeText { + width: 100%; + padding: 1rem; + } +} + +.typeSection { + padding: 6rem 12em; + min-height: 50vh; + display: flex; + align-items: space; + justify-content: center; + position: relative; + background: var(--gray-alpha-100); + border-top: 1px solid var(--gray-alpha-200); +} + +.typeContainer { + display: flex; + gap: 4rem; + justify-content: space-between; + align-items: center; + width: 100%; +} + +.typeText { + flex: 1; +} + +.typeCode { + flex: 2; + width: 100%; + max-width: 780px; +} + +.typeText h2 { + color: #ff0080; + margin: 0 0 1.5rem 0; + font-size: 2rem; +} + +.typeText p { + color: #fff; + opacity: 0.8; + margin: 1rem 0; + font-size: 1.1rem; + line-height: 1.6; } .hydrationText p code { @@ -291,4 +352,4 @@ padding: 0.1em 0.2em; color: var(--foreground); border: 1px solid var(--gray-alpha-200); -} \ No newline at end of file +} diff --git a/website/src/app/page.tsx b/website/src/app/page.tsx index 731d064..86e91b0 100644 --- a/website/src/app/page.tsx +++ b/website/src/app/page.tsx @@ -67,6 +67,28 @@ export default function Home() { + +
+
+
+

Type Coercion

+

+ Unicord automatically handles type coercion for command arguments, + ensuring you always get the correct types in your handlers. Define your + command structure once, and get full type safety and autocompletion + throughout your codebase. +

+

+ In this example, the user argument is automatically typed + as a User object, providing access to all user properties + with full TypeScript support. +

+
+
+ +
+
+
); diff --git a/website/src/components/CodeExample.tsx b/website/src/components/CodeExample.tsx index e51792c..b8c17e4 100644 --- a/website/src/components/CodeExample.tsx +++ b/website/src/components/CodeExample.tsx @@ -70,3 +70,21 @@ client.chatCommands.register('ping', async (context: Context, args: any[]) => { // Edit the message to include the time await context.editMessage(response, \`Pong! Latency: \${time}ms\`); });`; + +export const typeCoercionExample = `\ +const avatarCommand = createCommandHandler({ + description: 'Get a users avatar', + args: [ + { + id: 'user', + name: 'user', + type: CommandOptionType.User, + description: 'The user to get the avatar for', + required: true + } + ], + execute: async (context: Context, args) => { + // Args will be typed here as { user: User } + context.reply(args.user.avatarURL); + } +});`;