Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
1f98e74
Remove source code to src folder
zhiyan114 Jun 21, 2023
fc430eb
Added tsconfig
zhiyan114 Jun 21, 2023
8cb500a
Moved deploy command
zhiyan114 Jun 21, 2023
a984f43
More config for ts support
zhiyan114 Jun 21, 2023
79dacb8
Added types for index.ts
zhiyan114 Jun 21, 2023
c090970
Added eslint typescript support
zhiyan114 Jun 21, 2023
524e9ca
Converted deploy commands to ts
zhiyan114 Jun 21, 2023
fb27226
Replaced pgsqlDriver with types
zhiyan114 Jun 21, 2023
3682bc4
Converted all commands to ts
zhiyan114 Jun 21, 2023
c77fa0c
Added builder to support build test
zhiyan114 Jun 21, 2023
a3a33af
Inital Migration for #158; need more work for corrections
zhiyan114 Jun 22, 2023
865b9b5
Fixed eslint and more typescript stuff
zhiyan114 Jun 22, 2023
da54466
potentially fixed close.ts bugs due to invalid way of disabling buttons
zhiyan114 Jun 22, 2023
caf305f
fixed other close.ts usage
zhiyan114 Jun 22, 2023
1bf9002
Fixed claim.ts usage
zhiyan114 Jun 22, 2023
1b98308
fixed more util errors
zhiyan114 Jun 22, 2023
91db9ee
Removed unused import
zhiyan114 Jun 22, 2023
f7614c5
Removed unused import
zhiyan114 Jun 22, 2023
8954921
Converted interactionCreate
zhiyan114 Jun 22, 2023
13e35d2
Check for interaction guild to avoid ! assertation
zhiyan114 Jun 22, 2023
9ab69e6
option to disable telemetry and warns user #148
zhiyan114 Jun 22, 2023
bc35c7a
Types update
zhiyan114 Jun 22, 2023
8175a28
fixed some lint issues
zhiyan114 Jun 22, 2023
35ff035
Don't run action when PR is in draft & Run npm i during PR for full C…
zhiyan114 Jun 23, 2023
f4d7c4e
fixed some eslint stuff
zhiyan114 Jun 23, 2023
16401f0
fixed psqlDriver eslint
zhiyan114 Jun 23, 2023
f84c0a6
fix: Resolves #167
zhiyan114 Jun 23, 2023
ea60619
Refactor: Token uses env variable #160 & #158 seems to be stable enough
zhiyan114 Jun 23, 2023
6b3e8e9
refactor: Lint script will only check ts file
zhiyan114 Jun 23, 2023
f7c3234
Workflow use package.json script to run lint
zhiyan114 Jun 23, 2023
e96caf3
refactor: Replace disableTelemetry with minimalTracking, request by @…
zhiyan114 Jun 23, 2023
96518a2
Cleaned up eslint warnings
zhiyan114 Jun 23, 2023
a914e8e
Cleaned up some extra license message
zhiyan114 Jun 23, 2023
016b1b4
Fixed embed color bugs
zhiyan114 Jun 24, 2023
a10e4f6
removed quick.db module
zhiyan114 Jun 25, 2023
ae311c4
feat: Added prisma sql and its associated sql
zhiyan114 Jun 25, 2023
53e4c6b
Renamed some column names
zhiyan114 Jun 25, 2023
f713744
feat: Converted index and commands to support prisma
zhiyan114 Jun 25, 2023
29f5b1a
feat(events): Converted to Prisma system
zhiyan114 Jun 25, 2023
337ef9c
Added missing tickets column
zhiyan114 Jun 25, 2023
9237b67
Added missing 'closed' column
zhiyan114 Jun 25, 2023
c17dc54
Converted all code to use prisma #159
zhiyan114 Jun 25, 2023
e0c8cfe
Fixed bug preventing prisma from creating data
zhiyan114 Jun 25, 2023
cbb4df4
prisma save category as raw JSON string for now
zhiyan114 Jun 25, 2023
1d6c931
Fixed claim info not registered to db
zhiyan114 Jun 25, 2023
947b285
Merge pull request #170 from Sayrix/orm
zhiyan114 Jun 25, 2023
83968d6
Updated README to reflect new version
zhiyan114 Jun 25, 2023
c8af008
chores: Increment package.json version to 3.0.0
zhiyan114 Jun 25, 2023
8b203e3
fixed invalid LICENSE url in *.sql file
zhiyan114 Jun 25, 2023
7a8e91e
telemetry warning only on first startup and added emojis on update check
Sayrix Jun 25, 2023
2b2be88
Merge branch 'typescript' of https://github.com/Sayrix/ticket-bot int…
Sayrix Jun 25, 2023
478f57e
Removed database conn from config
zhiyan114 Jun 25, 2023
76ea22f
Merge branch 'typescript' of github.com:Sayrix/Ticket-Bot into typesc…
zhiyan114 Jun 25, 2023
c87476a
Added the possibility of having a uuid or emoji
Sayrix Jun 25, 2023
29001de
Merge branch 'typescript' of https://github.com/Sayrix/ticket-bot int…
Sayrix Jun 25, 2023
c7da65e
More relaxed embed creation policy through locales
zhiyan114 Jun 25, 2023
86629d2
Merge branch 'typescript' of github.com:Sayrix/Ticket-Bot into typesc…
zhiyan114 Jun 25, 2023
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
5 changes: 5 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Your discord token
TOKEN=""
# Prisma Database URL (refer to docs for more details)
# Refer to https://www.prisma.io/docs/concepts/database-connectors to use other databases
DATABASE_URL="file:./tixbot.db"
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ README.md
LICENSE
package.json
package-lock.json
dist/
23 changes: 0 additions & 23 deletions .eslintrc.js

