add config and tasks (almost done)

This commit is contained in:
jacob
2024-07-17 00:09:49 -05:00
parent a1955894ee
commit 3fa02ec79a
9 changed files with 85 additions and 10 deletions

View File

@@ -2,7 +2,7 @@
title: Autocomplete
description: Implementing autocomplete in your commands
sidebar:
order: 7
order: 8
---
Autocomplete is a special interaction which can happen on multiple options can be suggested for a single command.

View File

@@ -2,7 +2,7 @@
title: Conclusion
description: Thank you for reading the sern guide
sidebar:
order: 8
order: 9
---
If you reached this far, thank you for reading!

View File

@@ -0,0 +1,60 @@
---
title: Config
description: Configure your bot
sidebar:
order: 2
---
Your app needs a way to store constants and required variables for the framework to work.
A project should look like this: <br />
import { FileTree } from '@astrojs/starlight/components';
<FileTree>
- src
- commands/
- events/
- plugins/
- index.js
- config.js **we are here**
- .env
- .gitignore
- bun.lockb
- package.json
- README.md
- sern.config.json
- jsconfig.json # tsconfig.json if you are using typescript
</FileTree>
## Required
### `commands`
```js title='src/config.js'
export const commands = './dist/commands'
```
We will pass this file so sern can start properly.
```js title='src/index.js'
import * as config from './config.js'
Sern.init(config)
```
## Optional
### events
Supply a directory for sern to register [event modules](/v4/modules)
### tasks
Supply a directory for sern to register [scheduled tasks](/v4/tasks)
### defaultPrefix
Supply a prefix for sern to enable text commands.
### user defined
Feel free to supply any other constants / variables you may need.
```js
export const OWNERS = ['182326315813306368']
```

View File

@@ -2,7 +2,7 @@
title: Dependencies
description: Customize & manage stateful dependencies
sidebar:
order: 5
order: 7
---
Manage objects which contain lots of state. If you were a previous user of Sapphire, dependency injection is the moral equivalent of `container`.

View File

@@ -2,7 +2,7 @@
title: Modules
description: Learn how to create modules for your sern bot
sidebar:
order: 3
order: 4
---
@@ -147,7 +147,7 @@ Components can carry metadata. This comes in handy when handling multiple compon
The first `/` is significant in custom ids. On the left of it is the custom id to be matched, and on the right is any user defined data.
:::
## Event Modules
## event modules
We are now moving to event modules, which listens to the vast streams of data provided by
- `node-cron`, `EventType.Cron`
- `sern`, `EventType.Sern`

View File

@@ -2,7 +2,7 @@
title: Plugins
description: Run code before execution
sidebar:
order: 4
order: 5
---
:::tip

View File

@@ -2,7 +2,7 @@
title: Presence
description: Manage your bot's presence programatically
sidebar:
order: 5
order: 6
---

View File

@@ -2,7 +2,7 @@
title: Project Layout
description: The layout of a sern project
sidebar:
order: 2
order: 3
---
A project should look like this: <br />
@@ -14,12 +14,13 @@ import { FileTree } from '@astrojs/starlight/components';
- commands/
- events/
- plugins/ # created automatically if running `sern plugins`
- index.ts
- index.js
- config.js # configuration for your entire application
- .env
- .gitignore
- bun.lockb
- package.json
- README.md
- sern.config.json
- tsconfig.json # jsconfig.json if you are using javascript
- jsconfig.json # tsconfig.json if you are using typescript
</FileTree>

View File

@@ -0,0 +1,14 @@
---
title: Tasks
description: Schedule and execute functions at certain times
sidebar:
order: 2
---
Your app may need to execute tasks in the future on intervals or over a long time.
If you haven't already, add the `tasks` directory to your [config](/v4/reference/config)
```js
export const tasks = "./dist/tasks"
```