TebexSync-Discord-Bot seamlessly integrates with your Tebex store to automatically grant buyers channel access and features a flexible ticket system with dynamic fields for efficient and organized support.
Important
This project is not affiliated in any way with Tebex Limited. It is a third party application provided and maintained by Maximus7474 to help organizations selling on tebex to grant customer roles on their discord server and provide systems to simplify purchase verification and providing support.
- Customizable Ticket Categories: Create multiple ticket categories, each with different prerequisites.
- Transaction ID Verification: Tickets can be configured to require a valid transaction ID from your Tebex store.
- Dynamic Forms: A modal form displays fields linked to the ticket category, with options for required inputs and minimum/maximum length.
- Support Workflow: Users can add others to a ticket, and the system includes a closure feature with an optional reason.
- Automatic Role Assignment: Customers who make a purchase with a linked Discord account will automatically receive their roles.
- Manual Claiming: Users without a linked account can claim their roles by using a command with their transaction ID.
- Developer Access: Customers can grant access to a configurable number of developers.
- Purchase Status Sync: Roles are automatically removed if a purchase is refunded, chargebacked, or canceled. These roles cannot be claimed again.
-
Copy the
.env.examplefile to.env:cp .env.template .env
-
Replace the following values in the
.envfile:DISCORD_BOT_TOKEN: Your bot's authentication token from Discord's developer portal.MAIN_GUILD_ID: The Discord ID of your main guild.
-
Run the setup script:
# if using npm npm run setup # if using pnpm pnpm run setup
This will install all packages, setup prisma and create the database.
- The TypeScript code is built using
tsc. - The
scripts/build.jsfile also transfers thebase.sqlfiles from thedatabasefolder to ensure smooth operation.
Note:
Building the project does not deploy the slash commands to Discord's API. You must run the deploy script to do so.
- Build the project:
pnpm run build
- Deploy the slash commands:
pnpm run deploy
Important:
The deploy script reads command data from the dist/ directory. Ensure you run the build script before deploying.
The bot uses Prisma as its ORM (Object-Relational Mapper) to interact with the database. By default, it's configured to use SQLite, making initial setup simple and quick since SQLite is file-based and requires no separate server.
If you need to change from SQLite to a different database like PostgreSQL or MySQL, you can do so by modifying the Prisma schema.
-
Modify the
schema.prismafile: Open theprisma/schema.prismafile. Locate thedatasource dbblock and change theproviderfield to your desired database.// For PostgreSQL datasource db { provider = "postgresql" url = env("DATABASE_URL") } // For MySQL datasource db { provider = "mysql" url = env("DATABASE_URL") }
-
Update the
.envfile: Change theDATABASE_URLin your.envfile to match your new database's connection string.# For PostgreSQL DATABASE_URL="postgresql://user:password@host:port/database?schema=public" # For MySQL DATABASE_URL="mysql://user:password@host:port/database"
When you make changes to your database schema in the prisma/schema.prisma file, you need to follow these steps to apply those changes to your database.
-
Generate the Prisma Client: After editing your schema, run the
prisma generatecommand. This command updates the generated Prisma Client with the new types and methods, ensuring your code remains type-safe.pnpm prisma generate
-
Run a Migration: To apply the schema changes to your actual database, you'll use Prisma Migrate. The
migrate devcommand creates a new migration file and applies it.pnpm prisma migrate dev --name <migration_name>
Replace
<migration_name>with a descriptive name for your changes (e.g.,add-user-model). This process ensures your database schema stays in sync with your Prisma schema.
For more detailed information on Prisma, including advanced migration strategies and different data modeling techniques, you can refer to the official documentation. 📖
Prisma Documentation: https://www.prisma.io/docs/
By default, the .env file is ignored by Git (via .gitignore).
If you disable this, it can lead to severe security risks, such as:
- Hackers gaining access to your authentication token and using it maliciously.
- Other unintended consequences.
To stay safe:
- Do not remove
.envfrom the.gitignorefile. - Ensure your
.envfile remains private.