This file was deleted.

27 changes: 27 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"env": {
"es2021": true,
"node": true
},
"overrides": [],
"extends": ["eslint:recommended", "prettier", "plugin:@typescript-eslint/recommended"],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": "latest",
"sourceType": "module"
},
"plugins": ["@typescript-eslint"],
"rules": {
"no-unused-vars": "warn",
"no-console": "off",
"no-undef": "warn",
"no-constant-condition": "warn",
"indent": ["error", "tab"],
"semi": ["error", "always"],
"quotes": [2, "double"],
"semi-style": ["error", "last"],
"no-process-exit": "off",
"node/no-missing-import": "off",
"no-var-requires": "off"
}
}
10 changes: 7 additions & 3 deletions .github/workflows/eslint.yml → .github/workflows/builder.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
name: ESLint Check
name: Source Check

on:
push:
branches:
- "main"
pull_request:
types: [review_requested, ready_for_review]

permissions:
contents: read
Expand Down Expand Up @@ -35,8 +36,11 @@ jobs:
key: node_modules-${{ matrix.os }}-${{ matrix.node-version }}-${{ hashFiles('package-lock.json') }}

- name: npm i
if: steps.cache-node_modules.outputs.cache-hit != 'true'
if: steps.cache-node_modules.outputs.cache-hit != 'true' || github.event_name == 'pull_request'
run: npm i --no-audit

- name: ESLint
run: npx --no-install eslint .
run: npm run lint:check

