From 3fa02ec79a19861df797a47c05413664a652f507 Mon Sep 17 00:00:00 2001 From: jacob Date: Wed, 17 Jul 2024 00:09:49 -0500 Subject: [PATCH] add config and tasks (almost done) --- .../docs/v4/reference/autocomplete.mdx | 2 +- src/content/docs/v4/reference/conclusion.mdx | 2 +- src/content/docs/v4/reference/config.mdx | 60 +++++++++++++++++++ .../docs/v4/reference/dependencies.mdx | 2 +- src/content/docs/v4/reference/modules.mdx | 4 +- src/content/docs/v4/reference/plugins.mdx | 2 +- src/content/docs/v4/reference/presence.mdx | 2 +- .../docs/v4/reference/project-layout.mdx | 7 ++- src/content/docs/v4/reference/tasks.mdx | 14 +++++ 9 files changed, 85 insertions(+), 10 deletions(-) create mode 100644 src/content/docs/v4/reference/config.mdx create mode 100644 src/content/docs/v4/reference/tasks.mdx diff --git a/src/content/docs/v4/reference/autocomplete.mdx b/src/content/docs/v4/reference/autocomplete.mdx index 2a942f86b..f9386bbb0 100644 --- a/src/content/docs/v4/reference/autocomplete.mdx +++ b/src/content/docs/v4/reference/autocomplete.mdx @@ -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. diff --git a/src/content/docs/v4/reference/conclusion.mdx b/src/content/docs/v4/reference/conclusion.mdx index 1c700832a..017c8189b 100644 --- a/src/content/docs/v4/reference/conclusion.mdx +++ b/src/content/docs/v4/reference/conclusion.mdx @@ -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! diff --git a/src/content/docs/v4/reference/config.mdx b/src/content/docs/v4/reference/config.mdx new file mode 100644 index 000000000..a224487ee --- /dev/null +++ b/src/content/docs/v4/reference/config.mdx @@ -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:
+ +import { FileTree } from '@astrojs/starlight/components'; + + +- 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 + + +## 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'] +``` diff --git a/src/content/docs/v4/reference/dependencies.mdx b/src/content/docs/v4/reference/dependencies.mdx index 80d73a5ab..e6cfc5a73 100644 --- a/src/content/docs/v4/reference/dependencies.mdx +++ b/src/content/docs/v4/reference/dependencies.mdx @@ -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`. diff --git a/src/content/docs/v4/reference/modules.mdx b/src/content/docs/v4/reference/modules.mdx index 02a23009d..0a02b029f 100644 --- a/src/content/docs/v4/reference/modules.mdx +++ b/src/content/docs/v4/reference/modules.mdx @@ -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` diff --git a/src/content/docs/v4/reference/plugins.mdx b/src/content/docs/v4/reference/plugins.mdx index 48b9ccd70..8ebaacc3c 100644 --- a/src/content/docs/v4/reference/plugins.mdx +++ b/src/content/docs/v4/reference/plugins.mdx @@ -2,7 +2,7 @@ title: Plugins description: Run code before execution sidebar: - order: 4 + order: 5 --- :::tip diff --git a/src/content/docs/v4/reference/presence.mdx b/src/content/docs/v4/reference/presence.mdx index 733059067..47642c25f 100644 --- a/src/content/docs/v4/reference/presence.mdx +++ b/src/content/docs/v4/reference/presence.mdx @@ -2,7 +2,7 @@ title: Presence description: Manage your bot's presence programatically sidebar: - order: 5 + order: 6 --- diff --git a/src/content/docs/v4/reference/project-layout.mdx b/src/content/docs/v4/reference/project-layout.mdx index 4f043db97..638a15e33 100644 --- a/src/content/docs/v4/reference/project-layout.mdx +++ b/src/content/docs/v4/reference/project-layout.mdx @@ -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:
@@ -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 diff --git a/src/content/docs/v4/reference/tasks.mdx b/src/content/docs/v4/reference/tasks.mdx new file mode 100644 index 000000000..302151a82 --- /dev/null +++ b/src/content/docs/v4/reference/tasks.mdx @@ -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" +``` +