-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
📝 add discordjs essentials and project structure
- Loading branch information
Showing
3 changed files
with
87 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,6 @@ | ||
{ | ||
"index": "", | ||
"installation": "" | ||
"installation": "", | ||
"project-structure": "", | ||
"discordjs-essentials": "Discord.js Essentials" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
--- | ||
title: "discord.js Essentials" | ||
description: "An overview of essential discord.js features for building bot" | ||
--- | ||
|
||
import { Tab, Tabs } from "nextra-theme-docs"; | ||
|
||
# Discord.js Essentials | ||
|
||
To build bot with dixt, it helps to be familiar with discord.js features such as client or shards. This page will give you a brief overview of these features. | ||
|
||
If you"re new to discord.js, we also recommend reffering to the [discord.js Documentation](https://discord.js.org/#/docs/main/stable/general/welcome). Here are some great resources for learning: | ||
- [discord.js Guide](https://discordjs.guide) | ||
- [discord.js Rapid Tutorial](https://ravbug.com/tutorials/discordjs) | ||
- [discord.js freeCodeCamp Tutorial](https://www.freecodecamp.org/news/create-a-discord-bot-with-javascript-nodejs) | ||
|
||
## Client | ||
|
||
The client is the main interface for interacting with the Discord API, and the starting point for any bot. It is the main class in discord.js. | ||
|
||
<Tabs items={["without dixt", "with dixt"]}> | ||
<Tab> | ||
```js | ||
const { Client } = require("discord.js"); | ||
|
||
const client = new Client(); | ||
|
||
client.on("ready", () => { | ||
console.log(`Logged in as ${client.user.tag}!`); | ||
}); | ||
|
||
client.login("your_bot_token"); | ||
``` | ||
</Tab> | ||
<Tab> | ||
```js | ||
const { default: dixt } = require("dixt"); | ||
|
||
const instance = new dixt({ | ||
application: { | ||
id: "your_application_id", | ||
bot: { | ||
token: "your_bot_token", | ||
} | ||
} | ||
}); | ||
|
||
instance.client.on("ready", () => { | ||
console.log(`Logged in as ${instance.client.user.tag}!`); | ||
}); | ||
|
||
instance.start(); | ||
``` | ||
</Tab> | ||
</Tabs> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
--- | ||
title: "Project Structure" | ||
description: "A list of folders and files conventions in a dixt project" | ||
--- | ||
|
||
# Project Structure | ||
|
||
This page provides an overview of the file and folder structure of a dixt project. | ||
|
||
## Top-level files | ||
|
||
| | | | ||
|-|-| | ||
| **dixt** | | | ||
| [`.env`](/installation#environment-variables) | Environment variables | | ||
| [`.env.local`](/installation#environment-variables) | Local environment variables | | ||
| [`.env.production`](/installation#environment-variables) | Production environment variables | | ||
| [`.env.development`](/installation#environment-variables) | Development environment variables | | ||
| **Ecosystem** | | | ||
| [`package.json`](/installation#manual-installation) | Project dependencies and scripts | | ||
| `.gitignore` | Git files and folders to ignore | | ||
| `tsconfig.json` | Configuration file for TypeScript | | ||
| `.eslintrc.json` | Configuration file for ESLint | | ||
|
||
## Top-level folders | ||
|
||
| | | | ||
|-|-| | ||
| `src` | Optional application source folder | |