/[sudobot]/trunk/docs/app/(docs)/getting-started/page.mdx
ViewVC logotype

Diff of /trunk/docs/app/(docs)/getting-started/page.mdx

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 575 by rakinar2, Mon Jul 29 17:59:26 2024 UTC revision 602 by rakinar2, Tue Aug 20 09:29:23 2024 UTC
# Line 17  This guide will help you get started wit Line 17  This guide will help you get started wit
17    
18  ## Prerequisites  ## Prerequisites
19    
20    <Callout type="warning">
21        This guide assumes you have a Linux/Unix-based system where you'll install SudoBot. Windows users, please [scroll down](#windows-compatibility) to see how you can run SudoBot on Windows.
22    </Callout>
23    
24  Before you start, you need to have the following installed on your system:  Before you start, you need to have the following installed on your system:
25    
26  - A Discord API Application token (bot token). Go to the [Discord Developer Portal](https://discord.com/developers/applications) to create a new application, and get the token.  - A Discord API Application token (bot token). Go to the [Discord Developer Portal](https://discord.com/developers/applications) to create a new application, and get the token.
# Line 34  Lastly, we expect you to have a very bas Line 38  Lastly, we expect you to have a very bas
38    
39  ## Installation  ## Installation
40    
41  To install SudoBot, you need to clone the repository first, if you have Git installed. Run the following command in your terminal:  To install SudoBot, you need to clone the [git](https://git-scm.com) repository or checkout the [svn](https://subversion.apache.org/) repository first, if you have git installed. Run the following command in your terminal:
42    
43  ```bash  ```bash
44  git clone https://github.com/onesoft-sudo/sudobot  git clone https://github.com/onesoft-sudo/sudobot
45  ```  ```
46    
47  If you don't have Git installed, you can download the repository as a zipball/tarball from the [GitHub Releases Page](https://github.com/onesoft-sudo/sudobot/releases/latest).  You can also checkout the [svn](https://subversion.apache.org/) repository:
48    
49    ```bash
50    svn checkout https://svn.onesoftnet.eu.org/svn/sudobot sudobot
51    ```
52    
53    If you don't have git or svn installed, you can download the repository as a zipball/tarball from the [GitHub Releases Page](https://github.com/onesoft-sudo/sudobot/releases/latest).
54  Then, extract the downloaded file to a directory of your choice.  Then, extract the downloaded file to a directory of your choice.
55    
56  Next, navigate to the directory where you have cloned the repository using Git, or extracted the zipball/tarball, by running the following command in your terminal:  Next, navigate to the directory where you have cloned the repository using Git, or extracted the zipball/tarball, by running the following command in your terminal:
# Line 49  Next, navigate to the directory where yo Line 59  Next, navigate to the directory where yo
59  cd sudobot  cd sudobot
60  ```  ```
61    
62    ### Building SudoBot for Node.js
63    
64  Now, to build the project, we'll use [BlazeBuild](https://github.com/onesoft-sudo/sudobot/tree/main/blazebuild), which is a blazingly fast build tool, for TypeScript and JavaScript projects.  Now, to build the project, we'll use [BlazeBuild](https://github.com/onesoft-sudo/sudobot/tree/main/blazebuild), which is a blazingly fast build tool, for TypeScript and JavaScript projects.
65  To use BlazeBuild, you don't need to install anything including BlazeBuild itself, as it will be installed and set-up automatically during the build process.  To use BlazeBuild, you don't need to install anything including BlazeBuild itself, as it will be installed and set-up automatically during the build process.
66  BlazeBuild will also make sure to install any missing SDKs or tools required for building the project.  BlazeBuild will also make sure to install any missing SDKs or tools required for building the project.
# Line 63  This will build, compile and package the Line 75  This will build, compile and package the
75  Depending on your system, the build process may take a few seconds to a few minutes to complete.  Depending on your system, the build process may take a few seconds to a few minutes to complete.
76  We recommend using a system with at least 8GB of RAM and 2 CPU cores for faster build times.  We recommend using a system with at least 8GB of RAM and 2 CPU cores for faster build times.
77    
78  If you don't have enough resources, this command will fail with heap allocation errors. If that happens, or if you don't want to build it yourself, don't worry. You can download prebuilt versions for every release. The builds are tested on Node.js **v21**, however they should also work with **v20**.  If you don't have enough memory, this command might fail with heap allocation errors. If that happens, or if you don't want to build it yourself, don't worry. You can download prebuilt versions for every release. The builds are tested on Node.js **v22**, however they should also work with **v20** and **v21**.
79  You might see that only Linux and macOS (darwin) releases are available. This doesn't mean you cannot run the bot on Windows systems - only the native bindings are platform dependent. You don't need to worry about that in most cases and the bot will just work fine.  You might see that only Linux and macOS (darwin) releases are available. This doesn't mean you cannot run the bot on Windows systems - only the native bindings are platform dependent. You don't need to worry about that in most cases and the bot will just work fine.
80  You can download the prebuilt versions in the GitHub releases page: https://github.com/onesoft-sudo/sudobot/releases/latest  You can download the prebuilt versions in the GitHub releases page: https://github.com/onesoft-sudo/sudobot/releases/latest
81    
82  As always if you ever encounter errors with commands or you see something is not working as you expect, you can join our [Discord Server](https://discord.gg/892GWhTzgs) and ask for help!  As always if you ever encounter errors with commands or you see something is not working as you expect, you can join our [Discord Server](https://discord.gg/892GWhTzgs) and ask for help!
83    
84    ### Building SudoBot for Bun
85    
86    If you'd like to use Bun instead of Node.js to run SudoBot, then you don't need to build the bot because Bun supports TypeScript natively. Just skip to the next part and follow the commands and instructions specifically for Bun.
87    
88  ## Configuration  ## Configuration
89    
90  After building the project, you need to configure the bot to run on your server.  After building the project, you need to configure the bot to run on your server.
# Line 158  After configuring the bot, you can run i Line 174  After configuring the bot, you can run i
174  By default, BlazeBuild will use [Bun](https://bun.sh) to run the bot. If you want to use Node.js instead, you can run the following command:  By default, BlazeBuild will use [Bun](https://bun.sh) to run the bot. If you want to use Node.js instead, you can run the following command:
175    
176  ```bash  ```bash
177  ./blazew run -- --node  ./blazew run --node
178  ```  ```
179    
180  This will start the bot, and you should see the bot online in your Discord server.  This will start the bot, and you should see the bot online in your Discord server.
# Line 172  The bot uses [Discord's Application Comm Line 188  The bot uses [Discord's Application Comm
188  To register the application commands to the Discord API, you can run the following command:  To register the application commands to the Discord API, you can run the following command:
189    
190  ```bash  ```bash
191  ./blazew run -- -- -u  ./blazew run -- -u
192  ```  ```
193    
194  If you have debug mode enabled and have `HOME_GUILD_ID` set in the `.env` file, the bot will register the commands in the development guild.  If you have debug mode enabled and have `HOME_GUILD_ID` set in the `.env` file, the bot will register the commands in the development guild.
# Line 181  If you don't have debug mode enabled, th Line 197  If you don't have debug mode enabled, th
197  If you want to force the bot to register the commands globally, you can run the following command:  If you want to force the bot to register the commands globally, you can run the following command:
198    
199  ```bash  ```bash
200  ./blazew run -- -- -u -g  ./blazew run -- -u -g
201  ```  ```
202    
203  To clear the registered commands, you can run the following command:  To clear the registered commands, you can run the following command:
204    
205  ```bash  ```bash
206  ./blazew run -- -- -c  ./blazew run -- -c
207  ```  ```
208    
209  Once again, if you have debug mode enabled, the bot will clear the commands in the development guild. Otherwise, it will clear the commands globally.  Once again, if you have debug mode enabled, the bot will clear the commands in the development guild. Otherwise, it will clear the commands globally.
210  To force the bot to clear the commands globally, you can run the following command:  To force the bot to clear the commands globally, you can run the following command:
211    
212  ```bash  ```bash
213  ./blazew run -- -- -c -g  ./blazew run -- -c -g
214    ```
215    
216    ## Windows Compatibility
217    
218    SudoBot was created with Linux/Unix-based systems in mind, since in most cases you're going to end up running SudoBot on a production server which is usually Linux/Unix-based.
219    However, that doesn't mean you can't run SudoBot on Windows &mdash; but please keep in mind that some things might need tweaks or you might need to do some things differently to make it work on Windows.
220    
221    **First of all**, BlazeBuild on Windows is still experimental, known to have some issues. So please run the following commands as alternatives:
222    
223    **Install dependencies**
224    
225    ```bash
226    bun install
227    ```
228    
229    If using Node:
230    
231    ```bash
232    npm install -D
233    ```
234    
235    **Build the project (Skip this if using Bun)**
236    
237    ```bash
238    npm run build
239  ```  ```
240    
241    **Run the Database Migrations**
242    
243    Please first make sure you have the right credentials in your `.env` file. Then, create a new file named `migrate.ts` in the project root with the following contents:
244    
245    ```typescript
246    import "dotenv/config";
247    
248    const { drizzle } = await import(String("drizzle-orm/node-postgres"));
249    const { migrate } = await import(String("drizzle-orm/node-postgres/migrator"));
250    const { Pool } = await import(String("pg"));
251    
252    const pool = new Pool({
253        connectionString: process.env.DB_URL
254    });
255    
256    const db = drizzle(pool);
257    await migrate(db, { migrationsFolder: "drizzle" });
258    await pool.end();
259    ```
260    
261    Then run this file:
262    
263    ```bash
264    bun migrate.ts
265    ```
266    
267    And if everything was correctly set up, your database will have the new tables created for SudoBot.
268    
269    **Starting the Bot**
270    
271    Be sure to set up the configuration files before starting the bot! After doing that, run the following:
272    
273    ```bash
274    bun dev
275    ```
276    
277    Or, if using Node:
278    
279    ```bash
280    npm run start
281    ```
282    
283    Also note, to pass any options that you could pass to `./blazew run`, you can just pass it normally to `bun dev` if using `bun`, or after a `--` argument if using `npm run start`.
284    
285  ## Emojis  ## Emojis
286    
287  The bot uses some custom emojis and it will try to find those emojis in the Home Guild (The main server, which is configured in `HOME_GUILD_ID` environment variable).  The bot uses some custom emojis and it will try to find those emojis in the Home Guild (The main server, which is configured in `HOME_GUILD_ID` environment variable).

Legend:
Removed from v.575  
changed lines
  Added in v.602

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26