try to set up sequelize, change a buncha shit, completely break fucking everything, that's just my life!!!

This commit is contained in:
SadlyNotSappho 2023-02-14 14:49:12 -08:00
parent cfd972557d
commit 644e0462c8
11 changed files with 961 additions and 75 deletions

View File

@ -1,36 +1,9 @@
# Docker Sapphire Bot example # sapling
This is a basic setup of a Discord bot using the [sapphire framework][sapphire] written in TypeScript containerized with Docker it's almost like i've tried making discord bots before and they've all fucking sucked, i wonder what could be different about this one!!!!!!!!
## How to use it? anyways yeah i'm making a discord bot. idrk why. i just want button roles, and AutoModerator's implementation of them isn't great
### Prerequisite ## how to host yourself
1. Copy the `.env.example` and rename it to `.env`, make sure to fill the Token. rename `.env.example` to `.env` and fill it out, i think that's it idk
2. Open the Dockerfile and in the block marked with `Conditional steps for end-users` make sure you enable the lines that apply to your project.
### Development
Run `docker-compose up`. This will start the bot in watch mode and automatically run it after each save.
It will build the `Dockerfile` up until the `development` stage.
### Production
Just like in the development step, you have to fill in the `.env` file and then run the following command to create a production image;
```sh
docker build . -t sapphire-sample-bot
```
To test if your image works, you can run:
```sh
docker run --env-file .env sapphire-sample-bot
```
## License
Dedicated to the public domain via the [Unlicense], courtesy of the Sapphire Community and its contributors.
[sapphire]: https://github.com/sapphiredev/framework
[unlicense]: https://github.com/sapphiredev/examples/blob/main/LICENSE.md

View File

@ -1,10 +1,20 @@
version: '3.9' version: '3.9'
services: services:
sapphire-sample-bot: bot:
build: build:
context: . context: .
target: development target: development
env_file: .env env_file: .env
volumes: volumes:
- ./:/opt/app - ./:/opt/app
postgresql:
image: postgres:14
restart: unless-stopped
container_name: bot-db
volumes:
- bot-db:/var/lib/postgresql/data/
env_file: .env
volumes:
bot-db:

547
package-lock.json generated
View File

