@mostfeatured/dbi 0.1.47 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/DBI.d.ts.map +1 -0
- package/dist/src/DBI.js.map +1 -0
- package/dist/src/Events.d.ts.map +1 -0
- package/dist/src/Events.js.map +1 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/methods/handleMessageCommands.d.ts.map +1 -0
- package/dist/src/methods/handleMessageCommands.js.map +1 -0
- package/dist/src/methods/hookEventListeners.d.ts.map +1 -0
- package/dist/src/methods/hookEventListeners.js.map +1 -0
- package/dist/src/methods/hookInteractionListeners.d.ts.map +1 -0
- package/dist/{methods → src/methods}/hookInteractionListeners.js +22 -12
- package/dist/src/methods/hookInteractionListeners.js.map +1 -0
- package/dist/src/methods/publishInteractions.d.ts.map +1 -0
- package/dist/src/methods/publishInteractions.js.map +1 -0
- package/dist/src/types/ApplicationRoleConnectionMetadata.d.ts.map +1 -0
- package/dist/src/types/ApplicationRoleConnectionMetadata.js.map +1 -0
- package/dist/src/types/Builders/ButtonBuilder.d.ts.map +1 -0
- package/dist/src/types/Builders/ButtonBuilder.js.map +1 -0
- package/dist/src/types/Builders/ChannelSelectMenuBuilder.d.ts.map +1 -0
- package/dist/src/types/Builders/ChannelSelectMenuBuilder.js.map +1 -0
- package/dist/src/types/Builders/MentionableSelectMenuBuilder.d.ts.map +1 -0
- package/dist/src/types/Builders/MentionableSelectMenuBuilder.js.map +1 -0
- package/dist/src/types/Builders/ModalBuilder.d.ts.map +1 -0
- package/dist/src/types/Builders/ModalBuilder.js.map +1 -0
- package/dist/src/types/Builders/RoleSelectMenuBuilder.d.ts.map +1 -0
- package/dist/src/types/Builders/RoleSelectMenuBuilder.js.map +1 -0
- package/dist/src/types/Builders/StringSelectMenuBuilder.d.ts.map +1 -0
- package/dist/src/types/Builders/StringSelectMenuBuilder.js.map +1 -0
- package/dist/src/types/Builders/UserSelectMenuBuilder.d.ts.map +1 -0
- package/dist/src/types/Builders/UserSelectMenuBuilder.js.map +1 -0
- package/dist/src/types/ChatInput/ChatInput.d.ts.map +1 -0
- package/dist/src/types/ChatInput/ChatInput.js.map +1 -0
- package/dist/{types → src/types}/ChatInput/ChatInputOptions.d.ts +2 -2
- package/dist/src/types/ChatInput/ChatInputOptions.d.ts.map +1 -0
- package/dist/src/types/ChatInput/ChatInputOptions.js.map +1 -0
- package/dist/src/types/Components/Button.d.ts.map +1 -0
- package/dist/src/types/Components/Button.js.map +1 -0
- package/dist/src/types/Components/ChannelSelectMenu.d.ts.map +1 -0
- package/dist/src/types/Components/ChannelSelectMenu.js.map +1 -0
- package/dist/src/types/Components/HTMLComponentsV2/HTMLComponentsV2Handlers.d.ts.map +1 -0
- package/dist/src/types/Components/HTMLComponentsV2/HTMLComponentsV2Handlers.js.map +1 -0
- package/dist/src/types/Components/HTMLComponentsV2/index.d.ts +91 -0
- package/dist/src/types/Components/HTMLComponentsV2/index.d.ts.map +1 -0
- package/dist/src/types/Components/HTMLComponentsV2/index.js +300 -0
- package/dist/src/types/Components/HTMLComponentsV2/index.js.map +1 -0
- package/dist/src/types/Components/HTMLComponentsV2/parser.d.ts.map +1 -0
- package/dist/{types → src/types}/Components/HTMLComponentsV2/parser.js +11 -4
- package/dist/src/types/Components/HTMLComponentsV2/parser.js.map +1 -0
- package/dist/src/types/Components/HTMLComponentsV2/svelteParser.d.ts +35 -0
- package/dist/src/types/Components/HTMLComponentsV2/svelteParser.d.ts.map +1 -0
- package/dist/src/types/Components/HTMLComponentsV2/svelteParser.js +822 -0
- package/dist/src/types/Components/HTMLComponentsV2/svelteParser.js.map +1 -0
- package/dist/src/types/Components/HTMLComponentsV2/svelteRenderer.d.ts +24 -0
- package/dist/src/types/Components/HTMLComponentsV2/svelteRenderer.d.ts.map +1 -0
- package/dist/src/types/Components/HTMLComponentsV2/svelteRenderer.js +294 -0
- package/dist/src/types/Components/HTMLComponentsV2/svelteRenderer.js.map +1 -0
- package/dist/src/types/Components/MentionableSelectMenu.d.ts.map +1 -0
- package/dist/src/types/Components/MentionableSelectMenu.js.map +1 -0
- package/dist/src/types/Components/Modal.d.ts.map +1 -0
- package/dist/src/types/Components/Modal.js.map +1 -0
- package/dist/src/types/Components/RoleSelectMenu.d.ts.map +1 -0
- package/dist/src/types/Components/RoleSelectMenu.js.map +1 -0
- package/dist/src/types/Components/StringSelectMenu.d.ts.map +1 -0
- package/dist/src/types/Components/StringSelectMenu.js.map +1 -0
- package/dist/src/types/Components/UserSelectMenu.d.ts.map +1 -0
- package/dist/src/types/Components/UserSelectMenu.js.map +1 -0
- package/dist/src/types/Event.d.ts.map +1 -0
- package/dist/src/types/Event.js.map +1 -0
- package/dist/src/types/Interaction.d.ts.map +1 -0
- package/dist/src/types/Interaction.js.map +1 -0
- package/dist/src/types/other/CustomEvent.d.ts.map +1 -0
- package/dist/src/types/other/CustomEvent.js.map +1 -0
- package/dist/src/types/other/FakeMessageInteraction.d.ts.map +1 -0
- package/dist/src/types/other/FakeMessageInteraction.js.map +1 -0
- package/dist/src/types/other/InteractionLocale.d.ts.map +1 -0
- package/dist/src/types/other/InteractionLocale.js.map +1 -0
- package/dist/src/types/other/Locale.d.ts.map +1 -0
- package/dist/src/types/other/Locale.js.map +1 -0
- package/dist/src/types/other/MessageContextMenu.d.ts.map +1 -0
- package/dist/src/types/other/MessageContextMenu.js.map +1 -0
- package/dist/src/types/other/UserContextMenu.d.ts.map +1 -0
- package/dist/src/types/other/UserContextMenu.js.map +1 -0
- package/dist/src/utils/MemoryStore.d.ts.map +1 -0
- package/dist/src/utils/MemoryStore.js.map +1 -0
- package/dist/src/utils/UtilTypes.d.ts.map +1 -0
- package/dist/src/utils/UtilTypes.js.map +1 -0
- package/dist/src/utils/customId.d.ts.map +1 -0
- package/dist/src/utils/customId.js.map +1 -0
- package/dist/src/utils/permissions.d.ts.map +1 -0
- package/dist/src/utils/permissions.js.map +1 -0
- package/dist/src/utils/recursiveImport.d.ts.map +1 -0
- package/dist/src/utils/recursiveImport.js.map +1 -0
- package/dist/src/utils/recursiveUnload.d.ts.map +1 -0
- package/dist/src/utils/recursiveUnload.js.map +1 -0
- package/dist/src/utils/unloadModule.d.ts.map +1 -0
- package/dist/src/utils/unloadModule.js.map +1 -0
- package/dist/test/index.d.ts +2 -0
- package/dist/test/index.d.ts.map +1 -0
- package/dist/test/index.js +103 -0
- package/dist/test/index.js.map +1 -0
- package/docs/ADVANCED_FEATURES.md +836 -0
- package/docs/API_REFERENCE.md +925 -0
- package/docs/CHAT_INPUT.md +807 -0
- package/docs/COMPONENTS.md +1035 -0
- package/docs/EVENTS.md +564 -0
- package/docs/GETTING_STARTED.md +394 -0
- package/docs/LOCALIZATION.md +773 -0
- package/docs/README.md +341 -0
- package/docs/SVELTE_COMPONENTS.md +955 -0
- package/generated/globals.d.ts +1 -0
- package/generated/index.d.ts +30 -0
- package/generated/svelte-dbi.d.ts +588 -0
- package/package.json +57 -47
- package/readme.md +168 -491
- package/src/methods/hookInteractionListeners.ts +23 -12
- package/src/types/Components/HTMLComponentsV2/index.ts +353 -12
- package/src/types/Components/HTMLComponentsV2/parser.ts +14 -4
- package/src/types/Components/HTMLComponentsV2/svelteParser.ts +904 -0
- package/src/types/Components/HTMLComponentsV2/svelteRenderer.ts +332 -0
- package/test/index.ts +105 -0
- package/test/product-showcase.svelte +199 -0
- package/tsconfig.json +13 -3
- package/dist/DBI.d.ts.map +0 -1
- package/dist/DBI.js.map +0 -1
- package/dist/Events.d.ts.map +0 -1
- package/dist/Events.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/methods/handleMessageCommands.d.ts.map +0 -1
- package/dist/methods/handleMessageCommands.js.map +0 -1
- package/dist/methods/hookEventListeners.d.ts.map +0 -1
- package/dist/methods/hookEventListeners.js.map +0 -1
- package/dist/methods/hookInteractionListeners.d.ts.map +0 -1
- package/dist/methods/hookInteractionListeners.js.map +0 -1
- package/dist/methods/publishInteractions.d.ts.map +0 -1
- package/dist/methods/publishInteractions.js.map +0 -1
- package/dist/types/ApplicationRoleConnectionMetadata.d.ts.map +0 -1
- package/dist/types/ApplicationRoleConnectionMetadata.js.map +0 -1
- package/dist/types/Builders/ButtonBuilder.d.ts.map +0 -1
- package/dist/types/Builders/ButtonBuilder.js.map +0 -1
- package/dist/types/Builders/ChannelSelectMenuBuilder.d.ts.map +0 -1
- package/dist/types/Builders/ChannelSelectMenuBuilder.js.map +0 -1
- package/dist/types/Builders/MentionableSelectMenuBuilder.d.ts.map +0 -1
- package/dist/types/Builders/MentionableSelectMenuBuilder.js.map +0 -1
- package/dist/types/Builders/ModalBuilder.d.ts.map +0 -1
- package/dist/types/Builders/ModalBuilder.js.map +0 -1
- package/dist/types/Builders/RoleSelectMenuBuilder.d.ts.map +0 -1
- package/dist/types/Builders/RoleSelectMenuBuilder.js.map +0 -1
- package/dist/types/Builders/StringSelectMenuBuilder.d.ts.map +0 -1
- package/dist/types/Builders/StringSelectMenuBuilder.js.map +0 -1
- package/dist/types/Builders/UserSelectMenuBuilder.d.ts.map +0 -1
- package/dist/types/Builders/UserSelectMenuBuilder.js.map +0 -1
- package/dist/types/ChatInput/ChatInput.d.ts.map +0 -1
- package/dist/types/ChatInput/ChatInput.js.map +0 -1
- package/dist/types/ChatInput/ChatInputOptions.d.ts.map +0 -1
- package/dist/types/ChatInput/ChatInputOptions.js.map +0 -1
- package/dist/types/Components/Button.d.ts.map +0 -1
- package/dist/types/Components/Button.js.map +0 -1
- package/dist/types/Components/ChannelSelectMenu.d.ts.map +0 -1
- package/dist/types/Components/ChannelSelectMenu.js.map +0 -1
- package/dist/types/Components/HTMLComponentsV2/HTMLComponentsV2Handlers.d.ts.map +0 -1
- package/dist/types/Components/HTMLComponentsV2/HTMLComponentsV2Handlers.js.map +0 -1
- package/dist/types/Components/HTMLComponentsV2/index.d.ts +0 -19
- package/dist/types/Components/HTMLComponentsV2/index.d.ts.map +0 -1
- package/dist/types/Components/HTMLComponentsV2/index.js +0 -31
- package/dist/types/Components/HTMLComponentsV2/index.js.map +0 -1
- package/dist/types/Components/HTMLComponentsV2/parser.d.ts.map +0 -1
- package/dist/types/Components/HTMLComponentsV2/parser.js.map +0 -1
- package/dist/types/Components/MentionableSelectMenu.d.ts.map +0 -1
- package/dist/types/Components/MentionableSelectMenu.js.map +0 -1
- package/dist/types/Components/Modal.d.ts.map +0 -1
- package/dist/types/Components/Modal.js.map +0 -1
- package/dist/types/Components/RoleSelectMenu.d.ts.map +0 -1
- package/dist/types/Components/RoleSelectMenu.js.map +0 -1
- package/dist/types/Components/StringSelectMenu.d.ts.map +0 -1
- package/dist/types/Components/StringSelectMenu.js.map +0 -1
- package/dist/types/Components/UserSelectMenu.d.ts.map +0 -1
- package/dist/types/Components/UserSelectMenu.js.map +0 -1
- package/dist/types/Event.d.ts.map +0 -1
- package/dist/types/Event.js.map +0 -1
- package/dist/types/Interaction.d.ts.map +0 -1
- package/dist/types/Interaction.js.map +0 -1
- package/dist/types/other/CustomEvent.d.ts.map +0 -1
- package/dist/types/other/CustomEvent.js.map +0 -1
- package/dist/types/other/FakeMessageInteraction.d.ts.map +0 -1
- package/dist/types/other/FakeMessageInteraction.js.map +0 -1
- package/dist/types/other/InteractionLocale.d.ts.map +0 -1
- package/dist/types/other/InteractionLocale.js.map +0 -1
- package/dist/types/other/Locale.d.ts.map +0 -1
- package/dist/types/other/Locale.js.map +0 -1
- package/dist/types/other/MessageContextMenu.d.ts.map +0 -1
- package/dist/types/other/MessageContextMenu.js.map +0 -1
- package/dist/types/other/UserContextMenu.d.ts.map +0 -1
- package/dist/types/other/UserContextMenu.js.map +0 -1
- package/dist/utils/MemoryStore.d.ts.map +0 -1
- package/dist/utils/MemoryStore.js.map +0 -1
- package/dist/utils/UtilTypes.d.ts.map +0 -1
- package/dist/utils/UtilTypes.js.map +0 -1
- package/dist/utils/customId.d.ts.map +0 -1
- package/dist/utils/customId.js.map +0 -1
- package/dist/utils/permissions.d.ts.map +0 -1
- package/dist/utils/permissions.js.map +0 -1
- package/dist/utils/recursiveImport.d.ts.map +0 -1
- package/dist/utils/recursiveImport.js.map +0 -1
- package/dist/utils/recursiveUnload.d.ts.map +0 -1
- package/dist/utils/recursiveUnload.js.map +0 -1
- package/dist/utils/unloadModule.d.ts.map +0 -1
- package/dist/utils/unloadModule.js.map +0 -1
- package/examples/modal/dbi.js +0 -30
- package/examples/modal/login.js +0 -15
- package/examples/modal/package.json +0 -15
- package/examples/modal/publish.js +0 -13
- package/examples/modal/src/chatInput.js +0 -38
- package/examples/modal/src/components.js +0 -33
- package/examples/modal/src/event.js +0 -20
- package/examples/modal/src/interactionlocales.js +0 -24
- package/examples/modal/src/locales.js +0 -38
- package/examples/modal/src/modal.js +0 -28
- /package/dist/{DBI.d.ts → src/DBI.d.ts} +0 -0
- /package/dist/{DBI.js → src/DBI.js} +0 -0
- /package/dist/{Events.d.ts → src/Events.d.ts} +0 -0
- /package/dist/{Events.js → src/Events.js} +0 -0
- /package/dist/{data → src/data}/eventMap.json +0 -0
- /package/dist/{index.d.ts → src/index.d.ts} +0 -0
- /package/dist/{index.js → src/index.js} +0 -0
- /package/dist/{methods → src/methods}/handleMessageCommands.d.ts +0 -0
- /package/dist/{methods → src/methods}/handleMessageCommands.js +0 -0
- /package/dist/{methods → src/methods}/hookEventListeners.d.ts +0 -0
- /package/dist/{methods → src/methods}/hookEventListeners.js +0 -0
- /package/dist/{methods → src/methods}/hookInteractionListeners.d.ts +0 -0
- /package/dist/{methods → src/methods}/publishInteractions.d.ts +0 -0
- /package/dist/{methods → src/methods}/publishInteractions.js +0 -0
- /package/dist/{types → src/types}/ApplicationRoleConnectionMetadata.d.ts +0 -0
- /package/dist/{types → src/types}/ApplicationRoleConnectionMetadata.js +0 -0
- /package/dist/{types → src/types}/Builders/ButtonBuilder.d.ts +0 -0
- /package/dist/{types → src/types}/Builders/ButtonBuilder.js +0 -0
- /package/dist/{types → src/types}/Builders/ChannelSelectMenuBuilder.d.ts +0 -0
- /package/dist/{types → src/types}/Builders/ChannelSelectMenuBuilder.js +0 -0
- /package/dist/{types → src/types}/Builders/MentionableSelectMenuBuilder.d.ts +0 -0
- /package/dist/{types → src/types}/Builders/MentionableSelectMenuBuilder.js +0 -0
- /package/dist/{types → src/types}/Builders/ModalBuilder.d.ts +0 -0
- /package/dist/{types → src/types}/Builders/ModalBuilder.js +0 -0
- /package/dist/{types → src/types}/Builders/RoleSelectMenuBuilder.d.ts +0 -0
- /package/dist/{types → src/types}/Builders/RoleSelectMenuBuilder.js +0 -0
- /package/dist/{types → src/types}/Builders/StringSelectMenuBuilder.d.ts +0 -0
- /package/dist/{types → src/types}/Builders/StringSelectMenuBuilder.js +0 -0
- /package/dist/{types → src/types}/Builders/UserSelectMenuBuilder.d.ts +0 -0
- /package/dist/{types → src/types}/Builders/UserSelectMenuBuilder.js +0 -0
- /package/dist/{types → src/types}/ChatInput/ChatInput.d.ts +0 -0
- /package/dist/{types → src/types}/ChatInput/ChatInput.js +0 -0
- /package/dist/{types → src/types}/ChatInput/ChatInputOptions.js +0 -0
- /package/dist/{types → src/types}/Components/Button.d.ts +0 -0
- /package/dist/{types → src/types}/Components/Button.js +0 -0
- /package/dist/{types → src/types}/Components/ChannelSelectMenu.d.ts +0 -0
- /package/dist/{types → src/types}/Components/ChannelSelectMenu.js +0 -0
- /package/dist/{types → src/types}/Components/HTMLComponentsV2/HTMLComponentsV2Handlers.d.ts +0 -0
- /package/dist/{types → src/types}/Components/HTMLComponentsV2/HTMLComponentsV2Handlers.js +0 -0
- /package/dist/{types → src/types}/Components/HTMLComponentsV2/parser.d.ts +0 -0
- /package/dist/{types → src/types}/Components/MentionableSelectMenu.d.ts +0 -0
- /package/dist/{types → src/types}/Components/MentionableSelectMenu.js +0 -0
- /package/dist/{types → src/types}/Components/Modal.d.ts +0 -0
- /package/dist/{types → src/types}/Components/Modal.js +0 -0
- /package/dist/{types → src/types}/Components/RoleSelectMenu.d.ts +0 -0
- /package/dist/{types → src/types}/Components/RoleSelectMenu.js +0 -0
- /package/dist/{types → src/types}/Components/StringSelectMenu.d.ts +0 -0
- /package/dist/{types → src/types}/Components/StringSelectMenu.js +0 -0
- /package/dist/{types → src/types}/Components/UserSelectMenu.d.ts +0 -0
- /package/dist/{types → src/types}/Components/UserSelectMenu.js +0 -0
- /package/dist/{types → src/types}/Event.d.ts +0 -0
- /package/dist/{types → src/types}/Event.js +0 -0
- /package/dist/{types → src/types}/Interaction.d.ts +0 -0
- /package/dist/{types → src/types}/Interaction.js +0 -0
- /package/dist/{types → src/types}/other/CustomEvent.d.ts +0 -0
- /package/dist/{types → src/types}/other/CustomEvent.js +0 -0
- /package/dist/{types → src/types}/other/FakeMessageInteraction.d.ts +0 -0
- /package/dist/{types → src/types}/other/FakeMessageInteraction.js +0 -0
- /package/dist/{types → src/types}/other/InteractionLocale.d.ts +0 -0
- /package/dist/{types → src/types}/other/InteractionLocale.js +0 -0
- /package/dist/{types → src/types}/other/Locale.d.ts +0 -0
- /package/dist/{types → src/types}/other/Locale.js +0 -0
- /package/dist/{types → src/types}/other/MessageContextMenu.d.ts +0 -0
- /package/dist/{types → src/types}/other/MessageContextMenu.js +0 -0
- /package/dist/{types → src/types}/other/UserContextMenu.d.ts +0 -0
- /package/dist/{types → src/types}/other/UserContextMenu.js +0 -0
- /package/dist/{utils → src/utils}/MemoryStore.d.ts +0 -0
- /package/dist/{utils → src/utils}/MemoryStore.js +0 -0
- /package/dist/{utils → src/utils}/UtilTypes.d.ts +0 -0
- /package/dist/{utils → src/utils}/UtilTypes.js +0 -0
- /package/dist/{utils → src/utils}/customId.d.ts +0 -0
- /package/dist/{utils → src/utils}/customId.js +0 -0
- /package/dist/{utils → src/utils}/permissions.d.ts +0 -0
- /package/dist/{utils → src/utils}/permissions.js +0 -0
- /package/dist/{utils → src/utils}/recursiveImport.d.ts +0 -0
- /package/dist/{utils → src/utils}/recursiveImport.js +0 -0
- /package/dist/{utils → src/utils}/recursiveUnload.d.ts +0 -0
- /package/dist/{utils → src/utils}/recursiveUnload.js +0 -0
- /package/dist/{utils → src/utils}/unloadModule.d.ts +0 -0
- /package/dist/{utils → src/utils}/unloadModule.js +0 -0
|
@@ -0,0 +1,394 @@
|
|
|
1
|
+
# Getting Started with DBI
|
|
2
|
+
|
|
3
|
+
This guide will walk you through setting up your first Discord bot using DBI (Discord Bot Infrastructure).
|
|
4
|
+
|
|
5
|
+
## Prerequisites
|
|
6
|
+
|
|
7
|
+
- **Node.js 16.9.0 or higher** - [Download Node.js](https://nodejs.org/)
|
|
8
|
+
- **A Discord Application** - [Create one here](https://discord.com/developers/applications)
|
|
9
|
+
- **Basic JavaScript/TypeScript knowledge**
|
|
10
|
+
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
## Installation
|
|
14
|
+
|
|
15
|
+
### Create a New Project
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
mkdir my-discord-bot
|
|
19
|
+
cd my-discord-bot
|
|
20
|
+
npm init -y
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
### Install Dependencies
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
npm install @mostfeatured/dbi discord.js
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
For TypeScript users:
|
|
30
|
+
```bash
|
|
31
|
+
npm install -D typescript @types/node ts-node
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
---
|
|
35
|
+
|
|
36
|
+
## Project Setup
|
|
37
|
+
|
|
38
|
+
### Recommended Project Structure
|
|
39
|
+
|
|
40
|
+
```
|
|
41
|
+
my-discord-bot/
|
|
42
|
+
├── package.json
|
|
43
|
+
├── .env # Environment variables (keep this secret!)
|
|
44
|
+
├── dbi.js # DBI configuration
|
|
45
|
+
├── login.js # Bot startup script
|
|
46
|
+
├── publish.js # Command publishing script
|
|
47
|
+
└── src/
|
|
48
|
+
├── commands/ # Slash commands
|
|
49
|
+
│ └── ping.js
|
|
50
|
+
├── components/ # Buttons, Select Menus, Modals
|
|
51
|
+
│ └── confirm.js
|
|
52
|
+
├── events/ # Discord event handlers
|
|
53
|
+
│ └── ready.js
|
|
54
|
+
└── locales/ # Language files
|
|
55
|
+
└── en.js
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
---
|
|
59
|
+
|
|
60
|
+
## Step-by-Step Configuration
|
|
61
|
+
|
|
62
|
+
### 1. Create the DBI Configuration (`dbi.js`)
|
|
63
|
+
|
|
64
|
+
The DBI configuration is the heart of your bot. It defines how your bot connects to Discord and its default behaviors.
|
|
65
|
+
|
|
66
|
+
```javascript
|
|
67
|
+
const { createDBI } = require("@mostfeatured/dbi");
|
|
68
|
+
|
|
69
|
+
// Create a DBI instance with a unique namespace
|
|
70
|
+
const dbi = createDBI("my-bot", {
|
|
71
|
+
// Strict mode - throws errors for duplicate registrations
|
|
72
|
+
strict: true,
|
|
73
|
+
|
|
74
|
+
// Discord connection settings
|
|
75
|
+
discord: {
|
|
76
|
+
token: process.env.DISCORD_TOKEN,
|
|
77
|
+
options: {
|
|
78
|
+
intents: [
|
|
79
|
+
"Guilds", // For guild-related events
|
|
80
|
+
"GuildMessages", // For message events
|
|
81
|
+
"MessageContent" // For reading message content (privileged)
|
|
82
|
+
]
|
|
83
|
+
}
|
|
84
|
+
},
|
|
85
|
+
|
|
86
|
+
// Default settings for interactions
|
|
87
|
+
defaults: {
|
|
88
|
+
locale: {
|
|
89
|
+
name: "en", // Default language
|
|
90
|
+
// Custom message when locale path not found
|
|
91
|
+
invalidPath: (ctx) => `Missing translation: ${ctx.path}`
|
|
92
|
+
},
|
|
93
|
+
// Default permissions required to use commands
|
|
94
|
+
defaultMemberPermissions: ["SendMessages"],
|
|
95
|
+
// Whether commands work in DMs
|
|
96
|
+
directMessages: false
|
|
97
|
+
},
|
|
98
|
+
|
|
99
|
+
// Reference system for passing data through components
|
|
100
|
+
references: {
|
|
101
|
+
autoClear: {
|
|
102
|
+
ttl: 60 * 60 * 1000, // References expire after 1 hour
|
|
103
|
+
check: 60 * 1000 // Check for expired refs every minute
|
|
104
|
+
}
|
|
105
|
+
},
|
|
106
|
+
|
|
107
|
+
// Inline listener cleanup (for createInlineButton, etc.)
|
|
108
|
+
inlineListeners: {
|
|
109
|
+
autoClear: {
|
|
110
|
+
ttl: 15 * 60 * 1000, // 15 minutes TTL
|
|
111
|
+
check: 60 * 1000 // Check every minute
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
module.exports = dbi;
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
### Configuration Options Reference
|
|
120
|
+
|
|
121
|
+
| Option | Type | Description |
|
|
122
|
+
|--------|------|-------------|
|
|
123
|
+
| `strict` | `boolean` | Throw errors for duplicate registrations |
|
|
124
|
+
| `discord.token` | `string` | Your bot token |
|
|
125
|
+
| `discord.options` | `ClientOptions` | Discord.js client options |
|
|
126
|
+
| `defaults.locale.name` | `string` | Default locale name |
|
|
127
|
+
| `defaults.locale.invalidPath` | `string \| function` | Message/function for missing locale paths |
|
|
128
|
+
| `defaults.defaultMemberPermissions` | `string[]` | Required permissions for commands |
|
|
129
|
+
| `defaults.directMessages` | `boolean` | Allow commands in DMs |
|
|
130
|
+
| `references.autoClear.ttl` | `number` | Reference time-to-live (ms) |
|
|
131
|
+
| `references.autoClear.check` | `number` | Cleanup check interval (ms) |
|
|
132
|
+
| `sharding` | `"hybrid" \| "default" \| "off"` | Sharding mode |
|
|
133
|
+
| `store` | `DBIStore` | Custom persistent store |
|
|
134
|
+
|
|
135
|
+
---
|
|
136
|
+
|
|
137
|
+
### 2. Create Your First Command (`src/commands/ping.js`)
|
|
138
|
+
|
|
139
|
+
```javascript
|
|
140
|
+
const dbi = require("../../dbi");
|
|
141
|
+
|
|
142
|
+
dbi.register(({ ChatInput }) => {
|
|
143
|
+
ChatInput({
|
|
144
|
+
name: "ping",
|
|
145
|
+
description: "Check the bot's latency",
|
|
146
|
+
|
|
147
|
+
async onExecute({ interaction, dbi }) {
|
|
148
|
+
const ws = dbi.client().client.ws.ping;
|
|
149
|
+
const start = Date.now();
|
|
150
|
+
|
|
151
|
+
await interaction.deferReply();
|
|
152
|
+
|
|
153
|
+
const roundtrip = Date.now() - start;
|
|
154
|
+
|
|
155
|
+
await interaction.editReply(
|
|
156
|
+
`🏓 **Pong!**\n` +
|
|
157
|
+
`> WebSocket: \`${ws}ms\`\n` +
|
|
158
|
+
`> Roundtrip: \`${roundtrip}ms\``
|
|
159
|
+
);
|
|
160
|
+
}
|
|
161
|
+
});
|
|
162
|
+
});
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
---
|
|
166
|
+
|
|
167
|
+
### 3. Create an Event Handler (`src/events/ready.js`)
|
|
168
|
+
|
|
169
|
+
```javascript
|
|
170
|
+
const dbi = require("../../dbi");
|
|
171
|
+
|
|
172
|
+
dbi.register(({ Event }) => {
|
|
173
|
+
Event({
|
|
174
|
+
name: "clientReady",
|
|
175
|
+
id: "ready-handler", // Unique ID for multiple handlers of same event
|
|
176
|
+
|
|
177
|
+
onExecute({ client }) {
|
|
178
|
+
console.log(`✅ Bot is online!`);
|
|
179
|
+
console.log(`📊 Serving ${client.guilds.cache.size} guilds`);
|
|
180
|
+
|
|
181
|
+
// Set bot status
|
|
182
|
+
client.user.setActivity({
|
|
183
|
+
name: "with DBI",
|
|
184
|
+
type: 0 // Playing
|
|
185
|
+
});
|
|
186
|
+
}
|
|
187
|
+
});
|
|
188
|
+
});
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
---
|
|
192
|
+
|
|
193
|
+
### 4. Create the Login Script (`login.js`)
|
|
194
|
+
|
|
195
|
+
```javascript
|
|
196
|
+
const { Utils } = require("@mostfeatured/dbi");
|
|
197
|
+
const dbi = require("./dbi");
|
|
198
|
+
|
|
199
|
+
async function start() {
|
|
200
|
+
try {
|
|
201
|
+
// Recursively import all files in src/
|
|
202
|
+
// This makes DBI aware of all your commands, events, etc.
|
|
203
|
+
await Utils.recursiveImport("./src");
|
|
204
|
+
|
|
205
|
+
// Load all registered features into DBI
|
|
206
|
+
await dbi.load();
|
|
207
|
+
|
|
208
|
+
// Connect to Discord
|
|
209
|
+
await dbi.login();
|
|
210
|
+
|
|
211
|
+
console.log(`✅ Logged in as ${dbi.client().client.user.tag}`);
|
|
212
|
+
|
|
213
|
+
} catch (error) {
|
|
214
|
+
console.error("Failed to start bot:", error);
|
|
215
|
+
process.exit(1);
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
start();
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
---
|
|
223
|
+
|
|
224
|
+
### 5. Create the Publish Script (`publish.js`)
|
|
225
|
+
|
|
226
|
+
Commands must be published to Discord before they appear in the client.
|
|
227
|
+
|
|
228
|
+
```javascript
|
|
229
|
+
const { Utils } = require("@mostfeatured/dbi");
|
|
230
|
+
const dbi = require("./dbi");
|
|
231
|
+
|
|
232
|
+
async function publish() {
|
|
233
|
+
try {
|
|
234
|
+
await Utils.recursiveImport("./src");
|
|
235
|
+
await dbi.load();
|
|
236
|
+
|
|
237
|
+
// For development: Publish to a specific guild (instant updates)
|
|
238
|
+
await dbi.publish("Guild", "YOUR_GUILD_ID");
|
|
239
|
+
|
|
240
|
+
// For production: Publish globally (can take up to 1 hour)
|
|
241
|
+
// await dbi.publish("Global");
|
|
242
|
+
|
|
243
|
+
await dbi.unload();
|
|
244
|
+
console.log("✅ Commands published successfully!");
|
|
245
|
+
|
|
246
|
+
} catch (error) {
|
|
247
|
+
console.error("Failed to publish commands:", error);
|
|
248
|
+
process.exit(1);
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
publish();
|
|
253
|
+
```
|
|
254
|
+
|
|
255
|
+
---
|
|
256
|
+
|
|
257
|
+
### 6. Set Up Environment Variables
|
|
258
|
+
|
|
259
|
+
Create a `.env` file (never commit this!):
|
|
260
|
+
|
|
261
|
+
```env
|
|
262
|
+
DISCORD_TOKEN=your_bot_token_here
|
|
263
|
+
```
|
|
264
|
+
|
|
265
|
+
Install dotenv:
|
|
266
|
+
```bash
|
|
267
|
+
npm install dotenv
|
|
268
|
+
```
|
|
269
|
+
|
|
270
|
+
Add to top of `dbi.js`:
|
|
271
|
+
```javascript
|
|
272
|
+
require("dotenv").config();
|
|
273
|
+
```
|
|
274
|
+
|
|
275
|
+
---
|
|
276
|
+
|
|
277
|
+
## Running Your Bot
|
|
278
|
+
|
|
279
|
+
### Publish Commands First
|
|
280
|
+
|
|
281
|
+
```bash
|
|
282
|
+
node publish.js
|
|
283
|
+
```
|
|
284
|
+
|
|
285
|
+
### Start the Bot
|
|
286
|
+
|
|
287
|
+
```bash
|
|
288
|
+
node login.js
|
|
289
|
+
```
|
|
290
|
+
|
|
291
|
+
---
|
|
292
|
+
|
|
293
|
+
## Development Workflow
|
|
294
|
+
|
|
295
|
+
1. **Make changes** to your commands/events/components
|
|
296
|
+
2. **Restart the bot** to apply changes
|
|
297
|
+
3. **Republish commands** only if you changed command names, descriptions, or options
|
|
298
|
+
|
|
299
|
+
> **Tip:** For faster development, publish to a guild instead of globally. Guild command updates are instant!
|
|
300
|
+
|
|
301
|
+
---
|
|
302
|
+
|
|
303
|
+
## TypeScript Setup
|
|
304
|
+
|
|
305
|
+
### tsconfig.json
|
|
306
|
+
|
|
307
|
+
```json
|
|
308
|
+
{
|
|
309
|
+
"compilerOptions": {
|
|
310
|
+
"target": "ES2020",
|
|
311
|
+
"module": "commonjs",
|
|
312
|
+
"lib": ["ES2020"],
|
|
313
|
+
"strict": true,
|
|
314
|
+
"esModuleInterop": true,
|
|
315
|
+
"skipLibCheck": true,
|
|
316
|
+
"forceConsistentCasingInFileNames": true,
|
|
317
|
+
"outDir": "./dist",
|
|
318
|
+
"rootDir": "./src",
|
|
319
|
+
"declaration": true
|
|
320
|
+
},
|
|
321
|
+
"include": ["src/**/*"],
|
|
322
|
+
"exclude": ["node_modules"]
|
|
323
|
+
}
|
|
324
|
+
```
|
|
325
|
+
|
|
326
|
+
### TypeScript Example (`src/commands/ping.ts`)
|
|
327
|
+
|
|
328
|
+
```typescript
|
|
329
|
+
import { createDBI } from "@mostfeatured/dbi";
|
|
330
|
+
|
|
331
|
+
// Import your DBI instance
|
|
332
|
+
import dbi from "../../dbi";
|
|
333
|
+
|
|
334
|
+
dbi.register(({ ChatInput }) => {
|
|
335
|
+
ChatInput({
|
|
336
|
+
name: "ping",
|
|
337
|
+
description: "Check latency",
|
|
338
|
+
async onExecute({ interaction, dbi }) {
|
|
339
|
+
const latency = dbi.client().client.ws.ping;
|
|
340
|
+
await interaction.reply(`Pong! ${latency}ms`);
|
|
341
|
+
}
|
|
342
|
+
});
|
|
343
|
+
});
|
|
344
|
+
```
|
|
345
|
+
|
|
346
|
+
---
|
|
347
|
+
|
|
348
|
+
## Next Steps
|
|
349
|
+
|
|
350
|
+
Now that you have a basic bot running, explore these guides:
|
|
351
|
+
|
|
352
|
+
1. **[Chat Input Commands](./CHAT_INPUT.md)** - Learn about slash commands and options
|
|
353
|
+
2. **[Components](./COMPONENTS.md)** - Add buttons, select menus, and modals
|
|
354
|
+
3. **[Events](./EVENTS.md)** - Handle Discord events
|
|
355
|
+
4. **[Localization](./LOCALIZATION.md)** - Support multiple languages
|
|
356
|
+
5. **[Advanced Features](./ADVANCED_FEATURES.md)** - Rate limiting, references, and more
|
|
357
|
+
|
|
358
|
+
---
|
|
359
|
+
|
|
360
|
+
## Troubleshooting
|
|
361
|
+
|
|
362
|
+
### Commands not appearing?
|
|
363
|
+
|
|
364
|
+
1. Make sure you published commands: `node publish.js`
|
|
365
|
+
2. For global commands, wait up to 1 hour
|
|
366
|
+
3. Check bot has `applications.commands` scope
|
|
367
|
+
4. Verify the bot is in the guild
|
|
368
|
+
|
|
369
|
+
### Bot not responding?
|
|
370
|
+
|
|
371
|
+
1. Check the bot has required permissions
|
|
372
|
+
2. Verify intents are properly configured
|
|
373
|
+
3. Check for errors in console
|
|
374
|
+
4. Ensure `dbi.load()` was called before `dbi.login()`
|
|
375
|
+
|
|
376
|
+
### "Missing Access" error?
|
|
377
|
+
|
|
378
|
+
1. Invite bot with proper permissions
|
|
379
|
+
2. Check channel permissions
|
|
380
|
+
3. Verify bot role position
|
|
381
|
+
|
|
382
|
+
### Token errors?
|
|
383
|
+
|
|
384
|
+
1. Regenerate token in Discord Developer Portal
|
|
385
|
+
2. Check `.env` file is being loaded
|
|
386
|
+
3. Ensure no spaces around the `=` in `.env`
|
|
387
|
+
|
|
388
|
+
---
|
|
389
|
+
|
|
390
|
+
## Getting Help
|
|
391
|
+
|
|
392
|
+
- Check the [documentation](./README.md)
|
|
393
|
+
- Review the [examples](../test/)
|
|
394
|
+
- Report issues on GitHub
|