InterChat
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.
InterChat is an open-source project that connects communities across Discord servers. We're on the lookout for passionate contributors to help us take this project to the next level!
- 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.
- Explore our good first issues to tackle beginner-friendly tasks or bug fixes.
- Or browse through all our issues and pick one that catches your eye!
- Interested in improving our documentation/guides? Check out our docs repository and start contributing!
Please refer to the CONTRIBUTING.md file for guidelines on how to contribute to this project. Thank you!
- Node.js
- Git
- MongoDB
- An Imgur API Key (optional, for setting hub icon and banner)
- Python 3.9.13 & Visual Studio Build Tools (Windows Only) (for Tensorflow)
- Create a file called
.env
and fill it out with the appropriate contents - Install the dependencies
- Build the code using
pnpm build
- Register commands for your bot using
pnpm deploy-commands --public --private
- Finally run the code using
pnpm dev
.pnpm start
to run in production mode
To add a new command, follow these steps:
- Create a new file in the
src/commands
directory with the command's name. - In this file, export a default class that extends the
BaseCommand
class fromsrc/commands/BaseCommand.ts
. - Include:
- A
data
property to store the slash command builder or raw command JSON. - An
execute
method to handle incoming commands.
- A
You can also explore various other methods and properties for additional customization by referring to src/commands/BaseCommand.ts
for more details.
To add a subcommand, follow these steps:
- Create a new file named
index.ts
in thesrc/commands/<command name>/
directory. - In this file, export a default class that extends the
BaseCommand
class found insrc/commands/BaseSubCommand.ts
. - Create additional files in the same directory, each named after a subcommand.
- 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.
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.
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 suffix. Example:
const customId = new CustomID()
.setIdentifier('cool_button_', '1') // add a prefix and a suffix
.addArgs('arg1', 'arg2') // to add extra info like executor ID, page number, etc.
.toString(); // convert it to a string to use it as a custom ID
// add arguments to the custom ID
It can be later parsed when handling the component using the CustomID.parseCustomId
method. Example:
const customId = CustomID.parseCustomId(interaction.customId);
// this will return an object containing the following:
/* {
prefix: string,
suffix: string,
expiry?: Date,
args?: string[],
};
*/
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:
// you can change the type of `interaction` to ButtonInteraction etc. if you are aware of the type of component
@InteractionHandler('cool_button_')
override async handleComponents(interaction: MessageComponentInteraction) {
const customId = CustomID.parseCustomId(interaction.customId);
// handle component logic, same as how it is with collectors
}
- 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
.
Some Windows users face the following problem:
Error: The specified module could not be found.
\\?\C:\Users\<username>\...otherpathstuff\InterChat\node_modules\@tensorflow\tfjs-node\lib\napi-v8\tfjs_binding.node
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)
Please refer to the CONTRIBUTING.md file for guidelines on how to contribute to this project.