feat: Add type coercion section with code example and styling

This commit is contained in:
2025-02-23 00:24:20 -06:00
parent aab2f7a546
commit ddfcfa798a
3 changed files with 102 additions and 1 deletions
+18
View File
@@ -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);
}
});`;