@ -1,11 +1,11 @@
{ {
"name": "discord-button-roles", "name": "sapling",
"version": "1.0.0", "version": "1.0.0",
"lockfileVersion": 2, "lockfileVersion": 2,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "discord-button-roles", "name": "sapling",
"version": "1.0.0", "version": "1.0.0",
"license": "LGPL-3.0", "license": "LGPL-3.0",
"dependencies": { "dependencies": {
@ -22,12 +22,16 @@
"@sapphire/type": "^2.3.0", "@sapphire/type": "^2.3.0",
"@sapphire/utilities": "^3.11.0", "@sapphire/utilities": "^3.11.0",
"@skyra/env-utilities": "^1.1.0", "@skyra/env-utilities": "^1.1.0",
"discord.js": "^14.7.1" "discord.js": "^14.7.1",
"pg": "^8.9.0",
"pg-hstore": "^2.3.4",
"sequelize": "^6.28.0"
}, },
"devDependencies": { "devDependencies": {
"@sapphire/prettier-config": "^1.4.5", "@sapphire/prettier-config": "^1.4.5",
"@sapphire/ts-config": "^3.3.4", "@sapphire/ts-config": "^3.3.4",
"@types/node": "^18.11.18", "@types/node": "^18.11.18",
"@types/pg": "^8",
"@types/ws": "^8.5.4", "@types/ws": "^8.5.4",
"npm-run-all": "^4.1.5", "npm-run-all": "^4.1.5",
"prettier": "^2.8.3", "prettier": "^2.8.3",
@ -436,14 +440,43 @@
"version": "0.3.0", "version": "0.3.0",
"license": "MIT" "license": "MIT"
}, },
"node_modules/@types/debug": {
"version": "4.1.7",
"resolved": "https://registry.npmjs.org/@types/debug/-/debug-4.1.7.tgz",
"integrity": "sha512-9AonUzyTjXXhEOa0DnqpzZi6VHlqKMswga9EXjpXnnqxwLtdvPPtlO8evrI5D9S6asFRCQ6v+wpiUKbw+vKqyg==",
"dependencies": {
"@types/ms": "*"
}
},
"node_modules/@types/ms": {
"version": "0.7.31",
"resolved": "https://registry.npmjs.org/@types/ms/-/ms-0.7.31.tgz",
"integrity": "sha512-iiUgKzV9AuaEkZqkOLDIvlQiL6ltuZd9tGcW3gwpnX8JbuiuhFlEGmmFXEXkN50Cvq7Os88IY2v0dkDqXYWVgA=="
},
"node_modules/@types/node": { "node_modules/@types/node": {
"version": "18.13.0", "version": "18.13.0",
"license": "MIT" "license": "MIT"
}, },
"node_modules/@types/pg": {
"version": "8.6.6",
"resolved": "https://registry.npmjs.org/@types/pg/-/pg-8.6.6.tgz",
"integrity": "sha512-O2xNmXebtwVekJDD+02udOncjVcMZQuTEQEMpKJ0ZRf5E7/9JJX3izhKUcUifBkyKpljyUM6BTgy2trmviKlpw==",
"dev": true,
"dependencies": {
"@types/node": "*",
"pg-protocol": "*",
"pg-types": "^2.2.0"
}
},
"node_modules/@types/psl": { "node_modules/@types/psl": {
"version": "1.1.0", "version": "1.1.0",
"license": "MIT" "license": "MIT"
}, },
"node_modules/@types/validator": {
"version": "13.7.12",
"resolved": "https://registry.npmjs.org/@types/validator/-/validator-13.7.12.tgz",
"integrity": "sha512-YVtyAPqpefU+Mm/qqnOANW6IkqKpCSrarcyV269C8MA8Ux0dbkEuQwM/4CjL47kVEM2LgBef/ETfkH+c6+moFA=="
},
"node_modules/@types/ws": { "node_modules/@types/ws": {
"version": "8.5.4", "version": "8.5.4",
"license": "MIT", "license": "MIT",
@ -521,6 +554,14 @@
"concat-map": "0.0.1" "concat-map": "0.0.1"
} }
}, },
"node_modules/buffer-writer": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/buffer-writer/-/buffer-writer-2.0.0.tgz",
"integrity": "sha512-a7ZpuTZU1TRtnwyCNW3I5dc0wWNC3VR9S++Ewyk2HHZdrO3CQJqSpd+95Us590V6AL7JqUAH2IwZ/398PmNFgw==",
"engines": {
"node": ">=4"
}
},
"node_modules/busboy": { "node_modules/busboy": {
"version": "1.6.0", "version": "1.6.0",
"dependencies": { "dependencies": {
@ -723,6 +764,11 @@
"version": "5.1.0", "version": "5.1.0",
"license": "BSD-2-Clause" "license": "BSD-2-Clause"
}, },
"node_modules/dottie": {
"version": "2.0.3",
"resolved": "https://registry.npmjs.org/dottie/-/dottie-2.0.3.tgz",
"integrity": "sha512-4liA0PuRkZWQFQjwBypdxPfZaRWiv5tkhMXY2hzsa2pNf5s7U3m9cwUchfNKe8wZQxdGPQQzO6Rm2uGe0rvohQ=="
},
"node_modules/duplexer": { "node_modules/duplexer": {
"version": "0.1.2", "version": "0.1.2",
"dev": true, "dev": true,
@ -1140,6 +1186,14 @@
], ],
"license": "BSD-3-Clause" "license": "BSD-3-Clause"
}, },
"node_modules/inflection": {
"version": "1.13.4",
"resolved": "https://registry.npmjs.org/inflection/-/inflection-1.13.4.tgz",
"integrity": "sha512-6I/HUDeYFfuNCVS3td055BaXBwKYuzw7K3ExVMStBowKo9oOAMJIXIHvdyR3iboTCp1b+1i5DSkIZTcwIktuDw==",
"engines": [
"node >= 0.4.0"
]
},
"node_modules/inflight": { "node_modules/inflight": {
"version": "1.0.6", "version": "1.0.6",
"license": "ISC", "license": "ISC",
@ -1464,6 +1518,25 @@
"node": ">=10" "node": ">=10"
} }
}, },
"node_modules/moment": {
"version": "2.29.4",
"resolved": "https://registry.npmjs.org/moment/-/moment-2.29.4.tgz",
"integrity": "sha512-5LC9SOxjSc2HF6vO2CyuTDNivEdoz2IvyJJGj6X8DJ0eFyfszE0QiEd+iXmBvUP3WHxSjFH/vIsA0EN00cgr8w==",
"engines": {
"node": "*"
}
},
"node_modules/moment-timezone": {
"version": "0.5.40",
"resolved": "https://registry.npmjs.org/moment-timezone/-/moment-timezone-0.5.40.tgz",
"integrity": "sha512-tWfmNkRYmBkPJz5mr9GVDn9vRlVZOTe6yqY92rFxiOdWXbjaR0+9LwQnZGGuNR63X456NqmEkbskte8tWL5ePg==",
"dependencies": {
"moment": ">= 2.9.0"
},
"engines": {
"node": "*"
}
},
"node_modules/ms": { "node_modules/ms": {
"version": "2.1.2", "version": "2.1.2",
"license": "MIT" "license": "MIT"
@ -1613,6 +1686,11 @@
"wrappy": "1" "wrappy": "1"
} }
}, },
"node_modules/packet-reader": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/packet-reader/-/packet-reader-1.0.0.tgz",
"integrity": "sha512-HAKu/fG3HpHFO0AA8WE8q2g+gBJaZ9MG7fcKk+IJPLTGAD6Psw4443l+9DGRbOIh3/aXr7Phy0TjilYivJo5XQ=="
},
"node_modules/parse-json": { "node_modules/parse-json": {
"version": "4.0.0", "version": "4.0.0",
"dev": true, "dev": true,
@ -1678,6 +1756,91 @@
"url": "https://github.com/sponsors/Borewit" "url": "https://github.com/sponsors/Borewit"
} }
}, },
"node_modules/pg": {
"version": "8.9.0",
"resolved": "https://registry.npmjs.org/pg/-/pg-8.9.0.tgz",
"integrity": "sha512-ZJM+qkEbtOHRuXjmvBtOgNOXOtLSbxiMiUVMgE4rV6Zwocy03RicCVvDXgx8l4Biwo8/qORUnEqn2fdQzV7KCg==",
"dependencies": {
"buffer-writer": "2.0.0",
"packet-reader": "1.0.0",
"pg-connection-string": "^2.5.0",
"pg-pool": "^3.5.2",
"pg-protocol": "^1.6.0",
"pg-types": "^2.1.0",
"pgpass": "1.x"
},
"engines": {
"node": ">= 8.0.0"
},
"peerDependencies": {
"pg-native": ">=3.0.1"
},
"peerDependenciesMeta": {
"pg-native": {
"optional": true
}
}
},
"node_modules/pg-connection-string": {
"version": "2.5.0",
"resolved": "https://registry.npmjs.org/pg-connection-string/-/pg-connection-string-2.5.0.tgz",
"integrity": "sha512-r5o/V/ORTA6TmUnyWZR9nCj1klXCO2CEKNRlVuJptZe85QuhFayC7WeMic7ndayT5IRIR0S0xFxFi2ousartlQ=="
},
"node_modules/pg-hstore": {
"version": "2.3.4",
"resolved": "https://registry.npmjs.org/pg-hstore/-/pg-hstore-2.3.4.tgz",
"integrity": "sha512-N3SGs/Rf+xA1M2/n0JBiXFDVMzdekwLZLAO0g7mpDY9ouX+fDI7jS6kTq3JujmYbtNSJ53TJ0q4G98KVZSM4EA==",
"dependencies": {
"underscore": "^1.13.1"
},
"engines": {
"node": ">= 0.8.x"
}
},
"node_modules/pg-int8": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/pg-int8/-/pg-int8-1.0.1.tgz",
"integrity": "sha512-WCtabS6t3c8SkpDBUlb1kjOs7l66xsGdKpIPZsg4wR+B3+u9UAum2odSsF9tnvxg80h4ZxLWMy4pRjOsFIqQpw==",
"engines": {
"node": ">=4.0.0"
}
},
"node_modules/pg-pool": {
"version": "3.5.2",
"resolved": "https://registry.npmjs.org/pg-pool/-/pg-pool-3.5.2.tgz",
"integrity": "sha512-His3Fh17Z4eg7oANLob6ZvH8xIVen3phEZh2QuyrIl4dQSDVEabNducv6ysROKpDNPSD+12tONZVWfSgMvDD9w==",
"peerDependencies": {
"pg": ">=8.0"
}
},
"node_modules/pg-protocol": {
"version": "1.6.0",
"resolved": "https://registry.npmjs.org/pg-protocol/-/pg-protocol-1.6.0.tgz",
"integrity": "sha512-M+PDm637OY5WM307051+bsDia5Xej6d9IR4GwJse1qA1DIhiKlksvrneZOYQq42OM+spubpcNYEo2FcKQrDk+Q=="
},
"node_modules/pg-types": {
"version": "2.2.0",
"resolved": "https://registry.npmjs.org/pg-types/-/pg-types-2.2.0.tgz",
"integrity": "sha512-qTAAlrEsl8s4OiEQY69wDvcMIdQN6wdz5ojQiOy6YRMuynxenON0O5oCpJI6lshc6scgAY8qvJ2On/p+CXY0GA==",
"dependencies": {
"pg-int8": "1.0.1",
"postgres-array": "~2.0.0",
"postgres-bytea": "~1.0.0",
"postgres-date": "~1.0.4",
"postgres-interval": "^1.1.0"
},
"engines": {
"node": ">=4"
}
},
"node_modules/pgpass": {
"version": "1.0.5",
"resolved": "https://registry.npmjs.org/pgpass/-/pgpass-1.0.5.tgz",
"integrity": "sha512-FdW9r/jQZhSeohs1Z3sI1yxFQNFvMcnmfuj4WBMUTxOrAyLMaTcE1aAMBiTlbMNaXvBCQuVi0R7hd8udDSP7ug==",
"dependencies": {
"split2": "^4.1.0"
}
},
"node_modules/pidtree": { "node_modules/pidtree": {
"version": "0.3.1", "version": "0.3.1",
"dev": true, "dev": true,
@ -1697,6 +1860,41 @@
"node": ">=4" "node": ">=4"
} }
}, },
"node_modules/postgres-array": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/postgres-array/-/postgres-array-2.0.0.tgz",
"integrity": "sha512-VpZrUqU5A69eQyW2c5CA1jtLecCsN2U/bD6VilrFDWq5+5UIEVO7nazS3TEcHf1zuPYO/sqGvUvW62g86RXZuA==",
"engines": {
"node": ">=4"
}
},
"node_modules/postgres-bytea": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/postgres-bytea/-/postgres-bytea-1.0.0.tgz",
"integrity": "sha512-xy3pmLuQqRBZBXDULy7KbaitYqLcmxigw14Q5sj8QBVLqEwXfeybIKVWiqAXTlcvdvb0+xkOtDbfQMOf4lST1w==",
"engines": {
"node": ">=0.10.0"
}
},
"node_modules/postgres-date": {
"version": "1.0.7",
"resolved": "https://registry.npmjs.org/postgres-date/-/postgres-date-1.0.7.tgz",
"integrity": "sha512-suDmjLVQg78nMK2UZ454hAG+OAW+HQPZ6n++TNDUX+L0+uUlLywnoxJKDou51Zm+zTCjrCl0Nq6J9C5hP9vK/Q==",
"engines": {
"node": ">=0.10.0"
}
},
"node_modules/postgres-interval": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/postgres-interval/-/postgres-interval-1.2.0.tgz",
"integrity": "sha512-9ZhXKM/rw350N1ovuWHbGxnGh/SNJ4cnxHiM0rxE4VN41wsg8P8zWn9hv/buK00RP4WvlOyr/RBDiptyxVbkZQ==",
"dependencies": {
"xtend": "^4.0.0"
},
"engines": {
"node": ">=0.10.0"
}
},
"node_modules/prettier": { "node_modules/prettier": {
"version": "2.8.4", "version": "2.8.4",
"dev": true, "dev": true,
@ -1800,6 +1998,11 @@
"url": "https://github.com/sponsors/ljharb" "url": "https://github.com/sponsors/ljharb"
} }
}, },
"node_modules/retry-as-promised": {
"version": "7.0.4",
"resolved": "https://registry.npmjs.org/retry-as-promised/-/retry-as-promised-7.0.4.tgz",
"integrity": "sha512-XgmCoxKWkDofwH8WddD0w85ZfqYz+ZHlr5yo+3YUCfycWawU56T5ckWXsScsj5B8tqUcIG67DxXByo3VUgiAdA=="
},
"node_modules/rimraf": { "node_modules/rimraf": {
"version": "3.0.2", "version": "3.0.2",
"license": "ISC", "license": "ISC",
@ -1873,6 +2076,75 @@
"node": ">=10" "node": ">=10"
} }
}, },
"node_modules/sequelize": {
"version": "6.28.0",
"resolved": "https://registry.npmjs.org/sequelize/-/sequelize-6.28.0.tgz",
"integrity": "sha512-+WHqvUQgTp19GLkt+gyQ+F6qg+FIEO2O5F9C0TOYV/PjZ2a/XwWvVkL1NCkS4VSIjVVvAUutiW6Wv9ofveGaVw==",
"funding": [
{
"type": "opencollective",
"url": "https://opencollective.com/sequelize"
}
],
"dependencies": {
"@types/debug": "^4.1.7",
"@types/validator": "^13.7.1",
"debug": "^4.3.3",
"dottie": "^2.0.2",
"inflection": "^1.13.2",
"lodash": "^4.17.21",
"moment": "^2.29.1",
"moment-timezone": "^0.5.34",
"pg-connection-string": "^2.5.0",
"retry-as-promised": "^7.0.3",
"semver": "^7.3.5",
"sequelize-pool": "^7.1.0",
"toposort-class": "^1.0.1",
"uuid": "^8.3.2",
"validator": "^13.7.0",
"wkx": "^0.5.0"
},
"engines": {
"node": ">=10.0.0"
},
"peerDependenciesMeta": {
"ibm_db": {
"optional": true
},
"mariadb": {
"optional": true
},
"mysql2": {
"optional": true
},
"oracledb": {
"optional": true
},
"pg": {
"optional": true
},
"pg-hstore": {
"optional": true
},
"snowflake-sdk": {
"optional": true
},
"sqlite3": {
"optional": true
},
"tedious": {
"optional": true
}
}
},
"node_modules/sequelize-pool": {
"version": "7.1.0",
"resolved": "https://registry.npmjs.org/sequelize-pool/-/sequelize-pool-7.1.0.tgz",
"integrity": "sha512-G9c0qlIWQSK29pR/5U2JF5dDQeqqHRragoyahj/Nx4KOOQ3CPPfzxnfqFPCSB7x5UgjOgnZ61nSxz+fjDpRlJg==",
"engines": {
"node": ">= 10.0.0"
}
},
"node_modules/set-blocking": { "node_modules/set-blocking": {
"version": "2.0.0", "version": "2.0.0",
"license": "ISC" "license": "ISC"
@ -1960,6 +2232,14 @@
"node": "*" "node": "*"
} }
}, },
"node_modules/split2": {
"version": "4.1.0",
"resolved": "https://registry.npmjs.org/split2/-/split2-4.1.0.tgz",
"integrity": "sha512-VBiJxFkxiXRlUIeyMQi8s4hgvKCSjtknJv/LVYbrgALPwf5zSKmEwV9Lst25AkvMDnvxODugjdl6KZgwKM1WYQ==",
"engines": {
"node": ">= 10.x"
}
},
"node_modules/stream-combiner": { "node_modules/stream-combiner": {
"version": "0.0.4", "version": "0.0.4",
"dev": true, "dev": true,
@ -2140,6 +2420,11 @@
"url": "https://github.com/sponsors/Borewit" "url": "https://github.com/sponsors/Borewit"
} }
}, },
"node_modules/toposort-class": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/toposort-class/-/toposort-class-1.0.1.tgz",
"integrity": "sha512-OsLcGGbYF3rMjPUf8oKktyvCiUxSbqMMS39m33MAjLTC1DVIH6x3WSt63/M77ihI09+Sdfk1AXvfhCEeUmC7mg=="
},
"node_modules/tr46": { "node_modules/tr46": {
"version": "0.0.3", "version": "0.0.3",
"license": "MIT" "license": "MIT"
@ -2251,6 +2536,11 @@
"url": "https://github.com/sponsors/ljharb" "url": "https://github.com/sponsors/ljharb"
} }
}, },
"node_modules/underscore": {
"version": "1.13.6",
"resolved": "https://registry.npmjs.org/underscore/-/underscore-1.13.6.tgz",
"integrity": "sha512-+A5Sja4HP1M08MaXya7p5LvjuM7K6q/2EaC0+iovj/wOcMsTzMvDFbasi/oSapiwOlt252IqsKqPjCl7huKS0A=="
},
"node_modules/undici": { "node_modules/undici": {
"version": "5.18.0", "version": "5.18.0",
"license": "MIT", "license": "MIT",
@ -2265,6 +2555,14 @@
"version": "1.0.2", "version": "1.0.2",
"license": "MIT" "license": "MIT"
}, },
"node_modules/uuid": {
"version": "8.3.2",
"resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz",
"integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==",
"bin": {
"uuid": "dist/bin/uuid"
}
},
"node_modules/validate-npm-package-license": { "node_modules/validate-npm-package-license": {
"version": "3.0.4", "version": "3.0.4",
"dev": true, "dev": true,
@ -2274,6 +2572,14 @@
"spdx-expression-parse": "^3.0.0" "spdx-expression-parse": "^3.0.0"
} }
}, },
"node_modules/validator": {
"version": "13.9.0",
"resolved": "https://registry.npmjs.org/validator/-/validator-13.9.0.tgz",
"integrity": "sha512-B+dGG8U3fdtM0/aNK4/X8CXq/EcxU2WPrPEkJGslb47qyHsxmbggTWK0yEA4qnYVNF+nxNlN88o14hIcPmSIEA==",
"engines": {
"node": ">= 0.10"
}
},
"node_modules/webidl-conversions": { "node_modules/webidl-conversions": {
"version": "3.0.1", "version": "3.0.1",
"license": "BSD-2-Clause" "license": "BSD-2-Clause"
@ -2341,6 +2647,14 @@
"string-width": "^1.0.2 || 2 || 3 || 4" "string-width": "^1.0.2 || 2 || 3 || 4"
} }
}, },
"node_modules/wkx": {
"version": "0.5.0",
"resolved": "https://registry.npmjs.org/wkx/-/wkx-0.5.0.tgz",
"integrity": "sha512-Xng/d4Ichh8uN4l0FToV/258EjMGU9MGcA0HV2d9B/ZpZB3lqQm7nkOdZdm5GhKtLLhAE7PiVQwN4eN+2YJJUg==",
"dependencies": {
"@types/node": "*"
}
},
"node_modules/wrappy": { "node_modules/wrappy": {
"version": "1.0.2", "version": "1.0.2",
"license": "ISC" "license": "ISC"
@ -2364,6 +2678,14 @@
} }
} }
}, },
"node_modules/xtend": {
"version": "4.0.2",
"resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.2.tgz",
"integrity": "sha512-LKYU1iAXJXUgAXn9URjiu+MWhyUXHsvfp7mcuYm9dSUKK0/CjtrUwFAxD82/mCWbtLsGjFIad0wIsod4zrTAEQ==",
"engines": {
"node": ">=0.4"
}
},
"node_modules/yallist": { "node_modules/yallist": {
"version": "4.0.0", "version": "4.0.0",
"license": "ISC" "license": "ISC"
@ -2599,12 +2921,41 @@
"@tokenizer/token": { "@tokenizer/token": {
"version": "0.3.0" "version": "0.3.0"
}, },
"@types/debug": {
"version": "4.1.7",
"resolved": "https://registry.npmjs.org/@types/debug/-/debug-4.1.7.tgz",
"integrity": "sha512-9AonUzyTjXXhEOa0DnqpzZi6VHlqKMswga9EXjpXnnqxwLtdvPPtlO8evrI5D9S6asFRCQ6v+wpiUKbw+vKqyg==",
"requires": {
"@types/ms": "*"
}
},
"@types/ms": {
"version": "0.7.31",
"resolved": "https://registry.npmjs.org/@types/ms/-/ms-0.7.31.tgz",
"integrity": "sha512-iiUgKzV9AuaEkZqkOLDIvlQiL6ltuZd9tGcW3gwpnX8JbuiuhFlEGmmFXEXkN50Cvq7Os88IY2v0dkDqXYWVgA=="
},
"@types/node": { "@types/node": {
"version": "18.13.0" "version": "18.13.0"
}, },
"@types/pg": {
"version": "8.6.6",
"resolved": "https://registry.npmjs.org/@types/pg/-/pg-8.6.6.tgz",
"integrity": "sha512-O2xNmXebtwVekJDD+02udOncjVcMZQuTEQEMpKJ0ZRf5E7/9JJX3izhKUcUifBkyKpljyUM6BTgy2trmviKlpw==",
"dev": true,
"requires": {
"@types/node": "*",
"pg-protocol": "*",
"pg-types": "^2.2.0"
}
},
"@types/psl": { "@types/psl": {
"version": "1.1.0" "version": "1.1.0"
}, },
"@types/validator": {
"version": "13.7.12",
"resolved": "https://registry.npmjs.org/@types/validator/-/validator-13.7.12.tgz",
"integrity": "sha512-YVtyAPqpefU+Mm/qqnOANW6IkqKpCSrarcyV269C8MA8Ux0dbkEuQwM/4CjL47kVEM2LgBef/ETfkH+c6+moFA=="
},
"@types/ws": { "@types/ws": {
"version": "8.5.4", "version": "8.5.4",
"requires": { "requires": {
@ -2654,6 +3005,11 @@
"concat-map": "0.0.1" "concat-map": "0.0.1"
} }
}, },
"buffer-writer": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/buffer-writer/-/buffer-writer-2.0.0.tgz",
"integrity": "sha512-a7ZpuTZU1TRtnwyCNW3I5dc0wWNC3VR9S++Ewyk2HHZdrO3CQJqSpd+95Us590V6AL7JqUAH2IwZ/398PmNFgw=="
},
"busboy": { "busboy": {
"version": "1.6.0", "version": "1.6.0",
"requires": { "requires": {
@ -2786,6 +3142,11 @@
"dotenv-expand": { "dotenv-expand": {
"version": "5.1.0" "version": "5.1.0"
}, },
"dottie": {
"version": "2.0.3",
"resolved": "https://registry.npmjs.org/dottie/-/dottie-2.0.3.tgz",
"integrity": "sha512-4liA0PuRkZWQFQjwBypdxPfZaRWiv5tkhMXY2hzsa2pNf5s7U3m9cwUchfNKe8wZQxdGPQQzO6Rm2uGe0rvohQ=="
},
"duplexer": { "duplexer": {
"version": "0.1.2", "version": "0.1.2",
"dev": true "dev": true
@ -3053,6 +3414,11 @@
"ieee754": { "ieee754": {
"version": "1.2.1" "version": "1.2.1"
}, },
"inflection": {
"version": "1.13.4",
"resolved": "https://registry.npmjs.org/inflection/-/inflection-1.13.4.tgz",
"integrity": "sha512-6I/HUDeYFfuNCVS3td055BaXBwKYuzw7K3ExVMStBowKo9oOAMJIXIHvdyR3iboTCp1b+1i5DSkIZTcwIktuDw=="
},
"inflight": { "inflight": {
"version": "1.0.6", "version": "1.0.6",
"requires": { "requires": {
@ -3244,6 +3610,19 @@
"mkdirp": { "mkdirp": {
"version": "1.0.4" "version": "1.0.4"
}, },
"moment": {
"version": "2.29.4",
"resolved": "https://registry.npmjs.org/moment/-/moment-2.29.4.tgz",
"integrity": "sha512-5LC9SOxjSc2HF6vO2CyuTDNivEdoz2IvyJJGj6X8DJ0eFyfszE0QiEd+iXmBvUP3WHxSjFH/vIsA0EN00cgr8w=="
},
"moment-timezone": {
"version": "0.5.40",
"resolved": "https://registry.npmjs.org/moment-timezone/-/moment-timezone-0.5.40.tgz",
"integrity": "sha512-tWfmNkRYmBkPJz5mr9GVDn9vRlVZOTe6yqY92rFxiOdWXbjaR0+9LwQnZGGuNR63X456NqmEkbskte8tWL5ePg==",
"requires": {
"moment": ">= 2.9.0"
}
},
"ms": { "ms": {
"version": "2.1.2" "version": "2.1.2"
}, },
@ -3337,6 +3716,11 @@
"wrappy": "1" "wrappy": "1"
} }
}, },
"packet-reader": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/packet-reader/-/packet-reader-1.0.0.tgz",
"integrity": "sha512-HAKu/fG3HpHFO0AA8WE8q2g+gBJaZ9MG7fcKk+IJPLTGAD6Psw4443l+9DGRbOIh3/aXr7Phy0TjilYivJo5XQ=="
},
"parse-json": { "parse-json": {
"version": "4.0.0", "version": "4.0.0",
"dev": true, "dev": true,
@ -3373,6 +3757,69 @@
"peek-readable": { "peek-readable": {
"version": "5.0.0" "version": "5.0.0"
}, },
"pg": {
"version": "8.9.0",
"resolved": "https://registry.npmjs.org/pg/-/pg-8.9.0.tgz",
"integrity": "sha512-ZJM+qkEbtOHRuXjmvBtOgNOXOtLSbxiMiUVMgE4rV6Zwocy03RicCVvDXgx8l4Biwo8/qORUnEqn2fdQzV7KCg==",
"requires": {
"buffer-writer": "2.0.0",
"packet-reader": "1.0.0",
"pg-connection-string": "^2.5.0",
"pg-pool": "^3.5.2",
"pg-protocol": "^1.6.0",
"pg-types": "^2.1.0",
"pgpass": "1.x"
}
},
"pg-connection-string": {
"version": "2.5.0",
"resolved": "https://registry.npmjs.org/pg-connection-string/-/pg-connection-string-2.5.0.tgz",
"integrity": "sha512-r5o/V/ORTA6TmUnyWZR9nCj1klXCO2CEKNRlVuJptZe85QuhFayC7WeMic7ndayT5IRIR0S0xFxFi2ousartlQ=="
},
"pg-hstore": {
"version": "2.3.4",
"resolved": "https://registry.npmjs.org/pg-hstore/-/pg-hstore-2.3.4.tgz",
"integrity": "sha512-N3SGs/Rf+xA1M2/n0JBiXFDVMzdekwLZLAO0g7mpDY9ouX+fDI7jS6kTq3JujmYbtNSJ53TJ0q4G98KVZSM4EA==",
"requires": {
"underscore": "^1.13.1"
}
},
"pg-int8": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/pg-int8/-/pg-int8-1.0.1.tgz",
"integrity": "sha512-WCtabS6t3c8SkpDBUlb1kjOs7l66xsGdKpIPZsg4wR+B3+u9UAum2odSsF9tnvxg80h4ZxLWMy4pRjOsFIqQpw=="
},
"pg-pool": {
"version": "3.5.2",
"resolved": "https://registry.npmjs.org/pg-pool/-/pg-pool-3.5.2.tgz",
"integrity": "sha512-His3Fh17Z4eg7oANLob6ZvH8xIVen3phEZh2QuyrIl4dQSDVEabNducv6ysROKpDNPSD+12tONZVWfSgMvDD9w==",
"requires": {}
},
"pg-protocol": {
"version": "1.6.0",
"resolved": "https://registry.npmjs.org/pg-protocol/-/pg-protocol-1.6.0.tgz",
"integrity": "sha512-M+PDm637OY5WM307051+bsDia5Xej6d9IR4GwJse1qA1DIhiKlksvrneZOYQq42OM+spubpcNYEo2FcKQrDk+Q=="
},
"pg-types": {
"version": "2.2.0",
"resolved": "https://registry.npmjs.org/pg-types/-/pg-types-2.2.0.tgz",
"integrity": "sha512-qTAAlrEsl8s4OiEQY69wDvcMIdQN6wdz5ojQiOy6YRMuynxenON0O5oCpJI6lshc6scgAY8qvJ2On/p+CXY0GA==",
"requires": {
"pg-int8": "1.0.1",
"postgres-array": "~2.0.0",
"postgres-bytea": "~1.0.0",
"postgres-date": "~1.0.4",
"postgres-interval": "^1.1.0"
}
},
"pgpass": {
"version": "1.0.5",
"resolved": "https://registry.npmjs.org/pgpass/-/pgpass-1.0.5.tgz",
"integrity": "sha512-FdW9r/jQZhSeohs1Z3sI1yxFQNFvMcnmfuj4WBMUTxOrAyLMaTcE1aAMBiTlbMNaXvBCQuVi0R7hd8udDSP7ug==",
"requires": {
"split2": "^4.1.0"
}
},
"pidtree": { "pidtree": {
"version": "0.3.1", "version": "0.3.1",
"dev": true "dev": true
@ -3381,6 +3828,29 @@
"version": "3.0.0", "version": "3.0.0",
"dev": true "dev": true
}, },
"postgres-array": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/postgres-array/-/postgres-array-2.0.0.tgz",
"integrity": "sha512-VpZrUqU5A69eQyW2c5CA1jtLecCsN2U/bD6VilrFDWq5+5UIEVO7nazS3TEcHf1zuPYO/sqGvUvW62g86RXZuA=="
},
"postgres-bytea": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/postgres-bytea/-/postgres-bytea-1.0.0.tgz",
"integrity": "sha512-xy3pmLuQqRBZBXDULy7KbaitYqLcmxigw14Q5sj8QBVLqEwXfeybIKVWiqAXTlcvdvb0+xkOtDbfQMOf4lST1w=="
},
"postgres-date": {
"version": "1.0.7",
"resolved": "https://registry.npmjs.org/postgres-date/-/postgres-date-1.0.7.tgz",
"integrity": "sha512-suDmjLVQg78nMK2UZ454hAG+OAW+HQPZ6n++TNDUX+L0+uUlLywnoxJKDou51Zm+zTCjrCl0Nq6J9C5hP9vK/Q=="
},
"postgres-interval": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/postgres-interval/-/postgres-interval-1.2.0.tgz",
"integrity": "sha512-9ZhXKM/rw350N1ovuWHbGxnGh/SNJ4cnxHiM0rxE4VN41wsg8P8zWn9hv/buK00RP4WvlOyr/RBDiptyxVbkZQ==",
"requires": {
"xtend": "^4.0.0"
}
},
"prettier": { "prettier": {
"version": "2.8.4", "version": "2.8.4",
"dev": true "dev": true
@ -3436,6 +3906,11 @@
"supports-preserve-symlinks-flag": "^1.0.0" "supports-preserve-symlinks-flag": "^1.0.0"
} }
}, },
"retry-as-promised": {
"version": "7.0.4",
"resolved": "https://registry.npmjs.org/retry-as-promised/-/retry-as-promised-7.0.4.tgz",
"integrity": "sha512-XgmCoxKWkDofwH8WddD0w85ZfqYz+ZHlr5yo+3YUCfycWawU56T5ckWXsScsj5B8tqUcIG67DxXByo3VUgiAdA=="
},
"rimraf": { "rimraf": {
"version": "3.0.2", "version": "3.0.2",
"requires": { "requires": {
@ -3473,6 +3948,34 @@
} }
} }
}, },
"sequelize": {
"version": "6.28.0",
"resolved": "https://registry.npmjs.org/sequelize/-/sequelize-6.28.0.tgz",
"integrity": "sha512-+WHqvUQgTp19GLkt+gyQ+F6qg+FIEO2O5F9C0TOYV/PjZ2a/XwWvVkL1NCkS4VSIjVVvAUutiW6Wv9ofveGaVw==",
"requires": {
"@types/debug": "^4.1.7",
"@types/validator": "^13.7.1",
"debug": "^4.3.3",
"dottie": "^2.0.2",
"inflection": "^1.13.2",
"lodash": "^4.17.21",
"moment": "^2.29.1",
"moment-timezone": "^0.5.34",
"pg-connection-string": "^2.5.0",
"retry-as-promised": "^7.0.3",
"semver": "^7.3.5",
"sequelize-pool": "^7.1.0",
"toposort-class": "^1.0.1",
"uuid": "^8.3.2",
"validator": "^13.7.0",
"wkx": "^0.5.0"
}
},
"sequelize-pool": {
"version": "7.1.0",
"resolved": "https://registry.npmjs.org/sequelize-pool/-/sequelize-pool-7.1.0.tgz",
"integrity": "sha512-G9c0qlIWQSK29pR/5U2JF5dDQeqqHRragoyahj/Nx4KOOQ3CPPfzxnfqFPCSB7x5UgjOgnZ61nSxz+fjDpRlJg=="
},
"set-blocking": { "set-blocking": {
"version": "2.0.0" "version": "2.0.0"
}, },
@ -3534,6 +4037,11 @@
"through": "2" "through": "2"
} }
}, },
"split2": {
"version": "4.1.0",
"resolved": "https://registry.npmjs.org/split2/-/split2-4.1.0.tgz",
"integrity": "sha512-VBiJxFkxiXRlUIeyMQi8s4hgvKCSjtknJv/LVYbrgALPwf5zSKmEwV9Lst25AkvMDnvxODugjdl6KZgwKM1WYQ=="
},
"stream-combiner": { "stream-combiner": {
"version": "0.0.4", "version": "0.0.4",
"dev": true, "dev": true,
@ -3644,6 +4152,11 @@
"ieee754": "^1.2.1" "ieee754": "^1.2.1"
} }
}, },
"toposort-class": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/toposort-class/-/toposort-class-1.0.1.tgz",
"integrity": "sha512-OsLcGGbYF3rMjPUf8oKktyvCiUxSbqMMS39m33MAjLTC1DVIH6x3WSt63/M77ihI09+Sdfk1AXvfhCEeUmC7mg=="
},
"tr46": { "tr46": {
"version": "0.0.3" "version": "0.0.3"
}, },
@ -3712,6 +4225,11 @@
"which-boxed-primitive": "^1.0.2" "which-boxed-primitive": "^1.0.2"
} }
}, },
"underscore": {
"version": "1.13.6",
"resolved": "https://registry.npmjs.org/underscore/-/underscore-1.13.6.tgz",
"integrity": "sha512-+A5Sja4HP1M08MaXya7p5LvjuM7K6q/2EaC0+iovj/wOcMsTzMvDFbasi/oSapiwOlt252IqsKqPjCl7huKS0A=="
},
"undici": { "undici": {
"version": "5.18.0", "version": "5.18.0",
"requires": { "requires": {
@ -3721,6 +4239,11 @@
"util-deprecate": { "util-deprecate": {
"version": "1.0.2" "version": "1.0.2"
}, },
"uuid": {
"version": "8.3.2",
"resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz",
"integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg=="
},
"validate-npm-package-license": { "validate-npm-package-license": {
"version": "3.0.4", "version": "3.0.4",
"dev": true, "dev": true,
@ -3729,6 +4252,11 @@
"spdx-expression-parse": "^3.0.0" "spdx-expression-parse": "^3.0.0"
} }
}, },
"validator": {
"version": "13.9.0",
"resolved": "https://registry.npmjs.org/validator/-/validator-13.9.0.tgz",
"integrity": "sha512-B+dGG8U3fdtM0/aNK4/X8CXq/EcxU2WPrPEkJGslb47qyHsxmbggTWK0yEA4qnYVNF+nxNlN88o14hIcPmSIEA=="
},
"webidl-conversions": { "webidl-conversions": {
"version": "3.0.1" "version": "3.0.1"
}, },
@ -3775,6 +4303,14 @@
"string-width": "^1.0.2 || 2 || 3 || 4" "string-width": "^1.0.2 || 2 || 3 || 4"
} }
}, },
"wkx": {
"version": "0.5.0",
"resolved": "https://registry.npmjs.org/wkx/-/wkx-0.5.0.tgz",
"integrity": "sha512-Xng/d4Ichh8uN4l0FToV/258EjMGU9MGcA0HV2d9B/ZpZB3lqQm7nkOdZdm5GhKtLLhAE7PiVQwN4eN+2YJJUg==",
"requires": {
"@types/node": "*"
}
},
"wrappy": { "wrappy": {
"version": "1.0.2" "version": "1.0.2"
}, },
@ -3782,6 +4318,11 @@
"version": "8.12.0", "version": "8.12.0",
"requires": {} "requires": {}
}, },
"xtend": {
"version": "4.0.2",
"resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.2.tgz",
"integrity": "sha512-LKYU1iAXJXUgAXn9URjiu+MWhyUXHsvfp7mcuYm9dSUKK0/CjtrUwFAxD82/mCWbtLsGjFIad0wIsod4zrTAEQ=="
},
"yallist": { "yallist": {
"version": "4.0.0" "version": "4.0.0"
} }

