2025-02-22 23:00:37 -06:00
|
|
|
'use client';
|
|
|
|
|
|
2025-02-22 23:06:37 -06:00
|
|
|
import { useRef } from 'react';
|
|
|
|
|
import Editor from "@monaco-editor/react";
|
2025-02-22 23:00:37 -06:00
|
|
|
import styles from './CodeExample.module.css';
|
|
|
|
|
|
|
|
|
|
const exampleCode = `\
|
|
|
|
|
import { Client, type Context } from 'unicord';
|
|
|
|
|
|
|
|
|
|
// Initialize and configure
|
|
|
|
|
const client = new Client({
|
|
|
|
|
token: '<token>',
|
|
|
|
|
application_id: '<application_id>',
|
|
|
|
|
intents: [
|
|
|
|
|
Intent.GUILDS,
|
|
|
|
|
Intent.GUILD_MESSAGES,
|
|
|
|
|
Intent.GUILD_MESSAGE_REACTIONS,
|
|
|
|
|
Intent.MESSAGE_CONTENT
|
|
|
|
|
],
|
|
|
|
|
prefix: '??'
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// Register a command
|
|
|
|
|
client.chatCommands.register('ping', (context: Context, args) => {
|
|
|
|
|
context.reply('Pong!', true);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// Connect
|
|
|
|
|
client.connect();`;
|
|
|
|
|
|
|
|
|
|
export default function CodeExample() {
|
2025-02-22 23:06:37 -06:00
|
|
|
return (
|
|
|
|
|
<div className={styles.editorContainer}>
|
|
|
|
|
<Editor
|
2025-02-22 23:11:34 -06:00
|
|
|
height="100%"
|
2025-02-22 23:06:37 -06:00
|
|
|
defaultLanguage="typescript"
|
|
|
|
|
defaultValue={exampleCode}
|
|
|
|
|
theme="vs-dark"
|
|
|
|
|
options={{
|
|
|
|
|
readOnly: true,
|
|
|
|
|
minimap: { enabled: false },
|
|
|
|
|
fontSize: 14,
|
|
|
|
|
lineNumbers: 'on',
|
|
|
|
|
scrollBeyondLastLine: false,
|
|
|
|
|
roundedSelection: false,
|
|
|
|
|
padding: { top: 16, bottom: 16 },
|
|
|
|
|
automaticLayout: true,
|
|
|
|
|
}}
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
|
|
|
|
);
|
2025-02-22 23:00:37 -06:00
|
|
|
}
|