upgrades to guide and frontpage

This commit is contained in:
Jacob Nguyen
2023-07-29 11:09:03 -05:00
parent d531eb7340
commit e10e6cbd2f
6 changed files with 59 additions and 8 deletions

View File

@@ -4,6 +4,9 @@ Welcome to our official guide. This guide will go through all the core features
- 💖 Thank you for choosing sern to be your framework!
- Teaching the discord.js library and / or Javascript / Typescript is out of scope of this project, so the documentation assumes you already know these elements.
- [discord.js](https://discord.js.org/#/)
- [javascript](https://nodejs.dev/en/learn/)
- [typescript](https://www.typescriptlang.org/docs/)
- discord.js v14 is the only supported library at the moment
@@ -12,11 +15,13 @@ Welcome to our official guide. This guide will go through all the core features
* How to use sern with the [CLI](walkthrough/cli.md)
* [Your first command](walkthrough/first-command.md)
* [The Context class](walkthrough/first-command.md#context-class)
* [Autocomplete](walkthrough/autocomplete)
* [Services](walkthrough/services)
* [dependency injection](walkthrough/dependency-injection)
### Working with plugins
* [Plugins](walkthrough/plugins.md)
- [Command Plugins](walkthrough/plugins.md#command-plugins)
- [Event Plugins](walkthrough/plugins.md#event-plugins)
- [Init Plugins](walkthrough/plugins.md#command-plugins)
- [Control Plugins](walkthrough/plugins.md#event-plugins)
### Events
* [The SernEmitter class](walkthrough/sern-emitter.md)
* [Your first event](walkthrough/first-event.md)

View File

@@ -0,0 +1,45 @@
---
sidebar_position: 7
---
# Autocomplete
Autocomplete is a special interaction where it can happen on multiple options on a single command. We've handled this with a simple
tree search algorithm in a nested options tree.
## Example
```ts title="src/commands/cheese.ts" {11-18}
export default commandModule({
type: CommandType.Slash,
description: "show me cheese",
options: [
{
name: "list",
type: ApplicationCommandOptionType.String,
description: "pick a cheese to show",
required: true,
autocomplete: true,
command: {
onEvent: [],
execute: (ctx) => {
const focus = ctx.options.getFocused();
ctx.respond(['gouda', 'parmesan', 'harvati']
.map((cheese) => ({ name: cheese, value: cheese })));
}
}
}
],
execute: (ctx, [, args]) => {
const cheese = args.getString('list', true);
ctx.reply('selected cheese');
}
})
```
Sern will handle autocomplete interactions at arbitrary depths and subcommand levels.

View File

@@ -12,7 +12,7 @@ This walkthrough will be written in [TypeScript](https://www.typescriptlang.org/
- *Modularity*: sern is built with modularity in mind. You can swap pieces and parts easily.
- *Familiar*: commands and structures are similar to classic v12 handlers and the official discord.js command handler guide, while packing many features
- *Concise*: Too much code is a liability. with sern, write more for less 🤯
- *Concise*: Too much code is a liability. with sern, write less for more 🤯
### Using @sapphire/framework
@@ -40,7 +40,6 @@ import { commandModule, CommandType } from '@sern/handler'
import { publish } from '../plugins';
export default commandModule({
//This acts as both a slash command AND text command
type: CommandType.Both,
plugins: [publish()],
description: 'Pong!',
@@ -49,3 +48,4 @@ export default commandModule({
}
})
```
Keep in mind the above example acts as both a slash command AND text command

View File

@@ -1,5 +1,5 @@
---
sidebar_position: 8
sidebar_position: 9
---
# Good to know

View File

@@ -1,5 +1,5 @@
---
sidebar_position: 6
sidebar_position: 8
---
# The SernEmitter class