View File

@ -1,5 +1,5 @@
{ {
"name": "discord-button-roles", "name": "sapling",
"version": "1.0.0", "version": "1.0.0",
"main": "dist/index.js", "main": "dist/index.js",
"author": "SadlyNotSappho", "author": "SadlyNotSappho",
@ -27,12 +27,16 @@
"@sapphire/type": "^2.3.0", "@sapphire/type": "^2.3.0",
"@sapphire/utilities": "^3.11.0", "@sapphire/utilities": "^3.11.0",
"@skyra/env-utilities": "^1.1.0", "@skyra/env-utilities": "^1.1.0",
"discord.js": "^14.7.1" "discord.js": "^14.7.1",
"pg": "^8.9.0",
"pg-hstore": "^2.3.4",
"sequelize": "^6.28.0"
}, },
"devDependencies": { "devDependencies": {
"@sapphire/prettier-config": "^1.4.5", "@sapphire/prettier-config": "^1.4.5",
"@sapphire/ts-config": "^3.3.4", "@sapphire/ts-config": "^3.3.4",
"@types/node": "^18.11.18", "@types/node": "^18.11.18",
"@types/pg": "^8",
"@types/ws": "^8.5.4", "@types/ws": "^8.5.4",
"npm-run-all": "^4.1.5", "npm-run-all": "^4.1.5",
"prettier": "^2.8.3", "prettier": "^2.8.3",

View File

@ -15,7 +15,7 @@ export class UserCommand extends Command {
}, },
{ {
// guildIds: [] // guildIds: []
// idHints: [] idHints: ['1073817778257149972']
} }
); );
} }

