Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion CNAME

This file was deleted.

35 changes: 35 additions & 0 deletions apps/nextra-docs/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# dependencies
/node_modules
/.pnp
.pnp.js

# testing
/coverage

# next.js
/.next/
/out/

# production
/build

# misc
.DS_Store
*.pem

# debug
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# local env files
.env*.local

# vercel
.vercel

# typescript
*.tsbuildinfo
next-env.d.ts
6 changes: 6 additions & 0 deletions apps/nextra-docs/next.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
const withNextra = require('nextra')({
theme: 'nextra-theme-docs',
themeConfig: './theme.config.tsx',
});

module.exports = withNextra();
25 changes: 25 additions & 0 deletions apps/nextra-docs/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"name": "commandkit-docs",
"version": "0.0.0",
"private": true,
"scripts": {
"dev": "next dev",
"build": "next build",
"start": "next start",
"lint": "next lint"
},
"dependencies": {
"@types/node": "^20.5.9",
"@types/react": "18.2.22",
"@types/react-dom": "18.2.7",
"autoprefixer": "10.4.16",
"next": "13.5.2",
"nextra": "^2.12.3",
"nextra-theme-docs": "^2.12.3",
"postcss": "8.4.30",
"react": "18.2.0",
"react-dom": "18.2.0",
"tailwindcss": "3.3.3",
"typescript": "^5.1.6"
}
}
13 changes: 13 additions & 0 deletions apps/nextra-docs/pages/_app.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import '../styles/globals.css';
import Head from 'next/head';

export default function Nextra({ Component, pageProps }) {
return (
<>
<Head>
<link rel="shortcut icon" type="image/png" href="/favicon.png" />
</Head>
<Component {...pageProps} />
</>
);
}
9 changes: 9 additions & 0 deletions apps/nextra-docs/pages/_meta.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"index": {
"title": "Home",
"type": "page"
},
"docs": "Documentation",
"typedef": "Typedefs",
"enums": "Enums"
}
7 changes: 7 additions & 0 deletions apps/nextra-docs/pages/docs/_meta.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"installation": "Installation",
"commandkit-setup": "CommandKit Setup",
"command-file-setup": "Commands Setup",
"event-file-setup": "Events Setup",
"validation-file-setup": "Validations Setup"
}
175 changes: 175 additions & 0 deletions apps/nextra-docs/pages/docs/command-file-setup.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,175 @@
import { Tabs } from 'nextra/components';

# Commands Setup

CommandKit supports both slash commands and context menu commands. Since both have the same triggers (interactions) and similar command structure, they are both stored and handled from the same commands directory.

## Slash Command

Here's an example `/ping` slash command which replies with "Pong!"

<Tabs items={['CommonJS', 'ESM', 'TypeScript']}>
<Tabs.Tab>
```js filename="commands/misc/ping.js" copy
module.exports = {
data: {
name: 'ping',
description: 'Pong!',
},

run: ({ interaction, client, handler }) => {
interaction.reply(`:ping_pong: Pong! ${client.ws.ping}ms`);
},

options: {
devOnly: true,
guildOnly: true,
userPermissions: ['Administrator', 'AddReactions'],
botPermissions: ['Administrator', 'AddReactions'],
deleted: false,
},
};
```
</Tabs.Tab>
<Tabs.Tab>
```js filename="commands/misc/ping.js" copy
export const data = {
name: 'ping',
description: 'Pong!',
},

export function run({ interaction, client, handler }) {
interaction.reply(`:ping_pong: Pong! ${client.ws.ping}ms`);
},

export const options = {
devOnly: true,
guildOnly: true,
userPermissions: ['Administrator', 'AddReactions'],
botPermissions: ['Administrator', 'AddReactions'],
deleted: false,
},
```
</Tabs.Tab>
<Tabs.Tab>
```ts filename="commands/misc/ping.ts" copy
import type { CommandData, SlashCommandProps, CommandOptions } from 'commandkit';

export const data: CommandData = {
name: 'ping',
description: 'Pong!',
},

export function run({ interaction, client, handler }: SlashCommandProps) {
interaction.reply(`:ping_pong: Pong! ${client.ws.ping}ms`);
},

export const options: CommandOptions = {
devOnly: true,
guildOnly: true,
userPermissions: ['Administrator', 'AddReactions'],
botPermissions: ['Administrator', 'AddReactions'],
deleted: false,
},
```
</Tabs.Tab>

</Tabs>

## Context Menu Command

Here's an example `content` command which replies with the content of the target message.

<Tabs items={['CommonJS', 'ESM', 'TypeScript']}>
<Tabs.Tab>
```js filename="commands/misc/content.js" copy
const { CommandType } = require('commandkit');

module.exports = {
data: {
name: 'content',
type: CommandType.Message,
},

run: ({ interaction, client, handler }) => {
interaction.reply(`The message is: ${interaction.targetMessage}`);
},

options: {
devOnly: true,
guildOnly: true,
userPermissions: ['Administrator', 'AddReactions'],
botPermissions: ['Administrator', 'AddReactions'],
deleted: false,
},
};
```
</Tabs.Tab>
<Tabs.Tab>
```js filename="commands/misc/content.js" copy
import { CommandType } from 'commandkit';

export const data = {
name: 'content',
type: CommandType.Message,
},

export function run({ interaction, client, handler }) {
interaction.reply(`The message is: ${interaction.targetMessage}`);
},

export const options = {
devOnly: true,
guildOnly: true,
userPermissions: ['Administrator', 'AddReactions'],
botPermissions: ['Administrator', 'AddReactions'],
deleted: false,
},
```
</Tabs.Tab>
<Tabs.Tab>
```ts filename="commands/misc/content.ts" copy
import { CommandType, type CommandData, type ContextMenuCommandProps, type CommandOptions } from 'commandkit';

export const data: CommandData = {
name: 'content',
type: CommandType.Message,
},

export function run({ interaction, client, handler }: ContextMenuCommandProps) {
interaction.reply(`The message is: ${interaction.targetMessage}`);
},

export const options: CommandOptions = {
devOnly: true,
guildOnly: true,
userPermissions: ['Administrator', 'AddReactions'],
botPermissions: ['Administrator', 'AddReactions'],
deleted: false,
},
```
</Tabs.Tab>

</Tabs>

## Properties and Methods

### `data`

- Type: [`CommandData`](/typedef/CommandData) | [`SlashCommandBuilder`](https://discord.js.org/docs/packages/builders/main/SlashCommandBuilder:Class) | [`ContextMenuCommandBuilder`](https://discord.js.org/docs/packages/builders/main/ContextMenuCommandBuilder:Class)

This property contains the command's structural information, and is required to register and handle commands.

### `run`

- Type: `void`

- Props Type: [`SlashCommandProps`](/typedef/SlashCommandProps) | [`ContextMenuCommandProps`](/typedef/ContextMenuCommandProps)

This function will be called when the command is executed.

### `options` (optional)

- Type: [`CommandOptions`](/typedef/CommandOptions)

This property contains the command's registration/handling behaviour.
Loading