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
Show all changes
27 commits
Select commit Hold shift + click to select a range
c36f01e
feat(locale): use redis to fetch locale when needed (#86)
dev-737 Jul 21, 2024
1a27fa8
refactor(decorators): decorated command methods now utilize `this` cl…
dev-737 Jul 26, 2024
910979c
refactor(locale): type-safe locale functions
dev-737 Jul 26, 2024
ebb91f3
chore: move `src/utils/RegisterCmdsCli.ts` to `scripts/deploy-command…
dev-737 Jul 27, 2024
65f6974
chore: update readme and add contributing guidelines
dev-737 Jul 27, 2024
47e72ab
ci: fix lint ci
dev-737 Jul 27, 2024
55934db
refactor: small scripts refactor
dev-737 Jul 29, 2024
e8b3279
refactor: move some methods from utils to userManager
dev-737 Jul 29, 2024
afe4503
refactor: more random refactors
dev-737 Jul 29, 2024
d5e02bc
refactor: use import mapping for all imports
dev-737 Aug 7, 2024
c9234d1
refactor(pagination): move pagination to its own class
dev-737 Aug 10, 2024
07b2415
fix: resolve some eslint errors
dev-737 Aug 10, 2024
f7215ac
refactor(events): move events to seperate classes under `events/` folder
dev-737 Aug 11, 2024
6f4ab25
refactor(network): refactor checks function
dev-737 Aug 11, 2024
55d0681
refactor(basecommand): get userManager through client
dev-737 Aug 11, 2024
f997af8
refactor(scripts): use `typescript` lib to generate types
dev-737 Aug 11, 2024
9a96087
refactor(cache): redo cache system to be used only when required
dev-737 Aug 15, 2024
3d7c378
refactor(messagecreate): simplify code
dev-737 Aug 17, 2024
6065b2a
refactor(messageinfo): use collectors & improve readability
dev-737 Aug 17, 2024
956d973
refactor: dont sync botlist stats if clientId doesnt match
dev-737 Aug 18, 2024
0e708af
feat: util refactors
dev-737 Aug 18, 2024
7ad404c
refactor: antispam brainfart
dev-737 Aug 18, 2024
f37ccb8
refactor(hub): improve readability of /hub moderator command
dev-737 Aug 19, 2024
a61b586
refactor: `/hub moderator`, goal notifs, pagination refactor
dev-737 Aug 20, 2024
79c5290
refactor: fix some deepsource errors
dev-737 Aug 20, 2024
a6af185
fix(cache): dont cache null data
dev-737 Aug 20, 2024
9d29cb7
refactor: more deepsource fixes
dev-737 Aug 20, 2024
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
13 changes: 0 additions & 13 deletions .env.example

This file was deleted.

19 changes: 12 additions & 7 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,24 @@ jobs:
tests:
name: Lint Check
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
strategy:
matrix:
node-version: [20]

- name: Install node.js
steps:
- uses: actions/checkout@v4
- name: Install pnpm
uses: pnpm/action-setup@v4
with:
version: 9.6.0
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: 20
node-version: ${{ matrix.node-version }}
cache: 'pnpm'
cache-dependency-path: pnpm-lock.yaml

- name: Install dependencies
run: pnpm add eslint

- name: Lint files
run: pnpm lint
run: pnpm eslint --no-fix src/
6 changes: 3 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ tsconfig.tsbuildinfo
/logs/

# Configuration
.env
.env*

# Unit test coverage
__tests__/
Expand All @@ -25,5 +25,5 @@ build/
# Sentry Auth Token
.sentryclirc

# Yarn 4 state file
.yarn/install-state.gz
# Redis dev
dump.rdb
78 changes: 78 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
# Contributing to InterChat

We welcome contributions to InterChat! Whether you're fixing bugs, adding new features, or improving documentation, your help is appreciated.

## Getting Started

1. **Fork the Repository:** Click on the "Fork" button in the top-right corner of this page.
2. **Clone Your Fork:** Use `git clone` to clone your forked repository to your local machine.
3. **Create a Branch:** It's good practice to create a new branch for each feature or bug fix:

```sh
git checkout -b feature/new-feature
```

## Making Changes

- **Follow Coding Standards:** Adhere to the project's coding conventions and style guides. If you're unsure, refer to existing code or ask for guidance.
- **Include Tests:** If you're adding new features or fixing bugs, include tests to ensure your changes work as expected and don't break existing functionality.
- **Documentation:** Update the README.md and other relevant documentation if your changes affect how the bot is used or deployed.
- **Write Clear, Concise Commits:** Each commit should have a clear and concise message explaining what changes were made and why. Use semantic commit messages in your commit messages as it will make auto-releases and changelog updates easier.

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

- `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
- `docs`: changes to the documentation
- `style`: formatting, missing semi colons, etc; no production code change
- `refactor`: refactoring production code, eg. renaming a variable
- `test`: adding missing tests, refactoring tests; no production code change
- `chore`: updating grunt tasks etc; no production code change

### Commitizen Friendly

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.

> [!IMPORTANT]
> Make sure to run `npm i commitizen --global` first. It won't work if you haven't.

![commitizen](https://commitizen-tools.github.io/commitizen/images/demo.gif)

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

## 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.

## Submitting Your Changes

- **Push Your Branch:** Push your branch to your forked repository:

```sh
git cz
git push origin feature/new-feature
```

- **Open a Pull Request:** Go to the original repository and open a pull request (PR) from your branch to the main branch. Include a detailed description of your changes and any relevant issues or discussions.

## Code Review

Your pull request will be reviewed by the maintainers. Please be responsive to feedback and ready to make necessary changes. Once approved, your changes will be merged into the main branch.

## Reporting Issues

If you encounter any issues or bugs, please report them by creating a new issue in the GitHub repository. Provide as much detail as possible, including steps to reproduce the issue and any relevant logs or screenshots.

## Community

Join our [Discord server](https://interchat.fun/support) to connect with other contributors and discuss the project. Be respectful and follow the community guidelines.

Thank you for contributing to InterChat!
1 change: 0 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ COPY locales ./locales
COPY prisma ./prisma
COPY tsconfig.json .
COPY package.json .
COPY .yarnrc.yml .

RUN pnpm install
RUN npm rebuild @tensorflow/tfjs-node --build-from-source
Expand Down
90 changes: 25 additions & 65 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,44 +2,47 @@

<p align="center"><strong>InterChat</strong></p>

[![Maintainability](https://api.codeclimate.com/v1/badges/b13854f1a4e321cbdea5/maintainability)](https://codeclimate.com/repos/65e14df13087a11dde64b238/maintainability)
[![CodeFactor](https://www.codefactor.io/repository/github/discord-interchat/interchat/badge)](https://www.codefactor.io/repository/github/discord-interchat/interchat)
[![Discord Bots](https://top.gg/api/widget/servers/769921109209907241.svg/)](https://top.gg/bot/769921109209907241)


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.

# ❗Contributors Needed ❗

InterChat is an open-source project that connects communities across Discord servers. We're actively looking for contributors to help us improve and expand this project!

## How You Can Help

- **Feature Development:** Help us build new features that make cross-server communication even more seamless.
- **Bug Fixes:** Assist in identifying and squashing bugs to enhance stability and performance.
- **Documentation:** Improve our documentation to make it easier for others to get involved and use InterChat.
- **Testing:** Contribute to testing new features and updates, ensuring everything works smoothly.

# Getting Started

## Prerequisites

1. [Node.js](https://nodejs.org/)
2. [Git](https://git-scm.com/downloads)
3. [MongoDB](https://www.mongodb.com/try/download/community)
4. A Node Package Manager ([NPM](https://www.npmjs.com/get-npm)/[Yarn](https://yarnpkg.com/getting-started/install)/PNPM)
5. [An Imgur API Key](https://api.imgur.com/oauth2/addclient) (optional, for setting hub icon and banner)
6. [Python 3.9.13](https://www.python.org/downloads/release/python-3913/) & [Visual Studio Build Tools (Windows Only)](https://visualstudio.microsoft.com/downloads/#build-tools-for-visual-studio-2019) (for Tensorflow)
4. [An Imgur API Key](https://api.imgur.com/oauth2/addclient) (optional, for setting hub icon and banner)
5. [Python 3.9.13](https://www.python.org/downloads/release/python-3913/) & [Visual Studio Build Tools (Windows Only)](https://visualstudio.microsoft.com/downloads/#build-tools-for-visual-studio-2019) (for Tensorflow)

## 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.
3. Install dependencies using `npm install` or `yarn`
4. Build the code using `npm run build`
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

## 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`
1. Create a file called `.env` and fill it out with the appropriate contents
2. Install the dependencies
3. Build the code using `pnpm build`
4. Register commands for your bot using `pnpm deploy-commands --public --private`
5. Finally run the code using `pnpm dev`. `pnpm start` to run in production mode

## Creating Commands

To add a new command, follow these steps:

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:
3. Include:
- A `data` property to store the slash command builder or raw command JSON.
- An `execute` method to handle incoming commands.

Expand Down Expand Up @@ -89,74 +92,31 @@ const customId = CustomID.parseCustomId(interaction.customId);

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:

```typescript
```ts
// you can change the type of `interaction` to ButtonInteraction etc. if you are aware of the type of component
@InteractionHandler('cool_button_')
static override async handleComponents(interaction: MessageComponentInteraction) {
override async handleComponents(interaction: MessageComponentInteraction) {
const customId = CustomID.parseCustomId(interaction.customId);
// 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 set the CLIENT_ID to your bot's ID in `.env`.

### Tensorflow Errors

If you are facing errors that looks like this during runtime:
Some Windows users face the following problem:

```sh
Error: The specified module could not be found.
\\?\C:\Users\<username>\...otherpathstuff\InterChat\node_modules\@tensorflow\tfjs-node\lib\napi-v8\tfjs_binding.node
```

Don't worry, because some Windows users face this problem. A simple fix would be to copy `node_modules/@tensorflow/tfjs-node/lib/napi-v9/tensorflow.dll` into `node_modules/@tensorflow/tfjs-node/lib/napi-v8/`. Everything should work fine after that.
A simple fix would be to copy `node_modules/@tensorflow/tfjs-node/lib/napi-v9/tensorflow.dll` into `node_modules/@tensorflow/tfjs-node/lib/napi-v8/`. Everything should work fine after that. (just use linux frfr)

## Contributing

### Commit Messages

Use semantic commit messages in your commit messages as it will make auto-releases and changelog updates easier.

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

- `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)

- `docs`: (changes to the documentation)

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

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

- `test`: (adding missing tests, refactoring tests; 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.

> [!IMPORTANT]
> Make sure to run `npm i commitizen --global` first. It won't work if you haven't.

![commitizen](https://commitizen-tools.github.io/commitizen/images/demo.gif)

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

### 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.
Please refer to the [CONTRIBUTING.md](./CONTRIBUTING.md) file for guidelines on how to contribute to this project.
2 changes: 1 addition & 1 deletion locales
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@
"start:prod": "pm2 start .ecosystem.config.js",
"build": "tsc --build",
"dev": "tsc-watch --outDir ./build --onSuccess \"node --trace-warnings --import ./build/instrument.js .\"",
"register:commands": "node build/utils/RegisterCmdCli.js",
"deploy-commands": "node scripts/deploy-commands.js",
"release": "release-it",
"lint": "eslint --cache --fix ./src",
"prepare": "husky",
"postinstall": "prisma generate && node scripts/genLocaleTypes.js"
},
"engines": {
"node": ">=v20.15.1"
"node": ">=v20.16.0"
},
"type": "module",
"dependencies": {
Expand Down Expand Up @@ -73,5 +73,5 @@
"#main/*.js": "./build/*.js",
"#commands/*.js": "./build/commands/*.js"
},
"packageManager": "pnpm@9.5.0"
"packageManager": "pnpm@9.6.0"
}
9 changes: 0 additions & 9 deletions prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,6 @@ type HubModerator {
// honestly... I might as well make permissions lol
}

// type HubSettings {
// useNicknames Boolean @default(false)
// allowInvites Boolean @default(true)
// allowLinks Boolean @default(true)
// allowReactions Boolean @default(true)
// profanityFilter Boolean @default(false)
// spamFilter Boolean @default(true)
// }

type HubLogChannels {
modLogs String?
joinLeaves String?
Expand Down
Loading