62
src/commands/roles.ts Normal file
View File

@ -0,0 +1,62 @@
import { ModalActionRowComponentBuilder, ModalBuilder } from '@discordjs/builders';
import { ApplyOptions } from '@sapphire/decorators';
import { Command } from '@sapphire/framework';
import { ActionRowBuilder, TextInputBuilder, TextInputStyle } from 'discord.js';
@ApplyOptions<Command.Options>({
description: 'Lets you configure a role message'
})
export class UserCommand extends Command {
public override registerApplicationCommands(registry: Command.Registry) {
registry.registerChatInputCommand((builder) =>
builder //
.setName(this.name)
.setDescription(this.description)
.addSubcommand(builder => builder.setName('new').setDescription('Creates a new role message'))
.addSubcommand(builder => builder.setName('edit').setDescription('Edit an existing role message'))
.addSubcommand(builder => builder.setName('show').setDescription('Re-send an existing role message'))
,
{
guildIds: ['1030563119132594187'],
idHints: ['1074474624672350279']
}
);
}
public override async chatInputRun(interaction: Command.ChatInputCommandInteraction) {
let subcommand = interaction.options.getSubcommand(true);
switch (subcommand) {
case 'new': await this.new(interaction); break;
case 'edit': await this.edit(interaction); break;
}
}
private async new(interaction: Command.ChatInputCommandInteraction) {
const modal = new ModalBuilder()
.setCustomId('embedEditorModal')
.setTitle('Embed Editor');
const embedTitle = new TextInputBuilder()
.setCustomId('embedTitle')
.setLabel('Title')
.setStyle(TextInputStyle.Short);
const embedDescription = new TextInputBuilder()
.setCustomId('embedDescription')
.setLabel('Description')
.setStyle(TextInputStyle.Paragraph)
let firstRow = new ActionRowBuilder<ModalActionRowComponentBuilder>().addComponents(embedTitle);
let secondRow = new ActionRowBuilder<ModalActionRowComponentBuilder>().addComponents(embedDescription)
modal.addComponents(firstRow, secondRow)
await interaction.showModal(modal)
}
private async edit(interaction: Command.ChatInputCommandInteraction) {
await interaction.reply({content: 'edit', ephemeral: true})
}
}
// new TextInputBuilder().setCustomId('embedName').setLabel("The embed's name").setRequired(false).setStyle(TextInputStyle.Short)

