35 |
|
|
36 |
```json5 |
```json5 |
37 |
{ |
{ |
38 |
main: "./build/index.js" /* The entry point. */, |
id: "org.example.sudobot.extension.hello" /* Extension ID */, |
39 |
commands: "./build/commands" /* Commands directory. The bot will load commands from this directory. */, |
main: "index.js" /* The entry point file name. */, |
40 |
events: "./build/events" /* Event handlers directory. The bot will load event handlers from this directory. */, |
src_main: "index.ts" /* The entry point file name. */, |
41 |
|
commands: "commands" /* Commands directory. The bot will load commands from this directory. */, |
42 |
|
events: "events" /* Event handlers directory. The bot will load event handlers from this directory. */, |
43 |
language: "typescript" /* The language being used for this extension. Can be either "javascript" or "typescript". */, |
language: "typescript" /* The language being used for this extension. Can be either "javascript" or "typescript". */, |
44 |
main_directory: "./build" /* The main directory where the entry point is located. */, |
main_directory: "./build" /* The main directory where the entry point is located. */, |
45 |
|
src_directory: "./src" /* The source directory where the source file of the entry point is located. */, |
46 |
build_command: "npm run build" /* Command to build the extension. In this case `npm run build` invokes `tsc`. */, |
build_command: "npm run build" /* Command to build the extension. In this case `npm run build` invokes `tsc`. */, |
47 |
} |
} |
48 |
``` |
``` |
67 |
|
|
68 |
```json |
```json |
69 |
{ |
{ |
70 |
"main": "./build/index.js", |
id: "org.example.sudobot.extension.hello", |
71 |
"commands": "./build/commands", |
main: "index.js", |
72 |
"events": "./build/events", |
src_main: "index.ts", |
73 |
"language": "typescript", |
commands: "commands", |
74 |
"main_directory": "./build", |
events: "events", |
75 |
"build_command": "npm run build" |
language: "typescript", |
76 |
|
main_directory: "./build", |
77 |
|
src_directory: "./src", |
78 |
|
build_command: "npm run build" |
79 |
} |
} |
80 |
``` |
``` |
81 |
|
|
103 |
npx tsc --init |
npx tsc --init |
104 |
``` |
``` |
105 |
|
|
106 |
This will add `typescript` as a dev dependency and also create the `tsconfig.json` file which contains the configuration for the TypeScript compiler. |
This will add `typescript` as a dev dependency and also create a `tsconfig.node.json` file which contains the configuration for the TypeScript compiler. |
107 |
|
|
108 |
Now open up `tsconfig.json` file, and add the following (you can tweak these options if you want): |
Now open up `tsconfig.node.json` file, and add the following (you can tweak these options if you want): |
109 |
|
|
110 |
```json |
```json |
111 |
{ |
{ |
136 |
``` |
``` |
137 |
|
|
138 |
This sets up the `@sudobot` and `@framework` import aliases for TypeScript, specifies the source root and build directory, and a few other things that are needed. |
This sets up the `@sudobot` and `@framework` import aliases for TypeScript, specifies the source root and build directory, and a few other things that are needed. |
139 |
|
After this, create a symbolic link named `tsconfig.json` that points to `tsconfig.node.json`. On windows, just copy the file. The command to create the symbolic link |
140 |
|
on a Unix/Linux based system would be the following: |
141 |
|
|
142 |
|
```bash |
143 |
|
ln -s ./tsconfig.node.json ./tsconfig.json |
144 |
|
``` |
145 |
|
|
146 |
<Callout type="info"> |
<Callout type="info"> |
147 |
Remember to build the bot beforehand! As you can see, this alias points to |
Remember to build the bot beforehand! As you can see, this alias points to |
252 |
npm start |
npm start |
253 |
``` |
``` |
254 |
|
|
255 |
Or using Bun (no build step required): |
**Please note that if you're using Bun to run the bot, the extensions will need to be configured differently. We'll include the instructions on how to do it |
256 |
|
manually and also how you can automate it, very soon.** |
|
```bash |
|
|
bun dev |
|
|
``` |
|
257 |
|
|
258 |
And then if everything was configured correctly, the `hello` command will be loaded and can be executed on any server. |
And then if everything was configured correctly, the `hello` command will be loaded and can be executed on any server. |
259 |
|
|