- name: build
run: npm run build --if-present
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,7 @@ node_modules
json.sqlite
package-lock.json
config.jsonc
token.json
token.json
dist
.env
*.db
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@ Ticket Bot is a open source project of an ticket discord bot using [discord.js](

The documentation is available [here](https://doc.ticket.pm/)

## ⚠️ Incompatibility
This new source code you're seeing are completely refactored and will be incompatible with the older version.
I recommend you finish up all of your remaining support ticket and start migrating to the newer version.
If you prefer to stay in the older version, you can download anything that is less than `3.0.0` from the release
or clone from the `old` branch (i.e. `git clone -b old https://github.com/Sayrix/Ticket-Bot.git`)

## 💬 Discord

You can come on the discord: https://discord.gg/VasYV6MEJy
Expand Down
32 changes: 8 additions & 24 deletions config/config.example.jsonc
Original file line number Diff line number Diff line change
@@ -1,31 +1,9 @@
{
"clientId": "1111111111111111111", // The id of the discord bot
"guildId": "1111111111111111111", // The id of the discord server
"mainColor": "f6c42f", // The hex color of the embeds by default
"mainColor": "#f6c42f", // The hex color of the embeds by default
"lang": "main", // If you want to set english please set "main"

/*
Pick a database driver, postgres will take priority over mysql (if both are enabled, which please don't do).
If neither option is enabled, SQLite will be used.
*PostgreSQL will be using default schema*
*/
"postgre": {
"enabled": false,
"host": "postgresql.example.com", // The host of the PostgreSQL database
"user": "postgres", // The user of the PostgreSQL database
"password": "password", // The password of the PostgreSQL database
"database": "postgres", // The name of the PostgreSQL database
"table": "json" // The name of the table where the tickets will be saved
},
"mysql": {
"enabled": false,
"host": "mysql.example.com", // The host of the MySQL database
"user": "mysql", // The user of the MySQL database
"password": "password", // The password of the MySQL database
"database": "ticketbot", // The name of the MySQL database
"table": "json" // The name of the table where the tickets will be saved
},

"closeTicketCategoryId": "", // The id of the category where a closed ticket will be moved to. Leave blank to disable this feature

"openTicketChannelId": "1111111111111111111", // The id of the channel where the message to create a ticket will be sent
Expand Down Expand Up @@ -99,6 +77,7 @@
"askReasonWhenClosing": true, // If false the ticket will be closed without asking the reason

"createTranscript": true, // If set to true, when the ticket is closed a transcript will be generated and sent in the logs channel
"uuidType": "uuid", // uuid or emoji

"status": {
"enabled": true, // If you want to enable the status of the bot
Expand All @@ -108,5 +87,10 @@
"status": "online" // online, idle, dnd, invisible set to online if the type is STREAMING
},

"maxTicketOpened": 0 // The number of tickets the user can open while another one is already open. Set to 0 to unlimited
"maxTicketOpened": 0, // The number of tickets the user can open while another one is already open. Set to 0 to unlimited
/*
Whether or not to minimizing the tracking data that are being sent
Enabling this will cause the telemetry to only send the software version and node version
*/
"minimalTracking": false
}
3 changes: 0 additions & 3 deletions config/token.example.json

This file was deleted.

36 changes: 0 additions & 36 deletions deploy-commands.js

This file was deleted.

30 changes: 21 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
{
"name": "ticket-bot",
"version": "2.4.0",
"version": "3.0.0",
"description": "Bot with a ticket system using Discord.js v14",
"main": "index.js",
"main": "dist/index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"setup": "npm install && prisma db push",
"build": "rimraf dist && tsc",
"start": "node dist/index.js",
"format:fix": "prettier --write .",
"format:check": "prettier --check .",
"lint:fix": "eslint --fix .",
"lint:check": "eslint ."
"lint:fix": "eslint --fix . --ext .ts",
"lint:check": "eslint . --ext .ts"
},
"repository": {
"type": "git",
Expand All @@ -26,25 +28,35 @@
},
"homepage": "https://github.com/Sayrix/ticket-bot#readme",
"dependencies": {
"@prisma/client": "^4.16.1",
"axios": "^1.4.0",
"better-sqlite3": "^8.4.0",
"discord.js": "^14.11.0",
"dotenv": "^16.3.1",
"fs-extra": "^11.1.1",
"jsonc": "^2.0.0",
"mysql2": "^3.3.5",
"pg": "^8.11.0",
"quick.db": "^9.1.6",
"mongoose": "^7.3.0",
"readline": "^1.3.0",
"ticket-bot-transcript-uploader": "^1.3.0",
"websocket": "^1.0.34"
},
"devDependencies": {
"@types/better-sqlite3": "^7.6.4",
"@types/fs-extra": "^11.0.1",
"@types/node": "^20.3.1",
"@types/pg": "^8.10.2",
"@types/websocket": "^1.0.5",
"@typescript-eslint/eslint-plugin": "^5.60.0",
"@typescript-eslint/parser": "^5.60.0",
"eslint": "^8.43.0",
"eslint-config-airbnb-base": "^15.0.0",
"eslint-config-prettier": "^8.8.0",
"eslint-plugin-import": "^2.27.5",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-prettier": "^4.2.1",
"prettier": "^2.8.8"
"prettier": "^2.8.8",
"prisma": "^4.16.1",
"rimraf": "^5.0.1",
"typescript": "^5.1.3"
}
}
43 changes: 43 additions & 0 deletions prisma/compatible.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/*
Copyright © 2023 小兽兽/zhiyan114 (github.com/zhiyan114)
File is licensed respectively under the terms of the Apache License 2.0
or whichever license the project is using at the time https://github.com/Sayrix/Ticket-Bot/blob/main/LICENSE

This file is from postgre.sql but modified for sqlite and mysql compatibility with prisma.
RANT: I LOVE AND HATE SQLITE. Why can't it just support a little more features...

For production use, please use "prisma db push" instead or follow the documentation: https://doc.ticket.pm/docs/intro.
*/


/*
this will be used for
* openTicketMessageId
* ticketCount
*/

CREATE TABLE IF NOT EXISTS config (
key TEXT PRIMARY KEY,
value TEXT
);

/*
this will be used for storing tickets
*/

CREATE TABLE IF NOT EXISTS tickets (
id SERIAL PRIMARY KEY,
channelid TEXT NOT NULL UNIQUE,
messageid TEXT NOT NULL UNIQUE,
category TEXT NOT NULL,
invited TEXT NOT NULL DEFAULT '[]',
reason TEXT NOT NULL,
creator TEXT NOT NULL,
createdat BIGINT NOT NULL,
claimedby TEXT,
claimedat BIGINT,
closedby TEXT,
closedat BIGINT,
closereason TEXT,
transcript TEXT
);
55 changes: 55 additions & 0 deletions prisma/postgre.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/*
Copyright © 2023 小兽兽/zhiyan114 (github.com/zhiyan114)
File is licensed respectively under the terms of the Apache License 2.0
or whichever license the project is using at the time https://github.com/Sayrix/Ticket-Bot/blob/main/LICENSE

For production use, please don't try to use this file, even if you're using postgresql,
Since the code is tailored towards compatibility.sql, it will break.
You have been warned.

I wrote this in-case multi-db support will eventually be dropped, and I'm a big postgresql fan ^w^
*/



/*
this will be used for
* openTicketMessageId
* ticketCount
*/

CREATE TABLE IF NOT EXISTS config (
key VARCHAR(256) PRIMARY KEY,
value TEXT
);

/*
this will be used for storing tickets
*/

CREATE TABLE IF NOT EXISTS tickets (
id SERIAL PRIMARY KEY,
channelid TEXT NOT NULL UNIQUE,
messageid TEXT NOT NULL UNIQUE,
category JSON NOT NULL,
reason TEXT NOT NULL,
creator TEXT NOT NULL,
createdat TIMESTAMP NOT NULL DEFAULT NOW(),
claimedby TEXT,
claimedat TIMESTAMP,
closedby TEXT,
closedat TIMESTAMP,
closereason TEXT,
transcript TEXT
);

/*
this will be used to handle ticket invites
*/

CREATE TABLE IF NOT EXISTS invites (
id SERIAL PRIMARY KEY,
ticketid TEXT NOT NULL,
userid TEXT NOT NULL,
CONSTRAINT FK_ticketID FOREIGN KEY(ticketid) REFERENCES tickets(messageid) ON DELETE CASCADE
);
Loading