View File

@ -0,0 +1,38 @@
import { ApplyOptions } from '@sapphire/decorators';
import { Command } from '@sapphire/framework';
import { ComponentType } from 'discord.js';
@ApplyOptions<Command.Options>({
description: 'A basic slash command'
})
export class UserCommand extends Command {
public override registerApplicationCommands(registry: Command.Registry) {
registry.registerChatInputCommand((builder) =>
builder //
.setName(this.name)
.setDescription(this.description)
.addRoleOption((builder) => {
return builder.setName('role').setDescription('pick a role! any role!').setRequired(true);
}),
{
guildIds: ['1030563119132594187'],
idHints: ['1073818897737855036']
}
);
}
public override async chatInputRun(interaction: Command.ChatInputCommandInteraction) {
await interaction.reply({
content: undefined,
allowedMentions: {parse: []},
components: [{type: ComponentType.ActionRow, components: [
{
type: ComponentType.RoleSelect,
minValues: 1,
maxValues: 1,
customId: 'roleSelectMenu'
}
]}]
});
}
}

View File

@ -8,20 +8,32 @@ import { ButtonStyle, ComponentType, Message } from 'discord.js';
export class UserCommand extends Command { export class UserCommand extends Command {
public async messageRun(message: Message) { public async messageRun(message: Message) {
await message.channel.send({ await message.channel.send({
content: "This button lets you select pronoun roles. You can select multiple.", content: 'This button lets you select pronoun roles. You can select multiple.',
allowedMentions: { parse: [] }, allowedMentions: { parse: [] },
components: [{type: ComponentType.ActionRow, components: [ components: [
{
type: ComponentType.ActionRow,
components: [
{ {
type: ComponentType.Button, type: ComponentType.Button,
style: ButtonStyle.Primary, style: ButtonStyle.Primary,
label: 'Click me!', label: 'Click me!',
customId: 'showRolesButton' customId: 'showRolesButton'
} }
]}] ]
}
]
}); });
await message.guild?.commands.fetch() // await message.guild?.commands.fetch()
console.log('message.guild.commands.cache, after fetching:', message.guild?.commands.cache) // console.log('message.guild.commands.cache, after fetching:', message.guild?.commands.cache)
// await this.container.client.application?.commands.fetch()
// console.log('global commands:', this.container.client.application?.commands.cache)
// await this.container.client.application?.commands.delete('1073818778254717019').then(console.log).catch(console.error)
console.log(this.container.db)
} }
} }

