mirror of
https://github.com/SrIzan10/sern-website.git
synced 2026-05-01 11:05:20 +00:00
upgrades to guide and frontpage
This commit is contained in:
@@ -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)
|
||||
|
||||
45
docs/guide/walkthrough/autocomplete.md
Normal file
45
docs/guide/walkthrough/autocomplete.md
Normal 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.
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
---
|
||||
sidebar_position: 8
|
||||
sidebar_position: 9
|
||||
---
|
||||
|
||||
# Good to know
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
---
|
||||
sidebar_position: 6
|
||||
sidebar_position: 8
|
||||
---
|
||||
|
||||
# The SernEmitter class
|
||||
|
||||
@@ -28,7 +28,8 @@ const FeatureList = [
|
||||
Svg: require('@site/static/img/fire-com.svg').default,
|
||||
description: (
|
||||
<>
|
||||
Code like a traditional command handler. Feels and looks like classic v12 command handlers.
|
||||
Code like a traditional command handler. Although not exactly the same, the api is easy to learn
|
||||
and resembles classic v12 command handlers.
|
||||
</>
|
||||
),
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user