Skip to content
This repository was archived by the owner on Oct 9, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
TOKEN="discord bot token here"
MONGODB_URI="mongodb connection url here" # Format: mongodb+srv://<name>:<password>@uri/dbname
DATABASE_URL="mongodb connection url here" # get it from mongodb atlas or use local mongodb
TOPGG_API_KEY="your topgg bot access token>" # not required if you don't have a bot on top.gg.
TENOR_KEY="tenor api key" # required for posting gifs in global chat.
SENTRY_DSN="your sentry dsn link" # get it from sentry.io
SENTRY_AUTH_TOKEN="your sentry auth token" # get it from devoid
NODE_ENV=development # change to production when deploying
IMGUR_CLIENT_ID="imgur client id" # get it from imgur
IMGUR_CLIENT_SECRET="imgur client secret" # get it from imgur
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "locales"]
path = locales
url = https://github.com/Discord-InterChat/locales.git
96 changes: 48 additions & 48 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,18 @@

This repo contains the source code for the InterChat Discord bot. InterChat is a Discord bot that allows you to chat with users from other servers.

## Getting Started
# Getting Started

### Prerequisites
## Prerequisites

1. [Node.js v18.0.0](https://nodejs.org/en/download/current/)
1. [Node.js v18.0.0](https://nodejs.org/en/download/current/), or higher for linux users
2. [Git](https://git-scm.com/downloads)
3. [MongoDB](https://www.mongodb.com/try/download/community)
4. [NPM](https://www.npmjs.com/get-npm) or [Yarn](https://yarnpkg.com/getting-started/install) (we are using npm in this guide)
5. [An Imgur API Key](https://api.imgur.com/oauth2/addclient) (optional, for setting hub icon and banner)
6. [Python 3.8+](https://www.python.org/downloads/) & [Visual Studio Build Tools (Windows Only)](https://visualstudio.microsoft.com/downloads/#build-tools-for-visual-studio-2019) (optional, for the API)
> [!NOTE]
> If you are on Windows, you will need to delete the `api/package-lock.json` before installing dependencies. And if that doesn't work, run `npm i` in a terminal with admin privileges. And if you're getting errors related to node-gyp, install `node-gyp` globally using `npm i -g node-gyp`. Or follow the [Installation Instructions](https://github.com/nodejs/node-gyp?tab=readme-ov-file#on-windows). Honestly, why are you on Windows? You can also just re-install Node.js and tick the "Automatically install the necessary tools" option, which should do all the stuff mentioned above for you.
6. [Python 2.7](https://www.python.org/downloads/release/python-2718/) & [Visual Studio Build Tools (Windows Only)](https://visualstudio.microsoft.com/downloads/#build-tools-for-visual-studio-2019) (for the API)

### Setting up the bot
## Running the code

1. Clone the repository using `git clone` or download the zip file.
2. Create a file called `.env` and fill it out with the appropriate contents mentioned in the env.example file.
Expand All @@ -26,29 +24,37 @@ This repo contains the source code for the InterChat Discord bot. InterChat is a
5. Register commands for your bot using `npm run register:commands --public` & `npm run register:commands --private`
6. Finally run the code using `npm run dev`, or `npm start` to run in production mode

### Setting up the database
## Database Setup

1. Create a MongoDB instance on [MongoDB Atlas](https://www.mongodb.com/cloud/atlas/register)
2. Copy the database connection string and paste it in the `.env` file as `MONGODB_URI`

### Creating new commands
## Creating Commands

To create a new command, create a new file in the `src/commands` directory with the name of the command. The file should export a **default** class that extends the `BaseCommand` class found in the `src/commands/BaseCommand.ts` file. This class is expected to include the following methods and properties:
To add a new command, follow these steps:

1. A `data` property, which should store the slash command builder or raw command JSON.
2. An `execute` method responsible for handling incoming commands.
1. Create a new file in the `src/commands` directory with the command's name.
2. In this file, export a **default** class that extends the `BaseCommand` class from `src/commands/BaseCommand.ts`.
3. The class should include:
- A `data` property to store the slash command builder or raw command JSON.
- An `execute` method to handle incoming commands.

Additionally, there are various optional methods and properties at your disposal for further customization. Have a look at `src/commands/BaseCommand.ts` for more information.
You can also explore various other methods and properties for additional customization by referring to `src/commands/BaseCommand.ts` for more details.

#### Subcommands
### Subcommands

To create a subcommand, create a new file called `index.ts` in the `src/commands/<command name>/` directory. The file must export a **default class** that extends the `BaseCommand` class from the `src/commands/BaseSubCommand.ts` file like usual. Then create additional files in the same directory with the name of the subcommands. The file must export another **default class** that extends the class was just created in `./index.ts`. It is important to note that subcommand **file names must be the same as the subcommand name** registered on discord.
To add a subcommand, follow these steps:

### Adding cooldowns
1. Create a new file named `index.ts` in the `src/commands/<command name>/` directory.
2. In this file, export a **default class** that extends the `BaseCommand` class found in `src/commands/BaseSubCommand.ts`.
3. Create additional files in the same directory, each named after a subcommand.
4. In each of these files, export a **default class** that extends the class created in `./index.ts`. Ensure that the subcommand file names match the registered subcommand names on Discord.

## Adding cooldowns

To add a cooldown to a command/subcommand, simply add a `cooldown` property to the class with the value being the cooldown in milliseconds. The cooldown will be applied to the user who executed the command.

### Creating Custom IDs
## Creating Custom IDs

To help with handling components, we have a custom ID class that can be used to create custom IDs for components. To create a custom ID, simply call the `CustomID` method with the custom ID prefix and the custom postfix. Example:

Expand All @@ -71,13 +77,13 @@ const customId = CustomID.parseCustomId(interaction.customId);
/* {
prefix: string,
postfix: string,
expiry: Date,
expiry?: Date,
args?: string[],
};
*/
```

### Handling components
## Handling components

To handle components (buttons, selects, modals) create a new method called `handleComponents` or `handleModals` for modals in the command/subcommand class. Then create a decorator for the method using the `@InteractionHandler` decorator with the customId prefix of the components/modals. The method will be called when the component is triggered. Example:

Expand All @@ -86,35 +92,22 @@ To handle components (buttons, selects, modals) create a new method called `hand
@InteractionHandler('cool_button_')
public async handleComponents(interaction: MessageComponentInteraction) {
const customId = CustomID.parseCustomId(interaction.customId);
// handle component logic, same as how its with collectors
// handle component logic, same as how it is with collectors
}
```

## Other information

* Events are located in `src/InterChat.ts`.
* Commands are loaded automatically by calling the `loadCommandFiles` method from `src/managers/CommandManager.ts` during the bot startup.
* The `src/commands/BaseCommand.ts` file contains all the methods/properties that can be used in a command.
* We use the `interactionCreate` event for handling **all** interactions instead of using collectors.
* If you are using your own bot for testing, make sure to change the CLIENT_ID in `src/utils/Constants.ts` like so:
- Events are located in `src/InterChat.ts`.
- Commands are loaded automatically by calling the `loadCommandFiles` method from `src/managers/CommandManager.ts` during the bot startup.
- The `src/commands/BaseCommand.ts` file contains all the methods/properties that can be used in a command.
- We use the `interactionCreate` event for handling **all** interactions instead of using collectors.
- If you are using your own bot for testing, make sure to change the CLIENT_ID in `src/utils/Constants.ts` like so (don't commit this change):

```ts
export const CLIENT_ID = isDevBuild ? '<new_client_id_here>' : '769921109209907241';
```

## Special Comments

These are comments to show the state of a piece of code. Install
the "Todo Tree" extension to highlight them in VS-Code.

1. `TODO` - Something that must be finished before releasing, a reminder.

2. `REVIEW` - Review a piece of code to see if there is a better alternative.

3. `FIXME` - To change later to avoid facing problems, a bug that must be fixed before release.

4. `NOTE` - A note left for later, something important or something that shows how something is supposed to be used/works.

## Contributing

### Commit Messages
Expand All @@ -123,19 +116,19 @@ Use semantic commit messages in your commit messages as it will make auto-releas

[Examples](https://gist.github.com/joshbuchea/6f47e86d2510bce28f8e7f42ae84c716):

* `feat`: (new feature for the user, not a new feature for build script)
- `feat`: (new feature for the user, not a new feature for build script)

* `fix`: (bug fix for the user, not a fix to a build script)
- `fix`: (bug fix for the user, not a fix to a build script)

* `docs`: (changes to the documentation)
- `docs`: (changes to the documentation)

* `style`: (formatting, missing semi colons, etc; no production code change)
- `style`: (formatting, missing semi colons, etc; no production code change)

* `refactor`: (refactoring production code, eg. renaming a variable)
- `refactor`: (refactoring production code, eg. renaming a variable)

* `test`: (adding missing tests, refactoring tests; no production code change)
- `test`: (adding missing tests, refactoring tests; no production code change)

* `chore`: (updating grunt tasks etc; no production code change)
- `chore`: (updating grunt tasks etc; no production code change)

To make our lives easier by not having to remember the commit messages at all times, this repository is [commitizen](https://www.npmjs.com/package/commitizen) friendly! Commitizen is a commandline tool that guides you through the process of choosing your desired commit type.

Expand All @@ -146,8 +139,15 @@ To make our lives easier by not having to remember the commit messages at all ti

Run `git cz` or `cz commit` to commit using commitizen.

## Achievements & Goals
### Special Comments

These are comments to show the state of a piece of code. Install
the "Todo Tree" extension to highlight them in VS-Code.

* [x] 1000 servers using InterChat 🎉
1. `TODO` - Something that must be finished before releasing, a reminder.

* [ ] 101 votes on topgg in a month
2. `REVIEW` - Review a piece of code to see if there is a better alternative.

3. `FIXME` - To change later to avoid facing problems, a bug that must be fixed before release.

4. `NOTE` - A note left for later, something important or something that shows how something is supposed to be used/works.
3 changes: 0 additions & 3 deletions api/.gitignore

This file was deleted.

42 changes: 0 additions & 42 deletions api/index.ts

This file was deleted.

Loading