View File

@ -1,30 +1,7 @@
import './lib/setup'; import './lib/setup';
import { LogLevel, SapphireClient } from '@sapphire/framework'; import { SaplingClient } from './lib/types';
import { GatewayIntentBits, Partials } from 'discord.js';
const client = new SapphireClient({ const client = new SaplingClient();
defaultPrefix: process.env.DEFAULT_PREFIX,
regexPrefix: /^(hey +)?bot[,! ]/i,
caseInsensitiveCommands: true,
logger: {
level: LogLevel.Info
},
shards: 'auto',
intents: [
GatewayIntentBits.DirectMessageReactions,
GatewayIntentBits.DirectMessages,
GatewayIntentBits.GuildModeration,
GatewayIntentBits.GuildEmojisAndStickers,
GatewayIntentBits.GuildMessageReactions,
GatewayIntentBits.GuildMessages,
GatewayIntentBits.Guilds,
GatewayIntentBits.GuildVoiceStates,
GatewayIntentBits.MessageContent
],
partials: [Partials.Channel],
loadMessageCommandListeners: true
});
const main = async () => { const main = async () => {
try { try {
@ -39,3 +16,4 @@ const main = async () => {
}; };
main(); main();

61
src/lib/types.ts Normal file
View File

@ -0,0 +1,61 @@
import { container, LogLevel, SapphireClient } from "@sapphire/framework";
import { GatewayIntentBits, Partials } from "discord.js";
import { Sequelize } from "sequelize";
export class SaplingClient extends SapphireClient {
public constructor() {
super({
defaultPrefix: process.env.DEFAULT_PREFIX,
regexPrefix: /^(hey +)?bot[,! ]/i,
caseInsensitiveCommands: true,
logger: {
level: LogLevel.Info
},
shards: 'auto',
intents: [
GatewayIntentBits.DirectMessageReactions,
GatewayIntentBits.DirectMessages,
GatewayIntentBits.GuildModeration,
GatewayIntentBits.GuildEmojisAndStickers,
GatewayIntentBits.GuildMessageReactions,
GatewayIntentBits.GuildMessages,
GatewayIntentBits.Guilds,
GatewayIntentBits.GuildVoiceStates,
GatewayIntentBits.MessageContent
],
partials: [Partials.Channel],
loadMessageCommandListeners: true
})
}
public override async login(token?: string) {
const sequelize = new Sequelize(process.env.POSTGRES_DB as string, process.env.POSTGRES_USER as string, process.env.POSTGRES_PASSWORD, {
host: 'bot-db',
dialect: 'postgres',
logging: container.logger.debug
});
try {
await sequelize.authenticate();
container.logger.info('Connected to database');
} catch (error) {
container.logger.fatal('Unable to connect to the database:', error);
}
container.db = sequelize;
return super.login(token)
}
public override async destroy() {
await container.db.close();
return super.destroy();
}
}
declare module '@sapphire/pieces' {
interface Container {
db: Sequelize;
}
}

209
yarn.lock
View File

@ -198,12 +198,38 @@
"@tokenizer/token@^0.3.0": "@tokenizer/token@^0.3.0":
"version" "0.3.0" "version" "0.3.0"
"@types/debug@^4.1.7":
"integrity" "sha512-9AonUzyTjXXhEOa0DnqpzZi6VHlqKMswga9EXjpXnnqxwLtdvPPtlO8evrI5D9S6asFRCQ6v+wpiUKbw+vKqyg=="
"resolved" "https://registry.npmjs.org/@types/debug/-/debug-4.1.7.tgz"
"version" "4.1.7"
dependencies:
"@types/ms" "*"
"@types/ms@*":
"integrity" "sha512-iiUgKzV9AuaEkZqkOLDIvlQiL6ltuZd9tGcW3gwpnX8JbuiuhFlEGmmFXEXkN50Cvq7Os88IY2v0dkDqXYWVgA=="
"resolved" "https://registry.npmjs.org/@types/ms/-/ms-0.7.31.tgz"
"version" "0.7.31"
"@types/node@*", "@types/node@^18.11.18": "@types/node@*", "@types/node@^18.11.18":
"version" "18.13.0" "version" "18.13.0"
"@types/pg@^8":
"integrity" "sha512-O2xNmXebtwVekJDD+02udOncjVcMZQuTEQEMpKJ0ZRf5E7/9JJX3izhKUcUifBkyKpljyUM6BTgy2trmviKlpw=="
"resolved" "https://registry.npmjs.org/@types/pg/-/pg-8.6.6.tgz"
"version" "8.6.6"
dependencies:
"@types/node" "*"
"pg-protocol" "*"
"pg-types" "^2.2.0"
"@types/psl@^1.1.0": "@types/psl@^1.1.0":
"version" "1.1.0" "version" "1.1.0"
"@types/validator@^13.7.1":
"integrity" "sha512-YVtyAPqpefU+Mm/qqnOANW6IkqKpCSrarcyV269C8MA8Ux0dbkEuQwM/4CjL47kVEM2LgBef/ETfkH+c6+moFA=="
"resolved" "https://registry.npmjs.org/@types/validator/-/validator-13.7.12.tgz"
"version" "13.7.12"
"@types/ws@^8.5.3", "@types/ws@^8.5.4": "@types/ws@^8.5.3", "@types/ws@^8.5.4":
"version" "8.5.4" "version" "8.5.4"
dependencies: dependencies:
@ -246,6 +272,11 @@
"balanced-match" "^1.0.0" "balanced-match" "^1.0.0"
"concat-map" "0.0.1" "concat-map" "0.0.1"
"buffer-writer@2.0.0":
"integrity" "sha512-a7ZpuTZU1TRtnwyCNW3I5dc0wWNC3VR9S++Ewyk2HHZdrO3CQJqSpd+95Us590V6AL7JqUAH2IwZ/398PmNFgw=="
"resolved" "https://registry.npmjs.org/buffer-writer/-/buffer-writer-2.0.0.tgz"
"version" "2.0.0"
"busboy@^1.6.0": "busboy@^1.6.0":
"version" "1.6.0" "version" "1.6.0"
dependencies: dependencies:
@ -308,7 +339,7 @@
"shebang-command" "^2.0.0" "shebang-command" "^2.0.0"
"which" "^2.0.1" "which" "^2.0.1"
"debug@4": "debug@^4.3.3", "debug@4":
"version" "4.3.4" "version" "4.3.4"
dependencies: dependencies:
"ms" "2.1.2" "ms" "2.1.2"
@ -356,6 +387,11 @@
"dotenv@^10.0.0": "dotenv@^10.0.0":
"version" "10.0.0" "version" "10.0.0"
"dottie@^2.0.2":
"integrity" "sha512-4liA0PuRkZWQFQjwBypdxPfZaRWiv5tkhMXY2hzsa2pNf5s7U3m9cwUchfNKe8wZQxdGPQQzO6Rm2uGe0rvohQ=="
"resolved" "https://registry.npmjs.org/dottie/-/dottie-2.0.3.tgz"
"version" "2.0.3"
"duplexer@~0.1.1": "duplexer@~0.1.1":
"version" "0.1.2" "version" "0.1.2"
@ -573,6 +609,11 @@
"ieee754@^1.2.1": "ieee754@^1.2.1":
"version" "1.2.1" "version" "1.2.1"
"inflection@^1.13.2":
"integrity" "sha512-6I/HUDeYFfuNCVS3td055BaXBwKYuzw7K3ExVMStBowKo9oOAMJIXIHvdyR3iboTCp1b+1i5DSkIZTcwIktuDw=="
"resolved" "https://registry.npmjs.org/inflection/-/inflection-1.13.4.tgz"
"version" "1.13.4"
"inflight@^1.0.4": "inflight@^1.0.4":
"version" "1.0.6" "version" "1.0.6"
dependencies: dependencies:
@ -727,6 +768,18 @@
"mkdirp@^1.0.3": "mkdirp@^1.0.3":
"version" "1.0.4" "version" "1.0.4"
"moment-timezone@^0.5.34":
"integrity" "sha512-tWfmNkRYmBkPJz5mr9GVDn9vRlVZOTe6yqY92rFxiOdWXbjaR0+9LwQnZGGuNR63X456NqmEkbskte8tWL5ePg=="
"resolved" "https://registry.npmjs.org/moment-timezone/-/moment-timezone-0.5.40.tgz"
"version" "0.5.40"
dependencies:
"moment" ">= 2.9.0"
"moment@^2.29.1", "moment@>= 2.9.0":
"integrity" "sha512-5LC9SOxjSc2HF6vO2CyuTDNivEdoz2IvyJJGj6X8DJ0eFyfszE0QiEd+iXmBvUP3WHxSjFH/vIsA0EN00cgr8w=="
"resolved" "https://registry.npmjs.org/moment/-/moment-2.29.4.tgz"
"version" "2.29.4"
"ms@2.1.2": "ms@2.1.2":
"version" "2.1.2" "version" "2.1.2"
@ -805,6 +858,11 @@
dependencies: dependencies:
"wrappy" "1" "wrappy" "1"
"packet-reader@1.0.0":
"integrity" "sha512-HAKu/fG3HpHFO0AA8WE8q2g+gBJaZ9MG7fcKk+IJPLTGAD6Psw4443l+9DGRbOIh3/aXr7Phy0TjilYivJo5XQ=="
"resolved" "https://registry.npmjs.org/packet-reader/-/packet-reader-1.0.0.tgz"
"version" "1.0.0"
"parse-json@^4.0.0": "parse-json@^4.0.0":
"version" "4.0.0" "version" "4.0.0"
dependencies: dependencies:
@ -836,12 +894,92 @@
"peek-readable@^5.0.0": "peek-readable@^5.0.0":
"version" "5.0.0" "version" "5.0.0"
"pg-connection-string@^2.5.0":
"integrity" "sha512-r5o/V/ORTA6TmUnyWZR9nCj1klXCO2CEKNRlVuJptZe85QuhFayC7WeMic7ndayT5IRIR0S0xFxFi2ousartlQ=="
"resolved" "https://registry.npmjs.org/pg-connection-string/-/pg-connection-string-2.5.0.tgz"
"version" "2.5.0"
"pg-hstore@^2.3.4":
"integrity" "sha512-N3SGs/Rf+xA1M2/n0JBiXFDVMzdekwLZLAO0g7mpDY9ouX+fDI7jS6kTq3JujmYbtNSJ53TJ0q4G98KVZSM4EA=="
"resolved" "https://registry.npmjs.org/pg-hstore/-/pg-hstore-2.3.4.tgz"
"version" "2.3.4"
dependencies:
"underscore" "^1.13.1"
"pg-int8@1.0.1":
"integrity" "sha512-WCtabS6t3c8SkpDBUlb1kjOs7l66xsGdKpIPZsg4wR+B3+u9UAum2odSsF9tnvxg80h4ZxLWMy4pRjOsFIqQpw=="
"resolved" "https://registry.npmjs.org/pg-int8/-/pg-int8-1.0.1.tgz"
"version" "1.0.1"
"pg-pool@^3.5.2":
"integrity" "sha512-His3Fh17Z4eg7oANLob6ZvH8xIVen3phEZh2QuyrIl4dQSDVEabNducv6ysROKpDNPSD+12tONZVWfSgMvDD9w=="
"resolved" "https://registry.npmjs.org/pg-pool/-/pg-pool-3.5.2.tgz"
"version" "3.5.2"
"pg-protocol@*", "pg-protocol@^1.6.0":
"integrity" "sha512-M+PDm637OY5WM307051+bsDia5Xej6d9IR4GwJse1qA1DIhiKlksvrneZOYQq42OM+spubpcNYEo2FcKQrDk+Q=="
"resolved" "https://registry.npmjs.org/pg-protocol/-/pg-protocol-1.6.0.tgz"
"version" "1.6.0"
"pg-types@^2.1.0", "pg-types@^2.2.0":
"integrity" "sha512-qTAAlrEsl8s4OiEQY69wDvcMIdQN6wdz5ojQiOy6YRMuynxenON0O5oCpJI6lshc6scgAY8qvJ2On/p+CXY0GA=="
"resolved" "https://registry.npmjs.org/pg-types/-/pg-types-2.2.0.tgz"
"version" "2.2.0"
dependencies:
"pg-int8" "1.0.1"
"postgres-array" "~2.0.0"
"postgres-bytea" "~1.0.0"
"postgres-date" "~1.0.4"
"postgres-interval" "^1.1.0"
"pg@^8.9.0", "pg@>=8.0":
"integrity" "sha512-ZJM+qkEbtOHRuXjmvBtOgNOXOtLSbxiMiUVMgE4rV6Zwocy03RicCVvDXgx8l4Biwo8/qORUnEqn2fdQzV7KCg=="
"resolved" "https://registry.npmjs.org/pg/-/pg-8.9.0.tgz"
"version" "8.9.0"
dependencies:
"buffer-writer" "2.0.0"
"packet-reader" "1.0.0"
"pg-connection-string" "^2.5.0"
"pg-pool" "^3.5.2"
"pg-protocol" "^1.6.0"
"pg-types" "^2.1.0"
"pgpass" "1.x"
"pgpass@1.x":
"integrity" "sha512-FdW9r/jQZhSeohs1Z3sI1yxFQNFvMcnmfuj4WBMUTxOrAyLMaTcE1aAMBiTlbMNaXvBCQuVi0R7hd8udDSP7ug=="
"resolved" "https://registry.npmjs.org/pgpass/-/pgpass-1.0.5.tgz"
"version" "1.0.5"
dependencies:
"split2" "^4.1.0"
"pidtree@^0.3.0": "pidtree@^0.3.0":
"version" "0.3.1" "version" "0.3.1"
"pify@^3.0.0": "pify@^3.0.0":
"version" "3.0.0" "version" "3.0.0"
"postgres-array@~2.0.0":
"integrity" "sha512-VpZrUqU5A69eQyW2c5CA1jtLecCsN2U/bD6VilrFDWq5+5UIEVO7nazS3TEcHf1zuPYO/sqGvUvW62g86RXZuA=="
"resolved" "https://registry.npmjs.org/postgres-array/-/postgres-array-2.0.0.tgz"
"version" "2.0.0"
"postgres-bytea@~1.0.0":
"integrity" "sha512-xy3pmLuQqRBZBXDULy7KbaitYqLcmxigw14Q5sj8QBVLqEwXfeybIKVWiqAXTlcvdvb0+xkOtDbfQMOf4lST1w=="
"resolved" "https://registry.npmjs.org/postgres-bytea/-/postgres-bytea-1.0.0.tgz"
"version" "1.0.0"
"postgres-date@~1.0.4":
"integrity" "sha512-suDmjLVQg78nMK2UZ454hAG+OAW+HQPZ6n++TNDUX+L0+uUlLywnoxJKDou51Zm+zTCjrCl0Nq6J9C5hP9vK/Q=="
"resolved" "https://registry.npmjs.org/postgres-date/-/postgres-date-1.0.7.tgz"
"version" "1.0.7"
"postgres-interval@^1.1.0":
"integrity" "sha512-9ZhXKM/rw350N1ovuWHbGxnGh/SNJ4cnxHiM0rxE4VN41wsg8P8zWn9hv/buK00RP4WvlOyr/RBDiptyxVbkZQ=="
"resolved" "https://registry.npmjs.org/postgres-interval/-/postgres-interval-1.2.0.tgz"
"version" "1.2.0"
dependencies:
"xtend" "^4.0.0"
"prettier@^2.8.2", "prettier@^2.8.3": "prettier@^2.8.2", "prettier@^2.8.3":
"version" "2.8.4" "version" "2.8.4"
@ -886,6 +1024,11 @@
"path-parse" "^1.0.7" "path-parse" "^1.0.7"
"supports-preserve-symlinks-flag" "^1.0.0" "supports-preserve-symlinks-flag" "^1.0.0"
"retry-as-promised@^7.0.3":
"integrity" "sha512-XgmCoxKWkDofwH8WddD0w85ZfqYz+ZHlr5yo+3YUCfycWawU56T5ckWXsScsj5B8tqUcIG67DxXByo3VUgiAdA=="
"resolved" "https://registry.npmjs.org/retry-as-promised/-/retry-as-promised-7.0.4.tgz"
"version" "7.0.4"
"rimraf@^3.0.2": "rimraf@^3.0.2":
"version" "3.0.2" "version" "3.0.2"
dependencies: dependencies:
@ -918,6 +1061,33 @@
"semver@2 || 3 || 4 || 5": "semver@2 || 3 || 4 || 5":
"version" "5.7.1" "version" "5.7.1"
"sequelize-pool@^7.1.0":
"integrity" "sha512-G9c0qlIWQSK29pR/5U2JF5dDQeqqHRragoyahj/Nx4KOOQ3CPPfzxnfqFPCSB7x5UgjOgnZ61nSxz+fjDpRlJg=="
"resolved" "https://registry.npmjs.org/sequelize-pool/-/sequelize-pool-7.1.0.tgz"
"version" "7.1.0"
"sequelize@^6.28.0":
"integrity" "sha512-+WHqvUQgTp19GLkt+gyQ+F6qg+FIEO2O5F9C0TOYV/PjZ2a/XwWvVkL1NCkS4VSIjVVvAUutiW6Wv9ofveGaVw=="
"resolved" "https://registry.npmjs.org/sequelize/-/sequelize-6.28.0.tgz"
"version" "6.28.0"
dependencies:
"@types/debug" "^4.1.7"
"@types/validator" "^13.7.1"
"debug" "^4.3.3"
"dottie" "^2.0.2"
"inflection" "^1.13.2"
"lodash" "^4.17.21"
"moment" "^2.29.1"
"moment-timezone" "^0.5.34"
"pg-connection-string" "^2.5.0"
"retry-as-promised" "^7.0.3"
"semver" "^7.3.5"
"sequelize-pool" "^7.1.0"
"toposort-class" "^1.0.1"
"uuid" "^8.3.2"
"validator" "^13.7.0"
"wkx" "^0.5.0"
"set-blocking@^2.0.0": "set-blocking@^2.0.0":
"version" "2.0.0" "version" "2.0.0"
@ -973,6 +1143,11 @@
dependencies: dependencies:
"through" "2" "through" "2"
"split2@^4.1.0":
"integrity" "sha512-VBiJxFkxiXRlUIeyMQi8s4hgvKCSjtknJv/LVYbrgALPwf5zSKmEwV9Lst25AkvMDnvxODugjdl6KZgwKM1WYQ=="
"resolved" "https://registry.npmjs.org/split2/-/split2-4.1.0.tgz"
"version" "4.1.0"
"stream-combiner@~0.0.4": "stream-combiner@~0.0.4":
"version" "0.0.4" "version" "0.0.4"
dependencies: dependencies:
@ -1058,6 +1233,11 @@
"@tokenizer/token" "^0.3.0" "@tokenizer/token" "^0.3.0"
"ieee754" "^1.2.1" "ieee754" "^1.2.1"
"toposort-class@^1.0.1":
"integrity" "sha512-OsLcGGbYF3rMjPUf8oKktyvCiUxSbqMMS39m33MAjLTC1DVIH6x3WSt63/M77ihI09+Sdfk1AXvfhCEeUmC7mg=="
"resolved" "https://registry.npmjs.org/toposort-class/-/toposort-class-1.0.1.tgz"
"version" "1.0.1"
"tr46@~0.0.3": "tr46@~0.0.3":
"version" "0.0.3" "version" "0.0.3"
@ -1093,6 +1273,11 @@
"has-symbols" "^1.0.3" "has-symbols" "^1.0.3"
"which-boxed-primitive" "^1.0.2" "which-boxed-primitive" "^1.0.2"
"underscore@^1.13.1":
"integrity" "sha512-+A5Sja4HP1M08MaXya7p5LvjuM7K6q/2EaC0+iovj/wOcMsTzMvDFbasi/oSapiwOlt252IqsKqPjCl7huKS0A=="
"resolved" "https://registry.npmjs.org/underscore/-/underscore-1.13.6.tgz"
"version" "1.13.6"
"undici@^5.13.0", "undici@^5.14.0": "undici@^5.13.0", "undici@^5.14.0":
"version" "5.18.0" "version" "5.18.0"
dependencies: dependencies:
@ -1101,12 +1286,22 @@
"util-deprecate@^1.0.1": "util-deprecate@^1.0.1":
"version" "1.0.2" "version" "1.0.2"
"uuid@^8.3.2":
"integrity" "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg=="
"resolved" "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz"
"version" "8.3.2"
"validate-npm-package-license@^3.0.1": "validate-npm-package-license@^3.0.1":
"version" "3.0.4" "version" "3.0.4"
dependencies: dependencies:
"spdx-correct" "^3.0.0" "spdx-correct" "^3.0.0"
"spdx-expression-parse" "^3.0.0" "spdx-expression-parse" "^3.0.0"
"validator@^13.7.0":
"integrity" "sha512-B+dGG8U3fdtM0/aNK4/X8CXq/EcxU2WPrPEkJGslb47qyHsxmbggTWK0yEA4qnYVNF+nxNlN88o14hIcPmSIEA=="
"resolved" "https://registry.npmjs.org/validator/-/validator-13.9.0.tgz"
"version" "13.9.0"
"webidl-conversions@^3.0.0": "webidl-conversions@^3.0.0":
"version" "3.0.1" "version" "3.0.1"
@ -1150,11 +1345,23 @@
dependencies: dependencies:
"string-width" "^1.0.2 || 2 || 3 || 4" "string-width" "^1.0.2 || 2 || 3 || 4"
"wkx@^0.5.0":
"integrity" "sha512-Xng/d4Ichh8uN4l0FToV/258EjMGU9MGcA0HV2d9B/ZpZB3lqQm7nkOdZdm5GhKtLLhAE7PiVQwN4eN+2YJJUg=="
"resolved" "https://registry.npmjs.org/wkx/-/wkx-0.5.0.tgz"
"version" "0.5.0"
dependencies:
"@types/node" "*"
"wrappy@1": "wrappy@1":
"version" "1.0.2" "version" "1.0.2"
"ws@^8.11.0": "ws@^8.11.0":
"version" "8.12.0" "version" "8.12.0"
"xtend@^4.0.0":
"integrity" "sha512-LKYU1iAXJXUgAXn9URjiu+MWhyUXHsvfp7mcuYm9dSUKK0/CjtrUwFAxD82/mCWbtLsGjFIad0wIsod4zrTAEQ=="
"resolved" "https://registry.npmjs.org/xtend/-/xtend-4.0.2.tgz"
"version" "4.0.2"
"yallist@^4.0.0": "yallist@^4.0.0":
"version" "4.0.0" "version" "4.0.0"