From c0d1e91d85becf2caa16a3a538189a3bf8ece38b Mon Sep 17 00:00:00 2001 From: benrobson Date: Sat, 11 Jan 2025 21:35:04 +1100 Subject: [PATCH 01/15] Append .js to some files and update deps. --- commands/devotion.mjs | 2 +- commands/votd.mjs | 2 +- cron/daily.js | 4 +- package-lock.json | 363 ++++++++++++++++++++++++------------------ package.json | 2 +- 5 files changed, 212 insertions(+), 161 deletions(-) diff --git a/commands/devotion.mjs b/commands/devotion.mjs index 5b0fb39..bb5c991 100644 --- a/commands/devotion.mjs +++ b/commands/devotion.mjs @@ -1,5 +1,5 @@ import { Command, RegisterBehavior } from '@sapphire/framework'; -import { compileDevotionMessage, getDevotion } from '../controller/devotionController'; +import { compileDevotionMessage, getDevotion } from '../controller/devotionController.js'; export class DevotionCommand extends Command { constructor(context, options) { diff --git a/commands/votd.mjs b/commands/votd.mjs index 50babc4..05727a1 100644 --- a/commands/votd.mjs +++ b/commands/votd.mjs @@ -1,5 +1,5 @@ import { Command, RegisterBehavior } from '@sapphire/framework'; -import { compileVotdMessage, getVotd } from '../controller/votdController'; +import { compileVotdMessage, getVotd } from '../controller/votdController.js'; export class VotdCommand extends Command { constructor(context, options) { diff --git a/cron/daily.js b/cron/daily.js index c10fe25..c5a2aab 100644 --- a/cron/daily.js +++ b/cron/daily.js @@ -1,6 +1,6 @@ import cron from 'node-cron'; -import { sendDevotion } from '../controller/devotionController'; -import { sendVotd } from '../controller/votdController'; +import { sendDevotion } from '../controller/devotionController.js'; +import { sendVotd } from '../controller/votdController.js'; // // DAILY Cron Jobs [Firing at 7:00am] diff --git a/package-lock.json b/package-lock.json index 0f93059..8a91a8e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -26,6 +26,7 @@ "resolved": "https://registry.npmjs.org/@discordjs/builders/-/builders-0.16.0.tgz", "integrity": "sha512-9/NCiZrLivgRub2/kBc0Vm5pMBE5AUdYbdXsLu/yg9ANgvnaJ0bZKTY8yYnLbsEc/LYUP79lEIdC73qEYhWq7A==", "deprecated": "no longer supported", + "license": "Apache-2.0", "dependencies": { "@sapphire/shapeshift": "^3.5.1", "discord-api-types": "^0.36.2", @@ -38,17 +39,19 @@ } }, "node_modules/@discordjs/collection": { - "version": "1.5.0", - "resolved": "https://registry.npmjs.org/@discordjs/collection/-/collection-1.5.0.tgz", - "integrity": "sha512-suyVndkEAAWrGxyw/CPGdtXoRRU6AUNkibtnbJevQzpelkJh3Q1gQqWDpqf5i39CnAn5+LrN0YS+cULeEjq2Yw==", + "version": "1.5.3", + "resolved": "https://registry.npmjs.org/@discordjs/collection/-/collection-1.5.3.tgz", + "integrity": "sha512-SVb428OMd3WO1paV3rm6tSjM4wC+Kecaa1EUGX7vc6/fddvw/6lg90z4QtCqm21zvVe92vMMDt9+DkIvjXImQQ==", + "license": "Apache-2.0", "engines": { - "node": ">=16.9.0" + "node": ">=16.11.0" } }, "node_modules/@sapphire/async-queue": { - "version": "1.5.0", - "resolved": "https://registry.npmjs.org/@sapphire/async-queue/-/async-queue-1.5.0.tgz", - "integrity": "sha512-JkLdIsP8fPAdh9ZZjrbHWR/+mZj0wvKS5ICibcLrRI1j84UmLMshx5n9QmL8b95d4onJ2xxiyugTgSAX7AalmA==", + "version": "1.5.5", + "resolved": "https://registry.npmjs.org/@sapphire/async-queue/-/async-queue-1.5.5.tgz", + "integrity": "sha512-cvGzxbba6sav2zZkH8GPf2oGk9yYoD5qrNWdu9fRehifgnFZJMV+nuy2nON2roRO4yQQ+v7MK/Pktl/HgfsUXg==", + "license": "MIT", "engines": { "node": ">=v14.0.0", "npm": ">=7.0.0" @@ -58,6 +61,7 @@ "version": "2.12.0", "resolved": "https://registry.npmjs.org/@sapphire/discord-utilities/-/discord-utilities-2.12.0.tgz", "integrity": "sha512-E/Qqb8PwEoX/WLVfcGvTglTgEGGcc/2rGtKBqhMcHcEEtNIY8dhQVYbW/KMNJpR/J81OqUJquVzpkzRe6fQWiw==", + "license": "MIT", "dependencies": { "discord-api-types": "^0.36.3" }, @@ -70,6 +74,7 @@ "version": "5.1.2", "resolved": "https://registry.npmjs.org/@sapphire/discord.js-utilities/-/discord.js-utilities-5.1.2.tgz", "integrity": "sha512-zKXUkVzueT3Zag9D/ubpey0g/vLXLCVVFlmYoZqpkx1HsTLSTKz4hxbD7IQ/8q7rvI5Pm/Ex1jajPHMLXKmlpw==", + "license": "MIT", "dependencies": { "@sapphire/discord-utilities": "^2.12.0", "@sapphire/duration": "^1.0.0", @@ -82,9 +87,10 @@ } }, "node_modules/@sapphire/duration": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/@sapphire/duration/-/duration-1.1.0.tgz", - "integrity": "sha512-ATb2pWPLcSgG7bzvT6MglUcDexFSufr2FLXUmhipWGFtZbvDhkopGBIuHyzoGy7LZvL8UY5T6pRLNdFv5pl/Lg==", + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/@sapphire/duration/-/duration-1.1.4.tgz", + "integrity": "sha512-hxtuE8HvmWcRok2A10lJ+ic8qY0oYGTTn44XmESUYJYYSVJWmqlCH1LnNYi6Ul+LRjxNUfFQEL/TJS0GJ+8kew==", + "license": "MIT", "engines": { "node": ">=v14.0.0", "npm": ">=7.0.0" @@ -94,6 +100,7 @@ "version": "3.2.0", "resolved": "https://registry.npmjs.org/@sapphire/framework/-/framework-3.2.0.tgz", "integrity": "sha512-GrxOlyxrydhwXH68zVwhaEys0XLqEJg6o0TCZLtEYhhDY6oRoOl1MwEiomS1cbDYNRpPkdY7ljHcxD44U6cZ9g==", + "license": "MIT", "dependencies": { "@discordjs/builders": "^0.16.0", "@sapphire/discord-utilities": "^2.12.0", @@ -111,11 +118,12 @@ } }, "node_modules/@sapphire/lexure": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/@sapphire/lexure/-/lexure-1.1.2.tgz", - "integrity": "sha512-+v3P3EMDdFoybHH7c7cMcz30jEyxujkxWu5f958cf/Sm27fMM0IqwILnNFUpExZCBAueEM/eoSgbRl4q+K+0jg==", + "version": "1.1.10", + "resolved": "https://registry.npmjs.org/@sapphire/lexure/-/lexure-1.1.10.tgz", + "integrity": "sha512-odE4FD0SkCxkwEOhzAOqEnCJ/oJlPUuyFEw2KJacIuGiwY86WRTPIHLg1rt6XmfSYLxGXiqRf74req43+wRV9g==", + "license": "MIT", "dependencies": { - "@sapphire/result": "^2.6.0" + "@sapphire/result": "^2.7.2" }, "engines": { "node": ">=v14.0.0", @@ -123,13 +131,14 @@ } }, "node_modules/@sapphire/pieces": { - "version": "3.6.1", - "resolved": "https://registry.npmjs.org/@sapphire/pieces/-/pieces-3.6.1.tgz", - "integrity": "sha512-LKa0WaaDNwLP0pkRRSgZ9POrH/S2xx+iiymbp8TcB1U5R8ra9y1ijgHwksJJ/ofL/zEHN1Dgx6gZwLBn+Mkb7Q==", + "version": "3.10.0", + "resolved": "https://registry.npmjs.org/@sapphire/pieces/-/pieces-3.10.0.tgz", + "integrity": "sha512-iBaux50dA+VYjtBqmaceWcskdmw7ua51ojEPkyaSJyg2t9ln/Wc9NqYoQheRCWltZeDTERCUBIYYMqDuCs1Okw==", + "license": "MIT", "dependencies": { - "@discordjs/collection": "^1.4.0", - "@sapphire/utilities": "^3.11.0", - "tslib": "^2.5.0" + "@discordjs/collection": "^1.5.3", + "@sapphire/utilities": "^3.13.0", + "tslib": "^2.6.2" }, "engines": { "node": ">=v14.0.0", @@ -137,42 +146,45 @@ } }, "node_modules/@sapphire/ratelimits": { - "version": "2.4.6", - "resolved": "https://registry.npmjs.org/@sapphire/ratelimits/-/ratelimits-2.4.6.tgz", - "integrity": "sha512-E8ZogD+gtXw/iAFuyd42ZzUcYzOC3qGXZFOjU12o0cSYWObh7kQEqkS62BB0hMXy+GJH0X2+kqgMklME8EhWUg==", + "version": "2.4.11", + "resolved": "https://registry.npmjs.org/@sapphire/ratelimits/-/ratelimits-2.4.11.tgz", + "integrity": "sha512-O6FNA/P0wxU4Ve9gxL948CoZw7+sSpujyUR2CLyLLCNuNvuFGFxPCJVl5crFVLXMIyBIrc2qk+/H9bsqsyQK1Q==", + "license": "MIT", "engines": { "node": ">=v14.0.0", "npm": ">=7.0.0" } }, "node_modules/@sapphire/result": { - "version": "2.6.0", - "resolved": "https://registry.npmjs.org/@sapphire/result/-/result-2.6.0.tgz", - "integrity": "sha512-gdW6n/oDZ8aC1439Ub3RiLQ6L4VHAxbN0AhGJWNkEZ6Z6Ww2V62fwRiA/73OPfgYQKXk9ljhAFiqNO91KAonHQ==", + "version": "2.7.2", + "resolved": "https://registry.npmjs.org/@sapphire/result/-/result-2.7.2.tgz", + "integrity": "sha512-DJbCGmvi8UZAu/hh85auQL8bODFlpcS3cWjRJZ5/cXTLekmGvs/CrRxrIzwbA6+poyYojo5rK4qu8trmjfneog==", + "license": "MIT", "engines": { "node": ">=v14.0.0", "npm": ">=7.0.0" } }, "node_modules/@sapphire/shapeshift": { - "version": "3.8.2", - "resolved": "https://registry.npmjs.org/@sapphire/shapeshift/-/shapeshift-3.8.2.tgz", - "integrity": "sha512-NXpnJAsxN3/h9TqQPntOeVWZrpIuucqXI3IWF6tj2fWCoRLCuVK5wx7Dtg7pRrtkYfsMUbDqgKoX26vrC5iYfA==", + "version": "3.9.7", + "resolved": "https://registry.npmjs.org/@sapphire/shapeshift/-/shapeshift-3.9.7.tgz", + "integrity": "sha512-4It2mxPSr4OGn4HSQWGmhFMsNFGfFVhWeRPCRwbH972Ek2pzfGRZtb0pJ4Ze6oIzcyh2jw7nUDa6qGlWofgd9g==", + "license": "MIT", "dependencies": { "fast-deep-equal": "^3.1.3", "lodash": "^4.17.21" }, "engines": { - "node": ">=v14.0.0", - "npm": ">=7.0.0" + "node": ">=v16" } }, "node_modules/@sapphire/stopwatch": { - "version": "1.5.0", - "resolved": "https://registry.npmjs.org/@sapphire/stopwatch/-/stopwatch-1.5.0.tgz", - "integrity": "sha512-DtyKugdy3JTqm6JnEepTY64fGJAqlusDVrlrzifEgSCfGYCqpvB+SBldkWtDH+z+zLcp+PyaFLq7xpVfkhmvGg==", + "version": "1.5.4", + "resolved": "https://registry.npmjs.org/@sapphire/stopwatch/-/stopwatch-1.5.4.tgz", + "integrity": "sha512-IVI48D2yAz411bSttXyTkBH0p2vhrXoqWLn5loDDSAAEUGkM1r5KNCX2027ifQ8svdoMkUfIGjFueR+satLeWw==", + "license": "MIT", "dependencies": { - "tslib": "^2.4.0" + "tslib": "^2.8.1" }, "engines": { "node": ">=v14.0.0", @@ -180,58 +192,47 @@ } }, "node_modules/@sapphire/utilities": { - "version": "3.11.0", - "resolved": "https://registry.npmjs.org/@sapphire/utilities/-/utilities-3.11.0.tgz", - "integrity": "sha512-ich7J+329UTEgWxgk8b871rMhbFW/hvXdabdiKaUKd6g10eIMkIakWf+EGkDQsiDSiebIXll9TIPPmWtN3cVSw==", + "version": "3.18.1", + "resolved": "https://registry.npmjs.org/@sapphire/utilities/-/utilities-3.18.1.tgz", + "integrity": "sha512-zyEyQOQb2/t2mKRmu8T+M4r1Ulb+54BjwDS5pfzf6abGzTAcUg4VDWjHeKX7p3IgiZTcpN4Ij77b9k+K1KV4Lg==", + "license": "MIT", "engines": { - "node": ">=v14.0.0", - "npm": ">=7.0.0" + "node": ">=v14.0.0" } }, "node_modules/@types/node": { - "version": "18.15.11", - "resolved": "https://registry.npmjs.org/@types/node/-/node-18.15.11.tgz", - "integrity": "sha512-E5Kwq2n4SbMzQOn6wnmBjuK9ouqlURrcZDVfbo9ftDDTFt3nk7ZKK4GMOzoYgnpQJKcxwQw+lGaBvvlMo0qN/Q==" - }, - "node_modules/@types/node-fetch": { - "version": "2.6.3", - "resolved": "https://registry.npmjs.org/@types/node-fetch/-/node-fetch-2.6.3.tgz", - "integrity": "sha512-ETTL1mOEdq/sxUtgtOhKjyB2Irra4cjxksvcMUR5Zr4n+PxVhsCD9WS46oPbHL3et9Zde7CNRr+WUNlcHvsX+w==", + "version": "22.10.5", + "resolved": "https://registry.npmjs.org/@types/node/-/node-22.10.5.tgz", + "integrity": "sha512-F8Q+SeGimwOo86fiovQh8qiXfFEh2/ocYv7tU5pJ3EXMSSxk1Joj5wefpFK2fHTf/N6HKGSxIDBT9f3gCxXPkQ==", + "license": "MIT", "dependencies": { - "@types/node": "*", - "form-data": "^3.0.0" + "undici-types": "~6.20.0" } }, - "node_modules/@types/node-fetch/node_modules/form-data": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/form-data/-/form-data-3.0.1.tgz", - "integrity": "sha512-RHkBKtLWUVwd7SqRIvCZMEvAMoGUp0XU+seQiZejj0COz3RI3hWP4sCv3gZWWLjJTd7rGwcsF5eKZGii0r/hbg==", + "node_modules/@types/node-fetch": { + "version": "2.6.12", + "resolved": "https://registry.npmjs.org/@types/node-fetch/-/node-fetch-2.6.12.tgz", + "integrity": "sha512-8nneRWKCg3rMtF69nLQJnOYUcbafYeFSjqkw3jCRLsqkWFlHaoQrr5mXmofFGOx3DKn7UfmBMyov8ySvLRVldA==", + "license": "MIT", "dependencies": { - "asynckit": "^0.4.0", - "combined-stream": "^1.0.8", - "mime-types": "^2.1.12" - }, - "engines": { - "node": ">= 6" + "@types/node": "*", + "form-data": "^4.0.0" } }, "node_modules/@types/ws": { - "version": "8.5.4", - "resolved": "https://registry.npmjs.org/@types/ws/-/ws-8.5.4.tgz", - "integrity": "sha512-zdQDHKUgcX/zBc4GrwsE/7dVdAD8JR4EuiAXiiUhhfyIJXXb2+PrGshFyeXWQPMmmZ2XxgaqclgpIC7eTXc1mg==", + "version": "8.5.13", + "resolved": "https://registry.npmjs.org/@types/ws/-/ws-8.5.13.tgz", + "integrity": "sha512-osM/gWBTPKgHV8XkTunnegTRIsvF6owmf5w+JtAfOw472dptdm0dlGv4xCt6GwQRcC2XVOvvRE/0bAoQcL2QkA==", + "license": "MIT", "dependencies": { "@types/node": "*" } }, - "node_modules/abbrev": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/abbrev/-/abbrev-1.1.1.tgz", - "integrity": "sha512-nne9/IiQ/hzIhY6pdDnbBtz7DjPTKrY00P/zvPSm5pOFkl6xuGrGnXn/VtTNNfNtAfZ9/1RtehkszU9qcTii0Q==" - }, "node_modules/anymatch": { "version": "3.1.3", "resolved": "https://registry.npmjs.org/anymatch/-/anymatch-3.1.3.tgz", "integrity": "sha512-KMReFUr0B4t+D+OBkjR3KYqvocp2XaSzO55UcB6mgQMd3KbcE+mWTyvVV7D/zsdEbNnV6acZUutkiHQXvTr1Rw==", + "license": "ISC", "dependencies": { "normalize-path": "^3.0.0", "picomatch": "^2.0.4" @@ -243,51 +244,54 @@ "node_modules/asynckit": { "version": "0.4.0", "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", - "integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==" + "integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==", + "license": "MIT" }, "node_modules/balanced-match": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", - "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==" + "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==", + "license": "MIT" }, "node_modules/binary-extensions": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-2.2.0.tgz", - "integrity": "sha512-jDctJ/IVQbZoJykoeHbhXpOlNBqGNcwXJKJog42E5HDPUwQTSdjCHdihjj0DlnheQ7blbT6dHOafNAiS8ooQKA==", + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-2.3.0.tgz", + "integrity": "sha512-Ceh+7ox5qe7LJuLHoY0feh3pHuUDHAcRUeyL2VYghZwfpkNIy/+8Ocg0a3UuSoYzavmylwuLWQOf3hl0jjMMIw==", + "license": "MIT", "engines": { "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" } }, "node_modules/brace-expansion": { "version": "1.1.11", "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", + "license": "MIT", "dependencies": { "balanced-match": "^1.0.0", "concat-map": "0.0.1" } }, "node_modules/braces": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.2.tgz", - "integrity": "sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A==", + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.3.tgz", + "integrity": "sha512-yQbXgO/OSZVD2IsiLlro+7Hf6Q18EJrKSEsdoMzKePKXct3gvD8oLcOQdIzGupr5Fj+EDe8gO/lxc1BzfMpxvA==", + "license": "MIT", "dependencies": { - "fill-range": "^7.0.1" + "fill-range": "^7.1.1" }, "engines": { "node": ">=8" } }, "node_modules/chokidar": { - "version": "3.5.3", - "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.5.3.tgz", - "integrity": "sha512-Dr3sfKRP6oTcjf2JmUmFJfeVMvXBdegxB0iVQ5eb2V10uFJUCAS8OByZdVAyVb8xXNz3GjjTgj9kLWsZTqE6kw==", - "funding": [ - { - "type": "individual", - "url": "https://paulmillr.com/funding/" - } - ], + "version": "3.6.0", + "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.6.0.tgz", + "integrity": "sha512-7VT13fmjotKpGipCW9JEQAusEPE+Ei8nl6/g4FBAmIm0GOOLMua9NDDo/DWp0ZAxCr3cPq5ZpBqmPAQgDda2Pw==", + "license": "MIT", "dependencies": { "anymatch": "~3.1.2", "braces": "~3.0.2", @@ -300,6 +304,9 @@ "engines": { "node": ">= 8.10.0" }, + "funding": { + "url": "https://paulmillr.com/funding/" + }, "optionalDependencies": { "fsevents": "~2.3.2" } @@ -308,6 +315,7 @@ "version": "1.0.8", "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz", "integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==", + "license": "MIT", "dependencies": { "delayed-stream": "~1.0.0" }, @@ -318,12 +326,14 @@ "node_modules/concat-map": { "version": "0.0.1", "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", - "integrity": "sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==" + "integrity": "sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==", + "license": "MIT" }, "node_modules/data-uri-to-buffer": { "version": "4.0.1", "resolved": "https://registry.npmjs.org/data-uri-to-buffer/-/data-uri-to-buffer-4.0.1.tgz", "integrity": "sha512-0R9ikRb668HB7QDxT1vkpuUBtqc53YyAwMwGeUFKRojY/NWKvdZ+9UYtRfGmhqNbRkTSVpMbmyhXipFFv2cb/A==", + "license": "MIT", "engines": { "node": ">= 12" } @@ -332,6 +342,7 @@ "version": "3.2.7", "resolved": "https://registry.npmjs.org/debug/-/debug-3.2.7.tgz", "integrity": "sha512-CFjzYYAi4ThfiQvizrFQevTTXHtnCqWfe7x1AhgEscTz6ZbLbfoLRLPugTQyBth6f8ZERVUSyWHFD/7Wu4t1XQ==", + "license": "MIT", "dependencies": { "ms": "^2.1.1" } @@ -340,6 +351,7 @@ "version": "1.0.0", "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", "integrity": "sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ==", + "license": "MIT", "engines": { "node": ">=0.4.0" } @@ -347,12 +359,14 @@ "node_modules/discord-api-types": { "version": "0.36.3", "resolved": "https://registry.npmjs.org/discord-api-types/-/discord-api-types-0.36.3.tgz", - "integrity": "sha512-bz/NDyG0KBo/tY14vSkrwQ/n3HKPf87a0WFW/1M9+tXYK+vp5Z5EksawfCWo2zkAc6o7CClc0eff1Pjrqznlwg==" + "integrity": "sha512-bz/NDyG0KBo/tY14vSkrwQ/n3HKPf87a0WFW/1M9+tXYK+vp5Z5EksawfCWo2zkAc6o7CClc0eff1Pjrqznlwg==", + "license": "MIT" }, "node_modules/discord.js": { - "version": "13.16.0", - "resolved": "https://registry.npmjs.org/discord.js/-/discord.js-13.16.0.tgz", - "integrity": "sha512-bOoCs1Ilojd/UshZVxmEcpxVmHcYOv2fPVZOVq3aFV8xrKLJfaF9mxlvGZ1D1z9aIqf2NkptDr+QndeNuQBTxQ==", + "version": "13.17.1", + "resolved": "https://registry.npmjs.org/discord.js/-/discord.js-13.17.1.tgz", + "integrity": "sha512-h13kUf+7ZaP5ZWggzooCxFutvJJvugcAO54oTEIdVr3zQWi0Sf/61S1kETtuY9nVAyYebXR/Ey4C+oWbsgEkew==", + "license": "Apache-2.0", "dependencies": { "@discordjs/builders": "^0.16.0", "@discordjs/collection": "^0.7.0", @@ -374,6 +388,7 @@ "resolved": "https://registry.npmjs.org/@discordjs/collection/-/collection-0.7.0.tgz", "integrity": "sha512-R5i8Wb8kIcBAFEPLLf7LVBQKBDYUL+ekb23sOgpkpyGT+V4P7V83wTxcsqmX+PbqHt4cEHn053uMWfRqh/Z/nA==", "deprecated": "no longer supported", + "license": "Apache-2.0", "engines": { "node": ">=16.9.0" } @@ -381,12 +396,14 @@ "node_modules/discord.js/node_modules/discord-api-types": { "version": "0.33.5", "resolved": "https://registry.npmjs.org/discord-api-types/-/discord-api-types-0.33.5.tgz", - "integrity": "sha512-dvO5M52v7m7Dy96+XUnzXNsQ/0npsYpU6dL205kAtEDueswoz3aU3bh1UMoK4cQmcGtB1YRyLKqp+DXi05lzFg==" + "integrity": "sha512-dvO5M52v7m7Dy96+XUnzXNsQ/0npsYpU6dL205kAtEDueswoz3aU3bh1UMoK4cQmcGtB1YRyLKqp+DXi05lzFg==", + "license": "MIT" }, "node_modules/discord.js/node_modules/node-fetch": { - "version": "2.6.9", - "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.9.tgz", - "integrity": "sha512-DJm/CJkZkRjKKj4Zi4BsKVZh3ValV5IR5s7LVZnW+6YMh0W1BfNA8XSs6DLMGYlId5F3KnA70uu2qepcR08Qqg==", + "version": "2.7.0", + "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.7.0.tgz", + "integrity": "sha512-c4FRfUm/dbcWZ7U+1Wq0AwCyFL+3nt2bEw05wfxSz+DWpWsitgmSgYmy2dQdWyKC1694ELPqMs/YzUSNozLt8A==", + "license": "MIT", "dependencies": { "whatwg-url": "^5.0.0" }, @@ -403,17 +420,22 @@ } }, "node_modules/dotenv": { - "version": "16.0.3", - "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.0.3.tgz", - "integrity": "sha512-7GO6HghkA5fYG9TYnNxi14/7K9f5occMlp3zXAuSxn7CKCxt9xbNWG7yF8hTCSUchlfWSe3uLmlPfigevRItzQ==", + "version": "16.4.7", + "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.4.7.tgz", + "integrity": "sha512-47qPchRCykZC03FhkYAhrvwU4xDBFIj1QPqaarj6mdM/hgUzfPHcpkHJOn3mJAufFeeAxAzeGsr5X0M4k6fLZQ==", + "license": "BSD-2-Clause", "engines": { "node": ">=12" + }, + "funding": { + "url": "https://dotenvx.com" } }, "node_modules/fast-deep-equal": { "version": "3.1.3", "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz", - "integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==" + "integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==", + "license": "MIT" }, "node_modules/fetch-blob": { "version": "3.2.0", @@ -429,6 +451,7 @@ "url": "https://paypal.me/jimmywarting" } ], + "license": "MIT", "dependencies": { "node-domexception": "^1.0.0", "web-streams-polyfill": "^3.0.3" @@ -438,9 +461,10 @@ } }, "node_modules/fill-range": { - "version": "7.0.1", - "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.0.1.tgz", - "integrity": "sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ==", + "version": "7.1.1", + "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.1.1.tgz", + "integrity": "sha512-YsGpe3WHLK8ZYi4tWDg2Jy3ebRz2rXowDxnld4bkQB00cc/1Zw9AWnC0i9ztDJitivtQvaI9KaLyKrc+hBW0yg==", + "license": "MIT", "dependencies": { "to-regex-range": "^5.0.1" }, @@ -449,9 +473,10 @@ } }, "node_modules/form-data": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.0.tgz", - "integrity": "sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww==", + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.1.tgz", + "integrity": "sha512-tzN8e4TX8+kkxGPK8D5u0FNmjPUjw3lwC9lSLxxoB/+GtsJG91CO8bSWy73APlgAZzZbXEYZJuxjkHH2w+Ezhw==", + "license": "MIT", "dependencies": { "asynckit": "^0.4.0", "combined-stream": "^1.0.8", @@ -465,6 +490,7 @@ "version": "4.0.10", "resolved": "https://registry.npmjs.org/formdata-polyfill/-/formdata-polyfill-4.0.10.tgz", "integrity": "sha512-buewHzMvYL29jdeQTVILecSaZKnt/RJWjoZCF5OW60Z67/GmSLBkOFM7qh1PI3zFNtJbaZL5eQu1vLfazOwj4g==", + "license": "MIT", "dependencies": { "fetch-blob": "^3.1.2" }, @@ -473,10 +499,11 @@ } }, "node_modules/fsevents": { - "version": "2.3.2", - "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.2.tgz", - "integrity": "sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==", + "version": "2.3.3", + "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz", + "integrity": "sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==", "hasInstallScript": true, + "license": "MIT", "optional": true, "os": [ "darwin" @@ -489,6 +516,7 @@ "version": "5.1.2", "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.2.tgz", "integrity": "sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==", + "license": "ISC", "dependencies": { "is-glob": "^4.0.1" }, @@ -500,6 +528,7 @@ "version": "3.0.0", "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", "integrity": "sha512-sKJf1+ceQBr4SMkvQnBDNDtf4TXpVhVGateu0t918bl30FnbE2m4vNLX+VWe/dpjlb+HugGYzW7uQXH98HPEYw==", + "license": "MIT", "engines": { "node": ">=4" } @@ -507,12 +536,14 @@ "node_modules/ignore-by-default": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/ignore-by-default/-/ignore-by-default-1.0.1.tgz", - "integrity": "sha512-Ius2VYcGNk7T90CppJqcIkS5ooHUZyIQK+ClZfMfMNFEF9VSE73Fq+906u/CWu92x4gzZMWOwfFYckPObzdEbA==" + "integrity": "sha512-Ius2VYcGNk7T90CppJqcIkS5ooHUZyIQK+ClZfMfMNFEF9VSE73Fq+906u/CWu92x4gzZMWOwfFYckPObzdEbA==", + "license": "ISC" }, "node_modules/is-binary-path": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/is-binary-path/-/is-binary-path-2.1.0.tgz", "integrity": "sha512-ZMERYes6pDydyuGidse7OsHxtbI7WVeUEozgR/g7rd0xUimYNlvZRE/K2MgZTjWy725IfelLeVcEM97mmtRGXw==", + "license": "MIT", "dependencies": { "binary-extensions": "^2.0.0" }, @@ -524,6 +555,7 @@ "version": "2.1.1", "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz", "integrity": "sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ==", + "license": "MIT", "engines": { "node": ">=0.10.0" } @@ -532,6 +564,7 @@ "version": "4.0.3", "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.3.tgz", "integrity": "sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg==", + "license": "MIT", "dependencies": { "is-extglob": "^2.1.1" }, @@ -543,6 +576,7 @@ "version": "7.0.0", "resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz", "integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==", + "license": "MIT", "engines": { "node": ">=0.12.0" } @@ -550,12 +584,14 @@ "node_modules/lodash": { "version": "4.17.21", "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz", - "integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==" + "integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==", + "license": "MIT" }, "node_modules/mime-db": { "version": "1.52.0", "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz", "integrity": "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==", + "license": "MIT", "engines": { "node": ">= 0.6" } @@ -564,6 +600,7 @@ "version": "2.1.35", "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.35.tgz", "integrity": "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==", + "license": "MIT", "dependencies": { "mime-db": "1.52.0" }, @@ -575,6 +612,7 @@ "version": "3.1.2", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", + "license": "ISC", "dependencies": { "brace-expansion": "^1.1.7" }, @@ -585,12 +623,14 @@ "node_modules/ms": { "version": "2.1.3", "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", - "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==" + "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==", + "license": "MIT" }, "node_modules/node-cron": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/node-cron/-/node-cron-3.0.2.tgz", - "integrity": "sha512-iP8l0yGlNpE0e6q1o185yOApANRe47UPbLf4YxfbiNHt/RU5eBcGB/e0oudruheSf+LQeDMezqC5BVAb5wwRcQ==", + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/node-cron/-/node-cron-3.0.3.tgz", + "integrity": "sha512-dOal67//nohNgYWb+nWmg5dkFdIwDm8EpeGYMekPMrngV3637lqnX0lbUcCtgibHTz6SEz7DAIjKvKDFYCnO1A==", + "license": "ISC", "dependencies": { "uuid": "8.3.2" }, @@ -612,14 +652,16 @@ "url": "https://paypal.me/jimmywarting" } ], + "license": "MIT", "engines": { "node": ">=10.5.0" } }, "node_modules/node-fetch": { - "version": "3.3.1", - "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-3.3.1.tgz", - "integrity": "sha512-cRVc/kyto/7E5shrWca1Wsea4y6tL9iYJE5FBCius3JQfb/4P4I295PfhgbJQBLTx6lATE4z+wK0rPM4VS2uow==", + "version": "3.3.2", + "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-3.3.2.tgz", + "integrity": "sha512-dRB78srN/l6gqWulah9SrxeYnxeddIG30+GOqK/9OlLVyLg3HPnr6SqOWTWOXKRwC2eGYCkZ59NNuSgvSrpgOA==", + "license": "MIT", "dependencies": { "data-uri-to-buffer": "^4.0.0", "fetch-blob": "^3.1.4", @@ -637,6 +679,7 @@ "version": "2.0.22", "resolved": "https://registry.npmjs.org/nodemon/-/nodemon-2.0.22.tgz", "integrity": "sha512-B8YqaKMmyuCO7BowF1Z1/mkPqLk6cs/l63Ojtd6otKjMx47Dq1utxfRxcavH1I7VSaL8n5BUaoutadnsX3AAVQ==", + "license": "MIT", "dependencies": { "chokidar": "^3.5.2", "debug": "^3.2.7", @@ -660,24 +703,11 @@ "url": "https://opencollective.com/nodemon" } }, - "node_modules/nopt": { - "version": "1.0.10", - "resolved": "https://registry.npmjs.org/nopt/-/nopt-1.0.10.tgz", - "integrity": "sha512-NWmpvLSqUrgrAC9HCuxEvb+PSloHpqVu+FqcO4eeF2h5qYRhA7ev6KvelyQAKtegUbC6RypJnlEOhd8vloNKYg==", - "dependencies": { - "abbrev": "1" - }, - "bin": { - "nopt": "bin/nopt.js" - }, - "engines": { - "node": "*" - } - }, "node_modules/normalize-path": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-3.0.0.tgz", "integrity": "sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==", + "license": "MIT", "engines": { "node": ">=0.10.0" } @@ -686,6 +716,7 @@ "version": "2.3.1", "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz", "integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==", + "license": "MIT", "engines": { "node": ">=8.6" }, @@ -696,12 +727,14 @@ "node_modules/pstree.remy": { "version": "1.1.8", "resolved": "https://registry.npmjs.org/pstree.remy/-/pstree.remy-1.1.8.tgz", - "integrity": "sha512-77DZwxQmxKnu3aR542U+X8FypNzbfJ+C5XQDk3uWjWxn6151aIMGthWYRXTqT1E5oJvg+ljaa2OJi+VfvCOQ8w==" + "integrity": "sha512-77DZwxQmxKnu3aR542U+X8FypNzbfJ+C5XQDk3uWjWxn6151aIMGthWYRXTqT1E5oJvg+ljaa2OJi+VfvCOQ8w==", + "license": "MIT" }, "node_modules/readdirp": { "version": "3.6.0", "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-3.6.0.tgz", "integrity": "sha512-hOS089on8RduqdbhvQ5Z37A0ESjsqz6qnRcffsMU3495FuTdqSm+7bhJ29JvIOsBDEEnan5DPu9t3To9VRlMzA==", + "license": "MIT", "dependencies": { "picomatch": "^2.2.1" }, @@ -710,9 +743,10 @@ } }, "node_modules/semver": { - "version": "5.7.1", - "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.1.tgz", - "integrity": "sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ==", + "version": "5.7.2", + "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.2.tgz", + "integrity": "sha512-cBznnQ9KjJqU67B52RMC65CMarK2600WFnbkcaiwWq3xy/5haFJlshgnpjovMVJ+Hff49d8GEn0b87C5pDQ10g==", + "license": "ISC", "bin": { "semver": "bin/semver" } @@ -721,6 +755,7 @@ "version": "1.1.0", "resolved": "https://registry.npmjs.org/simple-update-notifier/-/simple-update-notifier-1.1.0.tgz", "integrity": "sha512-VpsrsJSUcJEseSbMHkrsrAVSdvVS5I96Qo1QAQ4FxQ9wXFcB+pjj7FB7/us9+GcgfW4ziHtYMc1J0PLczb55mg==", + "license": "MIT", "dependencies": { "semver": "~7.0.0" }, @@ -732,6 +767,7 @@ "version": "7.0.0", "resolved": "https://registry.npmjs.org/semver/-/semver-7.0.0.tgz", "integrity": "sha512-+GB6zVA9LWh6zovYQLALHwv5rb2PHGlJi3lfiqIHxR0uuwCgefcOJc59v9fv1w8GbStwxuuqqAjI9NMAOOgq1A==", + "license": "ISC", "bin": { "semver": "bin/semver.js" } @@ -740,6 +776,7 @@ "version": "5.5.0", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==", + "license": "MIT", "dependencies": { "has-flag": "^3.0.0" }, @@ -751,6 +788,7 @@ "version": "5.0.1", "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz", "integrity": "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==", + "license": "MIT", "dependencies": { "is-number": "^7.0.0" }, @@ -759,12 +797,10 @@ } }, "node_modules/touch": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/touch/-/touch-3.1.0.tgz", - "integrity": "sha512-WBx8Uy5TLtOSRtIq+M03/sKDrXCLHxwDcquSP2c43Le03/9serjQBIztjRz6FkJez9D/hleyAXTBGLwwZUw9lA==", - "dependencies": { - "nopt": "~1.0.10" - }, + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/touch/-/touch-3.1.1.tgz", + "integrity": "sha512-r0eojU4bI8MnHr8c5bNo7lJDdI2qXlWWJk6a9EAFG7vbhTjElYhBVS3/miuE0uOuoLdb8Mc/rVfsmm6eo5o9GA==", + "license": "ISC", "bin": { "nodetouch": "bin/nodetouch.js" } @@ -772,35 +808,47 @@ "node_modules/tr46": { "version": "0.0.3", "resolved": "https://registry.npmjs.org/tr46/-/tr46-0.0.3.tgz", - "integrity": "sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw==" + "integrity": "sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw==", + "license": "MIT" }, "node_modules/ts-mixer": { - "version": "6.0.3", - "resolved": "https://registry.npmjs.org/ts-mixer/-/ts-mixer-6.0.3.tgz", - "integrity": "sha512-k43M7uCG1AkTyxgnmI5MPwKoUvS/bRvLvUb7+Pgpdlmok8AoqmUaZxUUw8zKM5B1lqZrt41GjYgnvAi0fppqgQ==" + "version": "6.0.4", + "resolved": "https://registry.npmjs.org/ts-mixer/-/ts-mixer-6.0.4.tgz", + "integrity": "sha512-ufKpbmrugz5Aou4wcr5Wc1UUFWOLhq+Fm6qa6P0w0K5Qw2yhaUoiWszhCVuNQyNwrlGiscHOmqYoAox1PtvgjA==", + "license": "MIT" }, "node_modules/tslib": { - "version": "2.5.0", - "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.5.0.tgz", - "integrity": "sha512-336iVw3rtn2BUK7ORdIAHTyxHGRIHVReokCR3XjbckJMK7ms8FysBfhLR8IXnAgy7T0PTPNBWKiH514FOW/WSg==" + "version": "2.8.1", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.8.1.tgz", + "integrity": "sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w==", + "license": "0BSD" }, "node_modules/undefsafe": { "version": "2.0.5", "resolved": "https://registry.npmjs.org/undefsafe/-/undefsafe-2.0.5.tgz", - "integrity": "sha512-WxONCrssBM8TSPRqN5EmsjVrsv4A8X12J4ArBiiayv3DyyG3ZlIg6yysuuSYdZsVz3TKcTg2fd//Ujd4CHV1iA==" + "integrity": "sha512-WxONCrssBM8TSPRqN5EmsjVrsv4A8X12J4ArBiiayv3DyyG3ZlIg6yysuuSYdZsVz3TKcTg2fd//Ujd4CHV1iA==", + "license": "MIT" + }, + "node_modules/undici-types": { + "version": "6.20.0", + "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-6.20.0.tgz", + "integrity": "sha512-Ny6QZ2Nju20vw1SRHe3d9jVu6gJ+4e3+MMpqu7pqE5HT6WsTSlce++GQmK5UXS8mzV8DSYHrQH+Xrf2jVcuKNg==", + "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==", + "license": "MIT", "bin": { "uuid": "dist/bin/uuid" } }, "node_modules/web-streams-polyfill": { - "version": "3.2.1", - "resolved": "https://registry.npmjs.org/web-streams-polyfill/-/web-streams-polyfill-3.2.1.tgz", - "integrity": "sha512-e0MO3wdXWKrLbL0DgGnUV7WHVuw9OUvL4hjgnPkIeEvESk74gAITi5G606JtZPp39cd8HA9VQzCIvA49LpPN5Q==", + "version": "3.3.3", + "resolved": "https://registry.npmjs.org/web-streams-polyfill/-/web-streams-polyfill-3.3.3.tgz", + "integrity": "sha512-d2JWLCivmZYTSIoge9MsgFCZrt571BikcWGYkjC1khllbTeDlGqZ2D8vD8E/lJa8WGWbb7Plm8/XJYV7IJHZZw==", + "license": "MIT", "engines": { "node": ">= 8" } @@ -808,21 +856,24 @@ "node_modules/webidl-conversions": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-3.0.1.tgz", - "integrity": "sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ==" + "integrity": "sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ==", + "license": "BSD-2-Clause" }, "node_modules/whatwg-url": { "version": "5.0.0", "resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-5.0.0.tgz", "integrity": "sha512-saE57nupxk6v3HY35+jzBwYa0rKSy0XR8JSxZPwgLr7ys0IBzhGviA1/TUGJLmSVqs8pb9AnvICXEuOHLprYTw==", + "license": "MIT", "dependencies": { "tr46": "~0.0.3", "webidl-conversions": "^3.0.0" } }, "node_modules/ws": { - "version": "8.13.0", - "resolved": "https://registry.npmjs.org/ws/-/ws-8.13.0.tgz", - "integrity": "sha512-x9vcZYTrFPC7aSIbj7sRCYo7L/Xb8Iy+pW0ng0wt2vCJv7M9HOMy0UoN3rr+IFC7hb7vXoqS+P9ktyLLLhO+LA==", + "version": "8.18.0", + "resolved": "https://registry.npmjs.org/ws/-/ws-8.18.0.tgz", + "integrity": "sha512-8VbfWfHLbbwu3+N6OKsOMpBdT4kXPDDB9cJk2bJ6mh9ucxdlnNvH1e+roYkKmN9Nxw2yjz7VzeO9oOz2zJ04Pw==", + "license": "MIT", "engines": { "node": ">=10.0.0" }, diff --git a/package.json b/package.json index 55df41b..e99e550 100644 --- a/package.json +++ b/package.json @@ -12,7 +12,7 @@ }, "engines": { "npm": ">=8.5.0", - "node": "16.17.0" + "node": "20.0.0" }, "keywords": [], "author": "ModularSoft", From 54a3e7f40d326f41e35cefdfe462d10e90392105 Mon Sep 17 00:00:00 2001 From: benrobson Date: Sat, 11 Jan 2025 22:35:41 +1100 Subject: [PATCH 02/15] Start draft on API discord instance. --- .env.example | 1 + listeners/guildCreate.js | 10 ++++++++++ package-lock.json | 5 ++--- package.json | 2 +- 4 files changed, 14 insertions(+), 4 deletions(-) create mode 100644 listeners/guildCreate.js diff --git a/.env.example b/.env.example index e226d2c..806548f 100644 --- a/.env.example +++ b/.env.example @@ -1,3 +1,4 @@ DISCORDAPIKEY=TOKEN APIURL=http://example.com +APIKEY=KEY TZ=Australia/Sydney \ No newline at end of file diff --git a/listeners/guildCreate.js b/listeners/guildCreate.js new file mode 100644 index 0000000..b1bd847 --- /dev/null +++ b/listeners/guildCreate.js @@ -0,0 +1,10 @@ +import { Listener } from "@sapphire/framework"; + +export class GuildCreateListener extends Listener { + async run(guild) { + // Log information about the new guild + this.container.logger.info( + `[CONSOLE] [DISCORD] Joined a new guild: ${guild.name} (${guild.id})` + ); + } +} diff --git a/package-lock.json b/package-lock.json index 8a91a8e..86a7f1b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -13,11 +13,11 @@ "discord.js": "^13.16.0", "dotenv": "^16.0.3", "node-cron": "^3.0.2", - "node-fetch": "^3.3.1", + "node-fetch": "^3.3.2", "nodemon": "^2.0.22" }, "engines": { - "node": "16.17.0", + "node": "20.0.0", "npm": ">=8.5.0" } }, @@ -661,7 +661,6 @@ "version": "3.3.2", "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-3.3.2.tgz", "integrity": "sha512-dRB78srN/l6gqWulah9SrxeYnxeddIG30+GOqK/9OlLVyLg3HPnr6SqOWTWOXKRwC2eGYCkZ59NNuSgvSrpgOA==", - "license": "MIT", "dependencies": { "data-uri-to-buffer": "^4.0.0", "fetch-blob": "^3.1.4", diff --git a/package.json b/package.json index e99e550..2319543 100644 --- a/package.json +++ b/package.json @@ -22,7 +22,7 @@ "discord.js": "^13.16.0", "dotenv": "^16.0.3", "node-cron": "^3.0.2", - "node-fetch": "^3.3.1", + "node-fetch": "^3.3.2", "nodemon": "^2.0.22" } } From 8ae54aeee7e30c16dbe8835702f2da5c3f148dd4 Mon Sep 17 00:00:00 2001 From: benrobson Date: Sun, 12 Jan 2025 21:08:29 +1100 Subject: [PATCH 03/15] Implement devotion completion button and stat --- app.js | 1 + commands/devotion.mjs | 29 +++++++--- controller/devotionController.js | 93 +++++++++++++++++++++++++------- listeners/guildCreate.js | 17 ++++-- listeners/ready.js | 3 ++ 5 files changed, 112 insertions(+), 31 deletions(-) diff --git a/app.js b/app.js index 291817d..447a63a 100644 --- a/app.js +++ b/app.js @@ -3,6 +3,7 @@ import packageData from './package.json' assert {type: "json"}; import dotenv from 'dotenv'; import dailyCron from './cron/daily.js'; +import { sendDevotion } from './controller/devotionController.js'; dotenv.config(); // diff --git a/commands/devotion.mjs b/commands/devotion.mjs index bb5c991..1d3f925 100644 --- a/commands/devotion.mjs +++ b/commands/devotion.mjs @@ -1,14 +1,17 @@ -import { Command, RegisterBehavior } from '@sapphire/framework'; -import { compileDevotionMessage, getDevotion } from '../controller/devotionController.js'; +import { Command, RegisterBehavior } from "@sapphire/framework"; +import { + compileDevotionMessage, + getDevotion, +} from "../controller/devotionController.js"; export class DevotionCommand extends Command { constructor(context, options) { super(context, { ...options, - description: 'Display today\'s Devotion.', + description: "Display today's Devotion.", chatInputCommand: { register: true, - behaviorWhenNotIdentical: RegisterBehavior.Overwrite + behaviorWhenNotIdentical: RegisterBehavior.Overwrite, }, }); } @@ -22,9 +25,19 @@ export class DevotionCommand extends Command { } async chatInputRun(interaction) { - const devotionData = await getDevotion(); - const embed = await compileDevotionMessage(devotionData); + try { + const devotionData = await getDevotion(); + const embed = await compileDevotionMessage(devotionData); - return interaction.reply({ embeds: [embed] }); + // Reply to the interaction first + await interaction.reply({ embeds: [embed] }); + } catch (error) { + console.error(error); + // If an error occurs, edit the reply with an error message + await interaction.editReply({ + content: "An error occurred while processing the devotion.", + ephemeral: true, + }); + } } -} \ No newline at end of file +} diff --git a/controller/devotionController.js b/controller/devotionController.js index 326eee2..7da3608 100644 --- a/controller/devotionController.js +++ b/controller/devotionController.js @@ -1,6 +1,6 @@ import fetch from 'node-fetch'; import config from '../config.json' assert {type: "json"}; -import { MessageEmbed } from 'discord.js'; +import { MessageActionRow, MessageButton, MessageEmbed } from 'discord.js'; /* Get Devotion from API. @@ -46,25 +46,80 @@ export async function compileDevotionMessage(devotionData) { Send Devotion to channel */ export async function sendDevotion(client) { - try { - const devotionData = await getDevotion(); - const embed = await compileDevotionMessage(devotionData); + try { + const devotionData = await getDevotion(); + const embed = await compileDevotionMessage(devotionData); // Assuming this is generating the embed - const guild = await client.guilds.cache.get(config.discord.guildID); - if (!guild) { - console.log('Guild not found.'); - return; - } + // Create the "Done" button with green color (SUCCESS style) + const doneButton = new MessageButton() + .setCustomId("done_button") + .setLabel("📖 Complete") + .setStyle("SUCCESS"); - const devotionChannel = guild.channels.cache.get(config.discord.channel.devotion); - if (!devotionChannel) { - console.log('Channel not found.'); - return; - } + // Create an action row and add the button to it + const actionRow = new MessageActionRow().addComponents(doneButton); - devotionChannel.send({ embeds: [embed] }); - } catch (error) { - console.log(error); - return; + const guild = await client.guilds.cache.get(config.discord.guildID); + if (!guild) { + console.log("Guild not found."); + return; + } + + const devotionChannel = guild.channels.cache.get( + config.discord.channel.devotion + ); + if (!devotionChannel) { + console.log("Channel not found."); + return; } -} \ No newline at end of file + + // Send the embed message with the button + const message = await devotionChannel.send({ + embeds: [embed], + components: [actionRow], // Add the button to the components field + }); + + // Set up a collector to track button interactions + const filter = (interaction) => interaction.customId === "done_button"; + const collector = message.createMessageComponentCollector({ + filter, + time: 86400000, + }); // Collect for 24 hours + + collector.on("collect", async (interaction) => { + // Acknowledge the interaction + await interaction.deferUpdate(); + + // You can process the user's interaction here, such as calling the API + const fetchURL = `${process.env.APIURL}/api/devotion/add`; + const response = await fetch(fetchURL, { + method: "POST", + headers: { + "x-access-token": process.env.apiKey, + "Content-Type": "application/json", + }, + body: JSON.stringify({ + tenantId: interaction.guild.id, + userId: interaction.user.id, + messageId: message.id, + }), + }); + + if (response.ok) { + // Notify the user that the action was successful + await interaction.followUp({ + content: "Devotion marked as complete!", + ephemeral: true, + }); + } else { + // Handle errors (optional) + await interaction.followUp({ + content: "An error occurred while marking as complete.", + ephemeral: true, + }); + } + }); + } catch (error) { + console.log(error); + } +} diff --git a/listeners/guildCreate.js b/listeners/guildCreate.js index b1bd847..87da0ea 100644 --- a/listeners/guildCreate.js +++ b/listeners/guildCreate.js @@ -1,10 +1,19 @@ import { Listener } from "@sapphire/framework"; +import fetch from "node-fetch"; export class GuildCreateListener extends Listener { async run(guild) { - // Log information about the new guild - this.container.logger.info( - `[CONSOLE] [DISCORD] Joined a new guild: ${guild.name} (${guild.id})` - ); + const fetchURL = `${process.env.APIURL}/api/tenant/create`; + const response = await fetch(fetchURL, { + method: "POST", + headers: { + "x-access-token": process.env.apiKey, + "Content-Type": "application/json", + }, + body: JSON.stringify({ + tenantId: guild.id, + tenantName: guild.name + }), + }); } } diff --git a/listeners/ready.js b/listeners/ready.js index a6d4a6c..b67b873 100644 --- a/listeners/ready.js +++ b/listeners/ready.js @@ -1,8 +1,11 @@ import { Listener } from '@sapphire/framework'; +import { sendDevotion } from '../controller/devotionController.js'; export class ReadyListener extends Listener { async run(client) { const { username, id } = client.user; this.container.logger.info(`[CONSOLE] [DISCORD] Successfully logged in as ${username} (${id})`); + + // sendDevotion(client); } } \ No newline at end of file From 795aad85e8c1c677cba410ec2cef4a99724abb8d Mon Sep 17 00:00:00 2001 From: benrobson Date: Sun, 12 Jan 2025 21:30:14 +1100 Subject: [PATCH 04/15] Add stat tracking for VOTD and checks for duplicates on VOTD and Devotion --- controller/devotionController.js | 29 ++++++-- controller/votdController.js | 116 +++++++++++++++++++++++++------ listeners/ready.js | 3 - 3 files changed, 120 insertions(+), 28 deletions(-) diff --git a/controller/devotionController.js b/controller/devotionController.js index 7da3608..caa6eb1 100644 --- a/controller/devotionController.js +++ b/controller/devotionController.js @@ -83,14 +83,35 @@ export async function sendDevotion(client) { const filter = (interaction) => interaction.customId === "done_button"; const collector = message.createMessageComponentCollector({ filter, - time: 86400000, - }); // Collect for 24 hours + time: 86400000, // Collect for 24 hours + }); collector.on("collect", async (interaction) => { // Acknowledge the interaction await interaction.deferUpdate(); - // You can process the user's interaction here, such as calling the API + // Check if the user already has a Devotion entry + const checkURL = `${process.env.APIURL}/api/devotion/check?tenantId=${interaction.guild.id}&messageId=${message.id}&userId=${interaction.user.id}`; + const checkResponse = await fetch(checkURL, { + method: "GET", + headers: { + "x-access-token": process.env.apiKey, + "Content-Type": "application/json", + }, + }); + + const checkData = await checkResponse.json(); + + // If the entry exists, notify the user and return early + if (checkData.exists) { + await interaction.followUp({ + content: "You have already completed this devotion!", + ephemeral: true, + }); + return; + } + + // Otherwise, add the Devotion entry const fetchURL = `${process.env.APIURL}/api/devotion/add`; const response = await fetch(fetchURL, { method: "POST", @@ -122,4 +143,4 @@ export async function sendDevotion(client) { } catch (error) { console.log(error); } -} +} \ No newline at end of file diff --git a/controller/votdController.js b/controller/votdController.js index e148544..5799dc7 100644 --- a/controller/votdController.js +++ b/controller/votdController.js @@ -1,6 +1,6 @@ import fetch from 'node-fetch'; import config from '../config.json' assert {type: "json"}; -import { MessageEmbed } from 'discord.js'; +import { MessageActionRow, MessageButton, MessageEmbed } from 'discord.js'; /* Get VOTD from API. @@ -40,25 +40,99 @@ export async function compileVotdMessage(votdData) { Send Votd to channel */ export async function sendVotd(client) { - try { - const votdData = await getVotd(); - const embed = await compileVotdMessage(votdData); - - const guild = await client.guilds.cache.get(config.discord.guildID); - if (!guild) { - console.log('Guild not found.'); - return; - } - - const votdChannel = guild.channels.cache.get(config.discord.channel.votd); - if (!votdChannel) { - console.log('Channel not found.'); - return; - } - - votdChannel.send({ embeds: [embed] }); - } catch (error) { - console.log(error); - return; + try { + const votdData = await getVotd(); + const embed = await compileVotdMessage(votdData); + + // Create the "Done" button with green color (SUCCESS style) + const doneButton = new MessageButton() + .setCustomId("done_button") + .setLabel("💭 Reflected") + .setStyle("PRIMARY"); + + // Create an action row and add the button to it + const actionRow = new MessageActionRow().addComponents(doneButton); + + const guild = await client.guilds.cache.get(config.discord.guildID); + if (!guild) { + console.log("Guild not found."); + return; + } + + const votdChannel = guild.channels.cache.get(config.discord.channel.votd); + if (!votdChannel) { + console.log("Channel not found."); + return; } + + // Send the embed message with the button + const message = await votdChannel.send({ + embeds: [embed], + components: [actionRow], // Add the button to the components field + }); + + // Set up a collector to track button interactions + const filter = (interaction) => interaction.customId === "done_button"; + const collector = message.createMessageComponentCollector({ + filter, + time: 86400000, // Collect for 24 hours + }); + + collector.on("collect", async (interaction) => { + // Acknowledge the interaction + await interaction.deferUpdate(); + + // Check if the user already has a VOTD entry + const checkURL = `${process.env.APIURL}/api/votd/check?tenantId=${interaction.guild.id}&messageId=${message.id}&userId=${interaction.user.id}`; + const checkResponse = await fetch(checkURL, { + method: "GET", + headers: { + "x-access-token": process.env.APIKEY, + "Content-Type": "application/json", + }, + }); + + const checkData = await checkResponse.json(); + + // If the entry exists, notify the user and return early + if (checkData.exists) { + await interaction.followUp({ + content: "You have already reflected on this VOTD!", + ephemeral: true, + }); + return; + } + + // Otherwise, add the VOTD entry + const fetchURL = `${process.env.APIURL}/api/votd/add`; + const response = await fetch(fetchURL, { + method: "POST", + headers: { + "x-access-token": process.env.APIKEY, + "Content-Type": "application/json", + }, + body: JSON.stringify({ + tenantId: interaction.guild.id, + userId: interaction.user.id, + messageId: message.id, + }), + }); + + if (response.ok) { + // Notify the user that the action was successful + await interaction.followUp({ + content: "VOTD marked as complete!", + ephemeral: true, + }); + } else { + // Handle errors (optional) + await interaction.followUp({ + content: "An error occurred while marking as complete.", + ephemeral: true, + }); + } + }); + } catch (error) { + console.log(error); + } } \ No newline at end of file diff --git a/listeners/ready.js b/listeners/ready.js index b67b873..a6d4a6c 100644 --- a/listeners/ready.js +++ b/listeners/ready.js @@ -1,11 +1,8 @@ import { Listener } from '@sapphire/framework'; -import { sendDevotion } from '../controller/devotionController.js'; export class ReadyListener extends Listener { async run(client) { const { username, id } = client.user; this.container.logger.info(`[CONSOLE] [DISCORD] Successfully logged in as ${username} (${id})`); - - // sendDevotion(client); } } \ No newline at end of file From ad2e384c1d1bd218a19fb205c348b90730c7f5d0 Mon Sep 17 00:00:00 2001 From: benrobson Date: Sun, 12 Jan 2025 22:05:45 +1100 Subject: [PATCH 05/15] Start work on tenant config command. --- commands/configure.mjs | 149 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 149 insertions(+) create mode 100644 commands/configure.mjs diff --git a/commands/configure.mjs b/commands/configure.mjs new file mode 100644 index 0000000..45f8c87 --- /dev/null +++ b/commands/configure.mjs @@ -0,0 +1,149 @@ +import { Command, RegisterBehavior } from "@sapphire/framework"; +import { Permissions } from "discord.js"; +import fetch from "node-fetch"; + +export class ConfigureCommand extends Command { + constructor(context, options) { + super(context, { + ...options, + description: "Configure various settings for the server.", + chatInputCommand: { + register: true, + behaviorWhenNotIdentical: RegisterBehavior.Overwrite, + }, + }); + } + + registerApplicationCommands(registry) { + registry.registerChatInputCommand((builder) => + builder + .setName("configure") + .setDescription(this.description) + // Subcommand to set VOTD channel + .addSubcommand((subcommand) => + subcommand + .setName("votd-channel") + .setDescription( + "Set the VOTD channel (only text channels can be selected)." + ) + .addChannelOption( + (option) => + option + .setName("channel") + .setDescription("The channel to set as VOTD channel") + .setRequired(true) + .addChannelTypes(0) // Only text channels + ) + ) + // Subcommand to set Devotion channel + .addSubcommand((subcommand) => + subcommand + .setName("devotion-channel") + .setDescription("Set the Devotion channel.") + .addChannelOption( + (option) => + option + .setName("channel") + .setDescription("The channel to set as Devotion channel") + .setRequired(true) + .addChannelTypes(0) // Only text channels + ) + ) + // Subcommand to view current configuration + .addSubcommand((subcommand) => + subcommand + .setName("view") + .setDescription( + "View the current VOTD and Devotion channel configuration." + ) + ) + ); + } + + async chatInputRun(interaction) { + if (!interaction.member.permissions.has(Permissions.FLAGS.ADMINISTRATOR)) { + return interaction.reply({ + content: "You need to be an admin to run this command.", + ephemeral: true, + }); + } + + const subcommand = interaction.options.getSubcommand(); + + try { + if (subcommand === "votd-channel") { + const channel = interaction.options.getChannel("channel"); + // Update VOTD channel via POST request + await this.updateChannelConfig( + interaction.guild.id, + "votd_channel", + channel.id + ); + return interaction.reply({ + content: `VOTD channel has been set to ${channel.name}.`, + ephemeral: true, + }); + } + + if (subcommand === "devotion-channel") { + const channel = interaction.options.getChannel("channel"); + // Update Devotion channel via POST request + await this.updateChannelConfig( + interaction.guild.id, + "devotion_channel", + channel.id + ); + return interaction.reply({ + content: `Devotion channel has been set to ${channel.name}.`, + ephemeral: true, + }); + } + + if (subcommand === "view") { + // Retrieve the current configuration from the database via GET request + const config = await this.getCurrentConfiguration(interaction.guild.id); + return interaction.reply({ + content: `Current configuration:\nVOTD Channel: <#${config.votd_channel}>\nDevotion Channel: <#${config.devotion_channel}>`, + ephemeral: true, + }); + } + } catch (error) { + console.error(error); + return interaction.reply({ + content: "There was an error while configuring the channels.", + ephemeral: true, + }); + } + } + + // Function to update the channel configuration via POST request + async updateChannelConfig(tenantId, channelType, channelId) { + const fetchURL = `${process.env.APIURL}/api/tenant/update`; + + try { + const response = await fetch(fetchURL, { + method: "POST", + headers: { + "x-access-token": process.env.apiKey, + "Content-Type": "application/json", + }, + body: JSON.stringify({ + tenantId: tenantId, + [channelType]: channelId, // Dynamically set the channel type (e.g., "votd_channel" or "devotion_channel") + }), + }); + + if (!response.ok) { + throw new Error(`Failed to update ${channelType}`); + } + + const data = await response.json(); + if (!data.success) { + throw new Error(`API response: ${data.message}`); + } + } catch (error) { + console.error(`Error updating channel configuration: ${error.message}`); + throw new Error("Failed to update channel configuration."); + } + } +} From 5d1b7913c3c2ce041dc889f2ec98815c1b735396 Mon Sep 17 00:00:00 2001 From: benrobson Date: Mon, 13 Jan 2025 04:40:06 +1100 Subject: [PATCH 06/15] Fix tenant update configuration command --- commands/configure.mjs | 45 +++++++++++++++++++++++++++++++----------- 1 file changed, 33 insertions(+), 12 deletions(-) diff --git a/commands/configure.mjs b/commands/configure.mjs index 45f8c87..e574b71 100644 --- a/commands/configure.mjs +++ b/commands/configure.mjs @@ -19,7 +19,6 @@ export class ConfigureCommand extends Command { builder .setName("configure") .setDescription(this.description) - // Subcommand to set VOTD channel .addSubcommand((subcommand) => subcommand .setName("votd-channel") @@ -35,7 +34,6 @@ export class ConfigureCommand extends Command { .addChannelTypes(0) // Only text channels ) ) - // Subcommand to set Devotion channel .addSubcommand((subcommand) => subcommand .setName("devotion-channel") @@ -49,7 +47,6 @@ export class ConfigureCommand extends Command { .addChannelTypes(0) // Only text channels ) ) - // Subcommand to view current configuration .addSubcommand((subcommand) => subcommand .setName("view") @@ -73,7 +70,6 @@ export class ConfigureCommand extends Command { try { if (subcommand === "votd-channel") { const channel = interaction.options.getChannel("channel"); - // Update VOTD channel via POST request await this.updateChannelConfig( interaction.guild.id, "votd_channel", @@ -87,7 +83,6 @@ export class ConfigureCommand extends Command { if (subcommand === "devotion-channel") { const channel = interaction.options.getChannel("channel"); - // Update Devotion channel via POST request await this.updateChannelConfig( interaction.guild.id, "devotion_channel", @@ -100,7 +95,6 @@ export class ConfigureCommand extends Command { } if (subcommand === "view") { - // Retrieve the current configuration from the database via GET request const config = await this.getCurrentConfiguration(interaction.guild.id); return interaction.reply({ content: `Current configuration:\nVOTD Channel: <#${config.votd_channel}>\nDevotion Channel: <#${config.devotion_channel}>`, @@ -116,20 +110,19 @@ export class ConfigureCommand extends Command { } } - // Function to update the channel configuration via POST request async updateChannelConfig(tenantId, channelType, channelId) { - const fetchURL = `${process.env.APIURL}/api/tenant/update`; - + try { + const fetchURL = `${process.env.APIURL}/api/tenant/update`; const response = await fetch(fetchURL, { method: "POST", headers: { - "x-access-token": process.env.apiKey, + "x-access-token": process.env.APIKEY, "Content-Type": "application/json", }, body: JSON.stringify({ tenantId: tenantId, - [channelType]: channelId, // Dynamically set the channel type (e.g., "votd_channel" or "devotion_channel") + [channelType]: channelId, }), }); @@ -138,6 +131,8 @@ export class ConfigureCommand extends Command { } const data = await response.json(); + console.log(data); + if (!data.success) { throw new Error(`API response: ${data.message}`); } @@ -146,4 +141,30 @@ export class ConfigureCommand extends Command { throw new Error("Failed to update channel configuration."); } } -} + + async getCurrentConfiguration(tenantId) { + try { + const fetchURL = `${process.env.APIURL}/api/tenant/get?tenantId=${tenantId}`; + const response = await fetch(fetchURL, { + method: "GET", + headers: { + "x-access-token": process.env.APIKEY, + }, + }); + + if (!response.ok) { + throw new Error("Failed to fetch current configuration."); + } + + const data = await response.json(); + if (!data.success) { + throw new Error(`API response: ${data.message}`); + } + + return data.data; + } catch (error) { + console.error(`Error fetching configuration: ${error.message}`); + throw new Error("Failed to fetch current configuration."); + } + } +} \ No newline at end of file From 6bb823cb296737e7c0465925c3a301b55cf8e18b Mon Sep 17 00:00:00 2001 From: benrobson Date: Mon, 13 Jan 2025 05:04:29 +1100 Subject: [PATCH 07/15] Added tenant controller and fixed configure view --- commands/configure.mjs | 59 +++++++++++++++----------------- controller/devotionController.js | 11 +++--- controller/tenantController.js | 25 ++++++++++++++ 3 files changed, 59 insertions(+), 36 deletions(-) create mode 100644 controller/tenantController.js diff --git a/commands/configure.mjs b/commands/configure.mjs index e574b71..cd57f1b 100644 --- a/commands/configure.mjs +++ b/commands/configure.mjs @@ -1,6 +1,7 @@ import { Command, RegisterBehavior } from "@sapphire/framework"; -import { Permissions } from "discord.js"; +import { MessageEmbed, Permissions } from "discord.js"; import fetch from "node-fetch"; +import { getTenantConfiguration } from "../controller/tenantController.js"; export class ConfigureCommand extends Command { constructor(context, options) { @@ -95,9 +96,31 @@ export class ConfigureCommand extends Command { } if (subcommand === "view") { - const config = await this.getCurrentConfiguration(interaction.guild.id); + const config = await getTenantConfiguration(interaction.guild.id); + + // Create the embed + const embed = new MessageEmbed() + .setTitle("Current Configuration") + .setColor("#0099ff") + .addFields( + { + name: "VOTD Channel", + value: config.votd_channel + ? `<${config.votd_channel}>` + : "Not configured", + inline: false, + }, + { + name: "Devotion Channel", + value: config.devotion_channel + ? `<${config.devotion_channel}>` + : "Not configured", + inline: false, + } + ); + return interaction.reply({ - content: `Current configuration:\nVOTD Channel: <#${config.votd_channel}>\nDevotion Channel: <#${config.devotion_channel}>`, + embeds: [embed], ephemeral: true, }); } @@ -130,9 +153,7 @@ export class ConfigureCommand extends Command { throw new Error(`Failed to update ${channelType}`); } - const data = await response.json(); - console.log(data); - + const data = await response.json(); if (!data.success) { throw new Error(`API response: ${data.message}`); } @@ -141,30 +162,4 @@ export class ConfigureCommand extends Command { throw new Error("Failed to update channel configuration."); } } - - async getCurrentConfiguration(tenantId) { - try { - const fetchURL = `${process.env.APIURL}/api/tenant/get?tenantId=${tenantId}`; - const response = await fetch(fetchURL, { - method: "GET", - headers: { - "x-access-token": process.env.APIKEY, - }, - }); - - if (!response.ok) { - throw new Error("Failed to fetch current configuration."); - } - - const data = await response.json(); - if (!data.success) { - throw new Error(`API response: ${data.message}`); - } - - return data.data; - } catch (error) { - console.error(`Error fetching configuration: ${error.message}`); - throw new Error("Failed to fetch current configuration."); - } - } } \ No newline at end of file diff --git a/controller/devotionController.js b/controller/devotionController.js index caa6eb1..a24fbe5 100644 --- a/controller/devotionController.js +++ b/controller/devotionController.js @@ -1,6 +1,7 @@ import fetch from 'node-fetch'; import config from '../config.json' assert {type: "json"}; import { MessageActionRow, MessageButton, MessageEmbed } from 'discord.js'; +import { getTenantConfiguration } from './tenantController.js'; /* Get Devotion from API. @@ -48,9 +49,8 @@ export async function compileDevotionMessage(devotionData) { export async function sendDevotion(client) { try { const devotionData = await getDevotion(); - const embed = await compileDevotionMessage(devotionData); // Assuming this is generating the embed - - // Create the "Done" button with green color (SUCCESS style) + const embed = await compileDevotionMessage(devotionData); + const doneButton = new MessageButton() .setCustomId("done_button") .setLabel("📖 Complete") @@ -65,8 +65,11 @@ export async function sendDevotion(client) { return; } + const tenantConfig = await getTenantConfiguration(interaction.guild.id); + console.log(tenantConfig); + const devotionChannel = guild.channels.cache.get( - config.discord.channel.devotion + tenantConfig.devotion_channel ); if (!devotionChannel) { console.log("Channel not found."); diff --git a/controller/tenantController.js b/controller/tenantController.js new file mode 100644 index 0000000..7d1e9e7 --- /dev/null +++ b/controller/tenantController.js @@ -0,0 +1,25 @@ +export async function getTenantConfiguration(tenantId) { + try { + const fetchURL = `${process.env.APIURL}/api/tenant/configuration/get?id=${tenantId}`; + const response = await fetch(fetchURL, { + method: "GET", + headers: { + "x-access-token": process.env.APIKEY, + }, + }); + + if (!response.ok) { + throw new Error("Failed to fetch current configuration."); + } + + const data = await response.json(); + if (!data.success) { + throw new Error(`API response: ${data.message}`); + } + + return data.data[0]; + } catch (error) { + console.error(`Error fetching configuration: ${error.message}`); + throw new Error("Failed to fetch current configuration."); + } +} From 13a1e8ba368cd4fb8fe1b030def574d8ad9c5adf Mon Sep 17 00:00:00 2001 From: benrobson Date: Mon, 13 Jan 2025 22:28:43 +1100 Subject: [PATCH 08/15] Move cron to 6am, make devotion and VOTD send at global time. --- commands/configure.mjs | 54 +++++----- commands/devotion.mjs | 21 ++-- controller/devotionController.js | 171 ++++++++++++++++-------------- controller/tenantController.js | 26 +++++ controller/votdController.js | 173 ++++++++++++++++++------------- cron/daily.js | 6 +- 6 files changed, 268 insertions(+), 183 deletions(-) diff --git a/commands/configure.mjs b/commands/configure.mjs index cd57f1b..93dd1a0 100644 --- a/commands/configure.mjs +++ b/commands/configure.mjs @@ -60,10 +60,11 @@ export class ConfigureCommand extends Command { async chatInputRun(interaction) { if (!interaction.member.permissions.has(Permissions.FLAGS.ADMINISTRATOR)) { - return interaction.reply({ - content: "You need to be an admin to run this command.", - ephemeral: true, - }); + const embed = new MessageEmbed() + .setColor("RED") + .setTitle("Permission Denied") + .setDescription("You need to be an admin to run this command."); + return interaction.reply({ embeds: [embed], ephemeral: true }); } const subcommand = interaction.options.getSubcommand(); @@ -76,10 +77,12 @@ export class ConfigureCommand extends Command { "votd_channel", channel.id ); - return interaction.reply({ - content: `VOTD channel has been set to ${channel.name}.`, - ephemeral: true, - }); + + const embed = new MessageEmbed() + .setColor("GREEN") + .setTitle("Configuration Updated") + .setDescription(`VOTD channel has been set to <#${channel.id}>.`); + return interaction.reply({ embeds: [embed], ephemeral: true }); } if (subcommand === "devotion-channel") { @@ -89,16 +92,16 @@ export class ConfigureCommand extends Command { "devotion_channel", channel.id ); - return interaction.reply({ - content: `Devotion channel has been set to ${channel.name}.`, - ephemeral: true, - }); + + const embed = new MessageEmbed() + .setColor("GREEN") + .setTitle("Configuration Updated") + .setDescription(`Devotion channel has been set to <#${channel.id}>.`); + return interaction.reply({ embeds: [embed], ephemeral: true }); } if (subcommand === "view") { const config = await getTenantConfiguration(interaction.guild.id); - - // Create the embed const embed = new MessageEmbed() .setTitle("Current Configuration") .setColor("#0099ff") @@ -106,35 +109,30 @@ export class ConfigureCommand extends Command { { name: "VOTD Channel", value: config.votd_channel - ? `<${config.votd_channel}>` + ? `<#${config.votd_channel}>` : "Not configured", - inline: false, }, { name: "Devotion Channel", value: config.devotion_channel - ? `<${config.devotion_channel}>` + ? `<#${config.devotion_channel}>` : "Not configured", - inline: false, } ); - return interaction.reply({ - embeds: [embed], - ephemeral: true, - }); + return interaction.reply({ embeds: [embed], ephemeral: true }); } } catch (error) { console.error(error); - return interaction.reply({ - content: "There was an error while configuring the channels.", - ephemeral: true, - }); + const embed = new MessageEmbed() + .setColor("RED") + .setTitle("Error") + .setDescription("There was an error while configuring the channels."); + return interaction.reply({ embeds: [embed], ephemeral: true }); } } async updateChannelConfig(tenantId, channelType, channelId) { - try { const fetchURL = `${process.env.APIURL}/api/tenant/update`; const response = await fetch(fetchURL, { @@ -153,7 +151,7 @@ export class ConfigureCommand extends Command { throw new Error(`Failed to update ${channelType}`); } - const data = await response.json(); + const data = await response.json(); if (!data.success) { throw new Error(`API response: ${data.message}`); } diff --git a/commands/devotion.mjs b/commands/devotion.mjs index 1d3f925..ad529cf 100644 --- a/commands/devotion.mjs +++ b/commands/devotion.mjs @@ -3,6 +3,7 @@ import { compileDevotionMessage, getDevotion, } from "../controller/devotionController.js"; +import { MessageEmbed } from "discord.js"; export class DevotionCommand extends Command { constructor(context, options) { @@ -29,15 +30,21 @@ export class DevotionCommand extends Command { const devotionData = await getDevotion(); const embed = await compileDevotionMessage(devotionData); - // Reply to the interaction first + // Reply with the devotion message embed await interaction.reply({ embeds: [embed] }); } catch (error) { console.error(error); - // If an error occurs, edit the reply with an error message - await interaction.editReply({ - content: "An error occurred while processing the devotion.", - ephemeral: true, - }); + + // Create an error embed + const errorEmbed = new MessageEmbed() + .setColor("RED") + .setTitle("Error") + .setDescription( + "An error occurred while processing the devotion. Please try again later." + ); + + // Reply with the error embed + await interaction.reply({ embeds: [errorEmbed], ephemeral: true }); } } -} +} \ No newline at end of file diff --git a/controller/devotionController.js b/controller/devotionController.js index a24fbe5..e5bc03b 100644 --- a/controller/devotionController.js +++ b/controller/devotionController.js @@ -1,7 +1,7 @@ import fetch from 'node-fetch'; import config from '../config.json' assert {type: "json"}; import { MessageActionRow, MessageButton, MessageEmbed } from 'discord.js'; -import { getTenantConfiguration } from './tenantController.js'; +import { getTenantConfiguration, getTenants } from './tenantController.js'; /* Get Devotion from API. @@ -50,100 +50,121 @@ export async function sendDevotion(client) { try { const devotionData = await getDevotion(); const embed = await compileDevotionMessage(devotionData); - + const doneButton = new MessageButton() .setCustomId("done_button") .setLabel("📖 Complete") .setStyle("SUCCESS"); - // Create an action row and add the button to it const actionRow = new MessageActionRow().addComponents(doneButton); - const guild = await client.guilds.cache.get(config.discord.guildID); - if (!guild) { - console.log("Guild not found."); - return; + let tenants = await getTenants(); + if (!Array.isArray(tenants)) { + tenants = [tenants]; } - const tenantConfig = await getTenantConfiguration(interaction.guild.id); - console.log(tenantConfig); + for (const tenant of tenants) { + console.log(tenant.tenantId); - const devotionChannel = guild.channels.cache.get( - tenantConfig.devotion_channel - ); - if (!devotionChannel) { - console.log("Channel not found."); - return; - } + const guild = await client.guilds.cache.get(tenant.tenantId); + if (!guild) { + console.log("Guild not found."); + continue; + } - // Send the embed message with the button - const message = await devotionChannel.send({ - embeds: [embed], - components: [actionRow], // Add the button to the components field - }); + const tenantConfig = await getTenantConfiguration(tenant.tenantId); + console.log(tenantConfig); - // Set up a collector to track button interactions - const filter = (interaction) => interaction.customId === "done_button"; - const collector = message.createMessageComponentCollector({ - filter, - time: 86400000, // Collect for 24 hours - }); + const devotionChannel = guild.channels.cache.get( + tenantConfig.devotion_channel + ); + if (!devotionChannel) { + console.log("Channel not found."); + continue; + } - collector.on("collect", async (interaction) => { - // Acknowledge the interaction - await interaction.deferUpdate(); - - // Check if the user already has a Devotion entry - const checkURL = `${process.env.APIURL}/api/devotion/check?tenantId=${interaction.guild.id}&messageId=${message.id}&userId=${interaction.user.id}`; - const checkResponse = await fetch(checkURL, { - method: "GET", - headers: { - "x-access-token": process.env.apiKey, - "Content-Type": "application/json", - }, + const message = await devotionChannel.send({ + embeds: [embed], + components: [actionRow], }); - const checkData = await checkResponse.json(); - - // If the entry exists, notify the user and return early - if (checkData.exists) { - await interaction.followUp({ - content: "You have already completed this devotion!", - ephemeral: true, - }); - return; - } - - // Otherwise, add the Devotion entry - const fetchURL = `${process.env.APIURL}/api/devotion/add`; - const response = await fetch(fetchURL, { - method: "POST", - headers: { - "x-access-token": process.env.apiKey, - "Content-Type": "application/json", - }, - body: JSON.stringify({ - tenantId: interaction.guild.id, - userId: interaction.user.id, - messageId: message.id, - }), + const filter = (interaction) => interaction.customId === "done_button"; + const collector = message.createMessageComponentCollector({ + filter, + time: 86400000, // Collect for 24 hours }); - if (response.ok) { - // Notify the user that the action was successful - await interaction.followUp({ - content: "Devotion marked as complete!", - ephemeral: true, + collector.on("collect", async (interaction) => { + await interaction.deferUpdate(); + + const checkURL = `${process.env.APIURL}/api/devotion/check?tenantId=${interaction.guild.id}&messageId=${message.id}&userId=${interaction.user.id}`; + const checkResponse = await fetch(checkURL, { + method: "GET", + headers: { + "x-access-token": process.env.apiKey, + "Content-Type": "application/json", + }, }); - } else { - // Handle errors (optional) - await interaction.followUp({ - content: "An error occurred while marking as complete.", - ephemeral: true, + + const checkData = await checkResponse.json(); + + if (checkData.exists) { + const completedEmbed = new MessageEmbed() + .setColor("RED") + .setTitle("Error") + .setDescription("You have already completed this devotion!"); + await interaction.followUp({ + embeds: [completedEmbed], + ephemeral: true, + }); + return; + } + + const fetchURL = `${process.env.APIURL}/api/devotion/add`; + const response = await fetch(fetchURL, { + method: "POST", + headers: { + "x-access-token": process.env.apiKey, + "Content-Type": "application/json", + }, + body: JSON.stringify({ + tenantId: interaction.guild.id, + userId: interaction.user.id, + messageId: message.id, + }), }); - } - }); + + if (response.ok) { + const successEmbed = new MessageEmbed() + .setColor("GREEN") + .setTitle("Devotion Completed") + .setDescription("Devotion marked as complete!"); + await interaction.followUp({ + embeds: [successEmbed], + ephemeral: true, + }); + } else { + const errorEmbed = new MessageEmbed() + .setColor("RED") + .setTitle("Error") + .setDescription("An error occurred while marking as complete."); + await interaction.followUp({ + embeds: [errorEmbed], + ephemeral: true, + }); + } + }); + } } catch (error) { console.log(error); + const errorEmbed = new MessageEmbed() + .setColor("RED") + .setTitle("Error") + .setDescription( + "An error occurred while processing the devotion. Please try again later." + ); + await client.users.fetch(process.env.ADMIN_USER_ID).then((admin) => { + admin.send({ embeds: [errorEmbed] }); + }); } } \ No newline at end of file diff --git a/controller/tenantController.js b/controller/tenantController.js index 7d1e9e7..6c9cf66 100644 --- a/controller/tenantController.js +++ b/controller/tenantController.js @@ -1,3 +1,29 @@ +export async function getTenants() { + try { + const fetchURL = `${process.env.APIURL}/api/tenant/get`; + const response = await fetch(fetchURL, { + method: "GET", + headers: { + "x-access-token": process.env.APIKEY, + }, + }); + + if (!response.ok) { + throw new Error("Failed to fetch tenants."); + } + + const data = await response.json(); + if (!data.success) { + throw new Error(`API response: ${data.message}`); + } + + return data.data[0]; + } catch (error) { + console.error(`Error fetching configuration: ${error.message}`); + throw new Error("Failed to fetch tenants."); + } +} + export async function getTenantConfiguration(tenantId) { try { const fetchURL = `${process.env.APIURL}/api/tenant/configuration/get?id=${tenantId}`; diff --git a/controller/votdController.js b/controller/votdController.js index 5799dc7..5b251b5 100644 --- a/controller/votdController.js +++ b/controller/votdController.js @@ -1,6 +1,7 @@ import fetch from 'node-fetch'; import config from '../config.json' assert {type: "json"}; import { MessageActionRow, MessageButton, MessageEmbed } from 'discord.js'; +import { getTenantConfiguration, getTenants } from './tenantController.js'; /* Get VOTD from API. @@ -44,7 +45,7 @@ export async function sendVotd(client) { const votdData = await getVotd(); const embed = await compileVotdMessage(votdData); - // Create the "Done" button with green color (SUCCESS style) + // Create the "Done" button with primary color (PRIMARY style) const doneButton = new MessageButton() .setCustomId("done_button") .setLabel("💭 Reflected") @@ -53,86 +54,118 @@ export async function sendVotd(client) { // Create an action row and add the button to it const actionRow = new MessageActionRow().addComponents(doneButton); - const guild = await client.guilds.cache.get(config.discord.guildID); - if (!guild) { - console.log("Guild not found."); - return; + let tenants = await getTenants(); + if (!Array.isArray(tenants)) { + tenants = [tenants]; } + + for (const tenant of tenants) { + const guild = await client.guilds.cache.get(tenant.tenantId); + if (!guild) { + console.log("Guild not found."); + continue; + } - const votdChannel = guild.channels.cache.get(config.discord.channel.votd); - if (!votdChannel) { - console.log("Channel not found."); - return; - } + const tenantConfig = await getTenantConfiguration(tenant.tenantId); + console.log(tenantConfig); - // Send the embed message with the button - const message = await votdChannel.send({ - embeds: [embed], - components: [actionRow], // Add the button to the components field - }); + const votdChannel = guild.channels.cache.get( + tenantConfig.votd_channel + ); + if (!votdChannel) { + console.log("Channel not found."); + return; + } - // Set up a collector to track button interactions - const filter = (interaction) => interaction.customId === "done_button"; - const collector = message.createMessageComponentCollector({ - filter, - time: 86400000, // Collect for 24 hours - }); + // Send the embed message with the button + const message = await votdChannel.send({ + embeds: [embed], + components: [actionRow], // Add the button to the components field + }); - collector.on("collect", async (interaction) => { - // Acknowledge the interaction - await interaction.deferUpdate(); - - // Check if the user already has a VOTD entry - const checkURL = `${process.env.APIURL}/api/votd/check?tenantId=${interaction.guild.id}&messageId=${message.id}&userId=${interaction.user.id}`; - const checkResponse = await fetch(checkURL, { - method: "GET", - headers: { - "x-access-token": process.env.APIKEY, - "Content-Type": "application/json", - }, + // Set up a collector to track button interactions + const filter = (interaction) => interaction.customId === "done_button"; + const collector = message.createMessageComponentCollector({ + filter, + time: 86400000, // Collect for 24 hours }); - const checkData = await checkResponse.json(); + collector.on("collect", async (interaction) => { + // Acknowledge the interaction + await interaction.deferUpdate(); + + // Check if the user already has a VOTD entry + const checkURL = `${process.env.APIURL}/api/votd/check?tenantId=${interaction.guild.id}&messageId=${message.id}&userId=${interaction.user.id}`; + const checkResponse = await fetch(checkURL, { + method: "GET", + headers: { + "x-access-token": process.env.APIKEY, + "Content-Type": "application/json", + }, + }); - // If the entry exists, notify the user and return early - if (checkData.exists) { - await interaction.followUp({ - content: "You have already reflected on this VOTD!", - ephemeral: true, + const checkData = await checkResponse.json(); + + // If the entry exists, notify the user and return early + if (checkData.exists) { + const completedEmbed = new MessageEmbed() + .setColor("RED") + .setTitle("Error") + .setDescription("You have already reflected on this VOTD!"); + await interaction.followUp({ + embeds: [completedEmbed], + ephemeral: true, + }); + return; + } + + // Otherwise, add the VOTD entry + const fetchURL = `${process.env.APIURL}/api/votd/add`; + const response = await fetch(fetchURL, { + method: "POST", + headers: { + "x-access-token": process.env.APIKEY, + "Content-Type": "application/json", + }, + body: JSON.stringify({ + tenantId: interaction.guild.id, + userId: interaction.user.id, + messageId: message.id, + }), }); - return; - } - // Otherwise, add the VOTD entry - const fetchURL = `${process.env.APIURL}/api/votd/add`; - const response = await fetch(fetchURL, { - method: "POST", - headers: { - "x-access-token": process.env.APIKEY, - "Content-Type": "application/json", - }, - body: JSON.stringify({ - tenantId: interaction.guild.id, - userId: interaction.user.id, - messageId: message.id, - }), + if (response.ok) { + const successEmbed = new MessageEmbed() + .setColor("GREEN") + .setTitle("VOTD Completed") + .setDescription("VOTD marked as complete!"); + await interaction.followUp({ + embeds: [successEmbed], + ephemeral: true, + }); + } else { + const errorEmbed = new MessageEmbed() + .setColor("RED") + .setTitle("Error") + .setDescription("An error occurred while marking as complete."); + await interaction.followUp({ + embeds: [errorEmbed], + ephemeral: true, + }); + } }); - - if (response.ok) { - // Notify the user that the action was successful - await interaction.followUp({ - content: "VOTD marked as complete!", - ephemeral: true, - }); - } else { - // Handle errors (optional) - await interaction.followUp({ - content: "An error occurred while marking as complete.", - ephemeral: true, - }); - } - }); + } } catch (error) { console.log(error); + + const errorEmbed = new MessageEmbed() + .setColor("RED") + .setTitle("Error") + .setDescription( + "An error occurred while processing the VOTD. Please try again later." + ); + await client.users.fetch(process.env.ADMIN_USER_ID).then((admin) => { + admin.send({ embeds: [errorEmbed] }); + }); } -} \ No newline at end of file +} diff --git a/cron/daily.js b/cron/daily.js index c5a2aab..dd73116 100644 --- a/cron/daily.js +++ b/cron/daily.js @@ -3,10 +3,10 @@ import { sendDevotion } from '../controller/devotionController.js'; import { sendVotd } from '../controller/votdController.js'; // -// DAILY Cron Jobs [Firing at 7:00am] +// DAILY Cron Jobs [Firing at 6:00am] // export default async function dailyCron(client) { - const sendDevotionTask = cron.schedule('0 7 * * *', async function () { + const sendDevotionTask = cron.schedule('0 6 * * *', async function () { sendDevotion(client); }, { scheduled: true, @@ -15,7 +15,7 @@ export default async function dailyCron(client) { sendDevotionTask.start(); - const sendVotdTask = cron.schedule('0 7 * * *', async function () { + const sendVotdTask = cron.schedule('0 6 * * *', async function () { sendVotd(client); }, { scheduled: true, From 068b84b2aaf149afc23711d95d5fac305e77c437 Mon Sep 17 00:00:00 2001 From: benrobson Date: Mon, 13 Jan 2025 22:37:48 +1100 Subject: [PATCH 09/15] Remove config.json and all reference due to API. --- .gitignore | 3 +-- app.js | 1 - config.json.example | 9 --------- controller/devotionController.js | 1 - controller/votdController.js | 1 - 5 files changed, 1 insertion(+), 14 deletions(-) delete mode 100644 config.json.example diff --git a/.gitignore b/.gitignore index 80df32d..1dcef2d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,2 @@ node_modules -.env -config.json \ No newline at end of file +.env \ No newline at end of file diff --git a/app.js b/app.js index 447a63a..291817d 100644 --- a/app.js +++ b/app.js @@ -3,7 +3,6 @@ import packageData from './package.json' assert {type: "json"}; import dotenv from 'dotenv'; import dailyCron from './cron/daily.js'; -import { sendDevotion } from './controller/devotionController.js'; dotenv.config(); // diff --git a/config.json.example b/config.json.example deleted file mode 100644 index 641644d..0000000 --- a/config.json.example +++ /dev/null @@ -1,9 +0,0 @@ -{ - "discord": { - "guildID": "GUILDID", - "channel": { - "devotion": "DEVOTIONCHANNELID", - "votd": "VOTDCHANNELID" - } - } -} \ No newline at end of file diff --git a/controller/devotionController.js b/controller/devotionController.js index e5bc03b..8954fa6 100644 --- a/controller/devotionController.js +++ b/controller/devotionController.js @@ -1,5 +1,4 @@ import fetch from 'node-fetch'; -import config from '../config.json' assert {type: "json"}; import { MessageActionRow, MessageButton, MessageEmbed } from 'discord.js'; import { getTenantConfiguration, getTenants } from './tenantController.js'; diff --git a/controller/votdController.js b/controller/votdController.js index 5b251b5..3beec3d 100644 --- a/controller/votdController.js +++ b/controller/votdController.js @@ -1,5 +1,4 @@ import fetch from 'node-fetch'; -import config from '../config.json' assert {type: "json"}; import { MessageActionRow, MessageButton, MessageEmbed } from 'discord.js'; import { getTenantConfiguration, getTenants } from './tenantController.js'; From 024422d76ec21f40d6fb6fd756cdc7a343abb0d1 Mon Sep 17 00:00:00 2001 From: benrobson Date: Tue, 14 Jan 2025 00:56:10 +1100 Subject: [PATCH 10/15] Added some logging to GuildCreate and updated packages. --- listeners/guildCreate.js | 43 +++++++++++---- package-lock.json | 114 +++++++-------------------------------- package.json | 6 +-- 3 files changed, 54 insertions(+), 109 deletions(-) diff --git a/listeners/guildCreate.js b/listeners/guildCreate.js index 87da0ea..27b2cd3 100644 --- a/listeners/guildCreate.js +++ b/listeners/guildCreate.js @@ -3,17 +3,38 @@ import fetch from "node-fetch"; export class GuildCreateListener extends Listener { async run(guild) { + console.log(`Guild created: ${guild.name} (ID: ${guild.id})`); + const fetchURL = `${process.env.APIURL}/api/tenant/create`; - const response = await fetch(fetchURL, { - method: "POST", - headers: { - "x-access-token": process.env.apiKey, - "Content-Type": "application/json", - }, - body: JSON.stringify({ - tenantId: guild.id, - tenantName: guild.name - }), - }); + console.log(`Making API request to: ${fetchURL}`); + + try { + const response = await fetch(fetchURL, { + method: "POST", + headers: { + "x-access-token": process.env.apiKey, + "Content-Type": "application/json", + }, + body: JSON.stringify({ + tenantId: guild.id, + tenantName: guild.name, + }), + }); + + if (response.ok) { + console.log( + `Successfully created tenant for guild: ${guild.name} (ID: ${guild.id})` + ); + } else { + console.log( + `Failed to create tenant for guild: ${guild.name} (ID: ${guild.id}). Response status: ${response.status}` + ); + } + } catch (error) { + console.error( + `Error occurred while making API request for guild: ${guild.name} (ID: ${guild.id})`, + error + ); + } } } diff --git a/package-lock.json b/package-lock.json index 86a7f1b..a343f52 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10,9 +10,9 @@ "license": "ISC", "dependencies": { "@sapphire/framework": "^3.2.0", - "discord.js": "^13.16.0", - "dotenv": "^16.0.3", - "node-cron": "^3.0.2", + "discord.js": "^13.17.1", + "dotenv": "^16.4.7", + "node-cron": "^3.0.3", "node-fetch": "^3.3.2", "nodemon": "^2.0.22" }, @@ -26,7 +26,6 @@ "resolved": "https://registry.npmjs.org/@discordjs/builders/-/builders-0.16.0.tgz", "integrity": "sha512-9/NCiZrLivgRub2/kBc0Vm5pMBE5AUdYbdXsLu/yg9ANgvnaJ0bZKTY8yYnLbsEc/LYUP79lEIdC73qEYhWq7A==", "deprecated": "no longer supported", - "license": "Apache-2.0", "dependencies": { "@sapphire/shapeshift": "^3.5.1", "discord-api-types": "^0.36.2", @@ -42,7 +41,6 @@ "version": "1.5.3", "resolved": "https://registry.npmjs.org/@discordjs/collection/-/collection-1.5.3.tgz", "integrity": "sha512-SVb428OMd3WO1paV3rm6tSjM4wC+Kecaa1EUGX7vc6/fddvw/6lg90z4QtCqm21zvVe92vMMDt9+DkIvjXImQQ==", - "license": "Apache-2.0", "engines": { "node": ">=16.11.0" } @@ -51,7 +49,6 @@ "version": "1.5.5", "resolved": "https://registry.npmjs.org/@sapphire/async-queue/-/async-queue-1.5.5.tgz", "integrity": "sha512-cvGzxbba6sav2zZkH8GPf2oGk9yYoD5qrNWdu9fRehifgnFZJMV+nuy2nON2roRO4yQQ+v7MK/Pktl/HgfsUXg==", - "license": "MIT", "engines": { "node": ">=v14.0.0", "npm": ">=7.0.0" @@ -61,7 +58,6 @@ "version": "2.12.0", "resolved": "https://registry.npmjs.org/@sapphire/discord-utilities/-/discord-utilities-2.12.0.tgz", "integrity": "sha512-E/Qqb8PwEoX/WLVfcGvTglTgEGGcc/2rGtKBqhMcHcEEtNIY8dhQVYbW/KMNJpR/J81OqUJquVzpkzRe6fQWiw==", - "license": "MIT", "dependencies": { "discord-api-types": "^0.36.3" }, @@ -74,7 +70,6 @@ "version": "5.1.2", "resolved": "https://registry.npmjs.org/@sapphire/discord.js-utilities/-/discord.js-utilities-5.1.2.tgz", "integrity": "sha512-zKXUkVzueT3Zag9D/ubpey0g/vLXLCVVFlmYoZqpkx1HsTLSTKz4hxbD7IQ/8q7rvI5Pm/Ex1jajPHMLXKmlpw==", - "license": "MIT", "dependencies": { "@sapphire/discord-utilities": "^2.12.0", "@sapphire/duration": "^1.0.0", @@ -90,7 +85,6 @@ "version": "1.1.4", "resolved": "https://registry.npmjs.org/@sapphire/duration/-/duration-1.1.4.tgz", "integrity": "sha512-hxtuE8HvmWcRok2A10lJ+ic8qY0oYGTTn44XmESUYJYYSVJWmqlCH1LnNYi6Ul+LRjxNUfFQEL/TJS0GJ+8kew==", - "license": "MIT", "engines": { "node": ">=v14.0.0", "npm": ">=7.0.0" @@ -100,7 +94,6 @@ "version": "3.2.0", "resolved": "https://registry.npmjs.org/@sapphire/framework/-/framework-3.2.0.tgz", "integrity": "sha512-GrxOlyxrydhwXH68zVwhaEys0XLqEJg6o0TCZLtEYhhDY6oRoOl1MwEiomS1cbDYNRpPkdY7ljHcxD44U6cZ9g==", - "license": "MIT", "dependencies": { "@discordjs/builders": "^0.16.0", "@sapphire/discord-utilities": "^2.12.0", @@ -121,7 +114,6 @@ "version": "1.1.10", "resolved": "https://registry.npmjs.org/@sapphire/lexure/-/lexure-1.1.10.tgz", "integrity": "sha512-odE4FD0SkCxkwEOhzAOqEnCJ/oJlPUuyFEw2KJacIuGiwY86WRTPIHLg1rt6XmfSYLxGXiqRf74req43+wRV9g==", - "license": "MIT", "dependencies": { "@sapphire/result": "^2.7.2" }, @@ -134,7 +126,6 @@ "version": "3.10.0", "resolved": "https://registry.npmjs.org/@sapphire/pieces/-/pieces-3.10.0.tgz", "integrity": "sha512-iBaux50dA+VYjtBqmaceWcskdmw7ua51ojEPkyaSJyg2t9ln/Wc9NqYoQheRCWltZeDTERCUBIYYMqDuCs1Okw==", - "license": "MIT", "dependencies": { "@discordjs/collection": "^1.5.3", "@sapphire/utilities": "^3.13.0", @@ -149,7 +140,6 @@ "version": "2.4.11", "resolved": "https://registry.npmjs.org/@sapphire/ratelimits/-/ratelimits-2.4.11.tgz", "integrity": "sha512-O6FNA/P0wxU4Ve9gxL948CoZw7+sSpujyUR2CLyLLCNuNvuFGFxPCJVl5crFVLXMIyBIrc2qk+/H9bsqsyQK1Q==", - "license": "MIT", "engines": { "node": ">=v14.0.0", "npm": ">=7.0.0" @@ -159,7 +149,6 @@ "version": "2.7.2", "resolved": "https://registry.npmjs.org/@sapphire/result/-/result-2.7.2.tgz", "integrity": "sha512-DJbCGmvi8UZAu/hh85auQL8bODFlpcS3cWjRJZ5/cXTLekmGvs/CrRxrIzwbA6+poyYojo5rK4qu8trmjfneog==", - "license": "MIT", "engines": { "node": ">=v14.0.0", "npm": ">=7.0.0" @@ -169,7 +158,6 @@ "version": "3.9.7", "resolved": "https://registry.npmjs.org/@sapphire/shapeshift/-/shapeshift-3.9.7.tgz", "integrity": "sha512-4It2mxPSr4OGn4HSQWGmhFMsNFGfFVhWeRPCRwbH972Ek2pzfGRZtb0pJ4Ze6oIzcyh2jw7nUDa6qGlWofgd9g==", - "license": "MIT", "dependencies": { "fast-deep-equal": "^3.1.3", "lodash": "^4.17.21" @@ -182,7 +170,6 @@ "version": "1.5.4", "resolved": "https://registry.npmjs.org/@sapphire/stopwatch/-/stopwatch-1.5.4.tgz", "integrity": "sha512-IVI48D2yAz411bSttXyTkBH0p2vhrXoqWLn5loDDSAAEUGkM1r5KNCX2027ifQ8svdoMkUfIGjFueR+satLeWw==", - "license": "MIT", "dependencies": { "tslib": "^2.8.1" }, @@ -195,7 +182,6 @@ "version": "3.18.1", "resolved": "https://registry.npmjs.org/@sapphire/utilities/-/utilities-3.18.1.tgz", "integrity": "sha512-zyEyQOQb2/t2mKRmu8T+M4r1Ulb+54BjwDS5pfzf6abGzTAcUg4VDWjHeKX7p3IgiZTcpN4Ij77b9k+K1KV4Lg==", - "license": "MIT", "engines": { "node": ">=v14.0.0" } @@ -204,7 +190,6 @@ "version": "22.10.5", "resolved": "https://registry.npmjs.org/@types/node/-/node-22.10.5.tgz", "integrity": "sha512-F8Q+SeGimwOo86fiovQh8qiXfFEh2/ocYv7tU5pJ3EXMSSxk1Joj5wefpFK2fHTf/N6HKGSxIDBT9f3gCxXPkQ==", - "license": "MIT", "dependencies": { "undici-types": "~6.20.0" } @@ -213,7 +198,6 @@ "version": "2.6.12", "resolved": "https://registry.npmjs.org/@types/node-fetch/-/node-fetch-2.6.12.tgz", "integrity": "sha512-8nneRWKCg3rMtF69nLQJnOYUcbafYeFSjqkw3jCRLsqkWFlHaoQrr5mXmofFGOx3DKn7UfmBMyov8ySvLRVldA==", - "license": "MIT", "dependencies": { "@types/node": "*", "form-data": "^4.0.0" @@ -223,7 +207,6 @@ "version": "8.5.13", "resolved": "https://registry.npmjs.org/@types/ws/-/ws-8.5.13.tgz", "integrity": "sha512-osM/gWBTPKgHV8XkTunnegTRIsvF6owmf5w+JtAfOw472dptdm0dlGv4xCt6GwQRcC2XVOvvRE/0bAoQcL2QkA==", - "license": "MIT", "dependencies": { "@types/node": "*" } @@ -232,7 +215,6 @@ "version": "3.1.3", "resolved": "https://registry.npmjs.org/anymatch/-/anymatch-3.1.3.tgz", "integrity": "sha512-KMReFUr0B4t+D+OBkjR3KYqvocp2XaSzO55UcB6mgQMd3KbcE+mWTyvVV7D/zsdEbNnV6acZUutkiHQXvTr1Rw==", - "license": "ISC", "dependencies": { "normalize-path": "^3.0.0", "picomatch": "^2.0.4" @@ -244,20 +226,17 @@ "node_modules/asynckit": { "version": "0.4.0", "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", - "integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==", - "license": "MIT" + "integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==" }, "node_modules/balanced-match": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", - "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==", - "license": "MIT" + "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==" }, "node_modules/binary-extensions": { "version": "2.3.0", "resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-2.3.0.tgz", "integrity": "sha512-Ceh+7ox5qe7LJuLHoY0feh3pHuUDHAcRUeyL2VYghZwfpkNIy/+8Ocg0a3UuSoYzavmylwuLWQOf3hl0jjMMIw==", - "license": "MIT", "engines": { "node": ">=8" }, @@ -269,7 +248,6 @@ "version": "1.1.11", "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", - "license": "MIT", "dependencies": { "balanced-match": "^1.0.0", "concat-map": "0.0.1" @@ -279,7 +257,6 @@ "version": "3.0.3", "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.3.tgz", "integrity": "sha512-yQbXgO/OSZVD2IsiLlro+7Hf6Q18EJrKSEsdoMzKePKXct3gvD8oLcOQdIzGupr5Fj+EDe8gO/lxc1BzfMpxvA==", - "license": "MIT", "dependencies": { "fill-range": "^7.1.1" }, @@ -291,7 +268,6 @@ "version": "3.6.0", "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.6.0.tgz", "integrity": "sha512-7VT13fmjotKpGipCW9JEQAusEPE+Ei8nl6/g4FBAmIm0GOOLMua9NDDo/DWp0ZAxCr3cPq5ZpBqmPAQgDda2Pw==", - "license": "MIT", "dependencies": { "anymatch": "~3.1.2", "braces": "~3.0.2", @@ -315,7 +291,6 @@ "version": "1.0.8", "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz", "integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==", - "license": "MIT", "dependencies": { "delayed-stream": "~1.0.0" }, @@ -326,14 +301,12 @@ "node_modules/concat-map": { "version": "0.0.1", "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", - "integrity": "sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==", - "license": "MIT" + "integrity": "sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==" }, "node_modules/data-uri-to-buffer": { "version": "4.0.1", "resolved": "https://registry.npmjs.org/data-uri-to-buffer/-/data-uri-to-buffer-4.0.1.tgz", "integrity": "sha512-0R9ikRb668HB7QDxT1vkpuUBtqc53YyAwMwGeUFKRojY/NWKvdZ+9UYtRfGmhqNbRkTSVpMbmyhXipFFv2cb/A==", - "license": "MIT", "engines": { "node": ">= 12" } @@ -342,7 +315,6 @@ "version": "3.2.7", "resolved": "https://registry.npmjs.org/debug/-/debug-3.2.7.tgz", "integrity": "sha512-CFjzYYAi4ThfiQvizrFQevTTXHtnCqWfe7x1AhgEscTz6ZbLbfoLRLPugTQyBth6f8ZERVUSyWHFD/7Wu4t1XQ==", - "license": "MIT", "dependencies": { "ms": "^2.1.1" } @@ -351,7 +323,6 @@ "version": "1.0.0", "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", "integrity": "sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ==", - "license": "MIT", "engines": { "node": ">=0.4.0" } @@ -359,14 +330,12 @@ "node_modules/discord-api-types": { "version": "0.36.3", "resolved": "https://registry.npmjs.org/discord-api-types/-/discord-api-types-0.36.3.tgz", - "integrity": "sha512-bz/NDyG0KBo/tY14vSkrwQ/n3HKPf87a0WFW/1M9+tXYK+vp5Z5EksawfCWo2zkAc6o7CClc0eff1Pjrqznlwg==", - "license": "MIT" + "integrity": "sha512-bz/NDyG0KBo/tY14vSkrwQ/n3HKPf87a0WFW/1M9+tXYK+vp5Z5EksawfCWo2zkAc6o7CClc0eff1Pjrqznlwg==" }, "node_modules/discord.js": { "version": "13.17.1", "resolved": "https://registry.npmjs.org/discord.js/-/discord.js-13.17.1.tgz", "integrity": "sha512-h13kUf+7ZaP5ZWggzooCxFutvJJvugcAO54oTEIdVr3zQWi0Sf/61S1kETtuY9nVAyYebXR/Ey4C+oWbsgEkew==", - "license": "Apache-2.0", "dependencies": { "@discordjs/builders": "^0.16.0", "@discordjs/collection": "^0.7.0", @@ -388,7 +357,6 @@ "resolved": "https://registry.npmjs.org/@discordjs/collection/-/collection-0.7.0.tgz", "integrity": "sha512-R5i8Wb8kIcBAFEPLLf7LVBQKBDYUL+ekb23sOgpkpyGT+V4P7V83wTxcsqmX+PbqHt4cEHn053uMWfRqh/Z/nA==", "deprecated": "no longer supported", - "license": "Apache-2.0", "engines": { "node": ">=16.9.0" } @@ -396,14 +364,12 @@ "node_modules/discord.js/node_modules/discord-api-types": { "version": "0.33.5", "resolved": "https://registry.npmjs.org/discord-api-types/-/discord-api-types-0.33.5.tgz", - "integrity": "sha512-dvO5M52v7m7Dy96+XUnzXNsQ/0npsYpU6dL205kAtEDueswoz3aU3bh1UMoK4cQmcGtB1YRyLKqp+DXi05lzFg==", - "license": "MIT" + "integrity": "sha512-dvO5M52v7m7Dy96+XUnzXNsQ/0npsYpU6dL205kAtEDueswoz3aU3bh1UMoK4cQmcGtB1YRyLKqp+DXi05lzFg==" }, "node_modules/discord.js/node_modules/node-fetch": { "version": "2.7.0", "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.7.0.tgz", "integrity": "sha512-c4FRfUm/dbcWZ7U+1Wq0AwCyFL+3nt2bEw05wfxSz+DWpWsitgmSgYmy2dQdWyKC1694ELPqMs/YzUSNozLt8A==", - "license": "MIT", "dependencies": { "whatwg-url": "^5.0.0" }, @@ -423,7 +389,6 @@ "version": "16.4.7", "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.4.7.tgz", "integrity": "sha512-47qPchRCykZC03FhkYAhrvwU4xDBFIj1QPqaarj6mdM/hgUzfPHcpkHJOn3mJAufFeeAxAzeGsr5X0M4k6fLZQ==", - "license": "BSD-2-Clause", "engines": { "node": ">=12" }, @@ -434,8 +399,7 @@ "node_modules/fast-deep-equal": { "version": "3.1.3", "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz", - "integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==", - "license": "MIT" + "integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==" }, "node_modules/fetch-blob": { "version": "3.2.0", @@ -451,7 +415,6 @@ "url": "https://paypal.me/jimmywarting" } ], - "license": "MIT", "dependencies": { "node-domexception": "^1.0.0", "web-streams-polyfill": "^3.0.3" @@ -464,7 +427,6 @@ "version": "7.1.1", "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.1.1.tgz", "integrity": "sha512-YsGpe3WHLK8ZYi4tWDg2Jy3ebRz2rXowDxnld4bkQB00cc/1Zw9AWnC0i9ztDJitivtQvaI9KaLyKrc+hBW0yg==", - "license": "MIT", "dependencies": { "to-regex-range": "^5.0.1" }, @@ -476,7 +438,6 @@ "version": "4.0.1", "resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.1.tgz", "integrity": "sha512-tzN8e4TX8+kkxGPK8D5u0FNmjPUjw3lwC9lSLxxoB/+GtsJG91CO8bSWy73APlgAZzZbXEYZJuxjkHH2w+Ezhw==", - "license": "MIT", "dependencies": { "asynckit": "^0.4.0", "combined-stream": "^1.0.8", @@ -490,7 +451,6 @@ "version": "4.0.10", "resolved": "https://registry.npmjs.org/formdata-polyfill/-/formdata-polyfill-4.0.10.tgz", "integrity": "sha512-buewHzMvYL29jdeQTVILecSaZKnt/RJWjoZCF5OW60Z67/GmSLBkOFM7qh1PI3zFNtJbaZL5eQu1vLfazOwj4g==", - "license": "MIT", "dependencies": { "fetch-blob": "^3.1.2" }, @@ -503,7 +463,6 @@ "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz", "integrity": "sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==", "hasInstallScript": true, - "license": "MIT", "optional": true, "os": [ "darwin" @@ -516,7 +475,6 @@ "version": "5.1.2", "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.2.tgz", "integrity": "sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==", - "license": "ISC", "dependencies": { "is-glob": "^4.0.1" }, @@ -528,7 +486,6 @@ "version": "3.0.0", "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", "integrity": "sha512-sKJf1+ceQBr4SMkvQnBDNDtf4TXpVhVGateu0t918bl30FnbE2m4vNLX+VWe/dpjlb+HugGYzW7uQXH98HPEYw==", - "license": "MIT", "engines": { "node": ">=4" } @@ -536,14 +493,12 @@ "node_modules/ignore-by-default": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/ignore-by-default/-/ignore-by-default-1.0.1.tgz", - "integrity": "sha512-Ius2VYcGNk7T90CppJqcIkS5ooHUZyIQK+ClZfMfMNFEF9VSE73Fq+906u/CWu92x4gzZMWOwfFYckPObzdEbA==", - "license": "ISC" + "integrity": "sha512-Ius2VYcGNk7T90CppJqcIkS5ooHUZyIQK+ClZfMfMNFEF9VSE73Fq+906u/CWu92x4gzZMWOwfFYckPObzdEbA==" }, "node_modules/is-binary-path": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/is-binary-path/-/is-binary-path-2.1.0.tgz", "integrity": "sha512-ZMERYes6pDydyuGidse7OsHxtbI7WVeUEozgR/g7rd0xUimYNlvZRE/K2MgZTjWy725IfelLeVcEM97mmtRGXw==", - "license": "MIT", "dependencies": { "binary-extensions": "^2.0.0" }, @@ -555,7 +510,6 @@ "version": "2.1.1", "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz", "integrity": "sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ==", - "license": "MIT", "engines": { "node": ">=0.10.0" } @@ -564,7 +518,6 @@ "version": "4.0.3", "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.3.tgz", "integrity": "sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg==", - "license": "MIT", "dependencies": { "is-extglob": "^2.1.1" }, @@ -576,7 +529,6 @@ "version": "7.0.0", "resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz", "integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==", - "license": "MIT", "engines": { "node": ">=0.12.0" } @@ -584,14 +536,12 @@ "node_modules/lodash": { "version": "4.17.21", "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz", - "integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==", - "license": "MIT" + "integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==" }, "node_modules/mime-db": { "version": "1.52.0", "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz", "integrity": "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==", - "license": "MIT", "engines": { "node": ">= 0.6" } @@ -600,7 +550,6 @@ "version": "2.1.35", "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.35.tgz", "integrity": "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==", - "license": "MIT", "dependencies": { "mime-db": "1.52.0" }, @@ -612,7 +561,6 @@ "version": "3.1.2", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", - "license": "ISC", "dependencies": { "brace-expansion": "^1.1.7" }, @@ -623,14 +571,12 @@ "node_modules/ms": { "version": "2.1.3", "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", - "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==", - "license": "MIT" + "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==" }, "node_modules/node-cron": { "version": "3.0.3", "resolved": "https://registry.npmjs.org/node-cron/-/node-cron-3.0.3.tgz", "integrity": "sha512-dOal67//nohNgYWb+nWmg5dkFdIwDm8EpeGYMekPMrngV3637lqnX0lbUcCtgibHTz6SEz7DAIjKvKDFYCnO1A==", - "license": "ISC", "dependencies": { "uuid": "8.3.2" }, @@ -652,7 +598,6 @@ "url": "https://paypal.me/jimmywarting" } ], - "license": "MIT", "engines": { "node": ">=10.5.0" } @@ -678,7 +623,6 @@ "version": "2.0.22", "resolved": "https://registry.npmjs.org/nodemon/-/nodemon-2.0.22.tgz", "integrity": "sha512-B8YqaKMmyuCO7BowF1Z1/mkPqLk6cs/l63Ojtd6otKjMx47Dq1utxfRxcavH1I7VSaL8n5BUaoutadnsX3AAVQ==", - "license": "MIT", "dependencies": { "chokidar": "^3.5.2", "debug": "^3.2.7", @@ -706,7 +650,6 @@ "version": "3.0.0", "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-3.0.0.tgz", "integrity": "sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==", - "license": "MIT", "engines": { "node": ">=0.10.0" } @@ -715,7 +658,6 @@ "version": "2.3.1", "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz", "integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==", - "license": "MIT", "engines": { "node": ">=8.6" }, @@ -726,14 +668,12 @@ "node_modules/pstree.remy": { "version": "1.1.8", "resolved": "https://registry.npmjs.org/pstree.remy/-/pstree.remy-1.1.8.tgz", - "integrity": "sha512-77DZwxQmxKnu3aR542U+X8FypNzbfJ+C5XQDk3uWjWxn6151aIMGthWYRXTqT1E5oJvg+ljaa2OJi+VfvCOQ8w==", - "license": "MIT" + "integrity": "sha512-77DZwxQmxKnu3aR542U+X8FypNzbfJ+C5XQDk3uWjWxn6151aIMGthWYRXTqT1E5oJvg+ljaa2OJi+VfvCOQ8w==" }, "node_modules/readdirp": { "version": "3.6.0", "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-3.6.0.tgz", "integrity": "sha512-hOS089on8RduqdbhvQ5Z37A0ESjsqz6qnRcffsMU3495FuTdqSm+7bhJ29JvIOsBDEEnan5DPu9t3To9VRlMzA==", - "license": "MIT", "dependencies": { "picomatch": "^2.2.1" }, @@ -745,7 +685,6 @@ "version": "5.7.2", "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.2.tgz", "integrity": "sha512-cBznnQ9KjJqU67B52RMC65CMarK2600WFnbkcaiwWq3xy/5haFJlshgnpjovMVJ+Hff49d8GEn0b87C5pDQ10g==", - "license": "ISC", "bin": { "semver": "bin/semver" } @@ -754,7 +693,6 @@ "version": "1.1.0", "resolved": "https://registry.npmjs.org/simple-update-notifier/-/simple-update-notifier-1.1.0.tgz", "integrity": "sha512-VpsrsJSUcJEseSbMHkrsrAVSdvVS5I96Qo1QAQ4FxQ9wXFcB+pjj7FB7/us9+GcgfW4ziHtYMc1J0PLczb55mg==", - "license": "MIT", "dependencies": { "semver": "~7.0.0" }, @@ -766,7 +704,6 @@ "version": "7.0.0", "resolved": "https://registry.npmjs.org/semver/-/semver-7.0.0.tgz", "integrity": "sha512-+GB6zVA9LWh6zovYQLALHwv5rb2PHGlJi3lfiqIHxR0uuwCgefcOJc59v9fv1w8GbStwxuuqqAjI9NMAOOgq1A==", - "license": "ISC", "bin": { "semver": "bin/semver.js" } @@ -775,7 +712,6 @@ "version": "5.5.0", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==", - "license": "MIT", "dependencies": { "has-flag": "^3.0.0" }, @@ -787,7 +723,6 @@ "version": "5.0.1", "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz", "integrity": "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==", - "license": "MIT", "dependencies": { "is-number": "^7.0.0" }, @@ -799,7 +734,6 @@ "version": "3.1.1", "resolved": "https://registry.npmjs.org/touch/-/touch-3.1.1.tgz", "integrity": "sha512-r0eojU4bI8MnHr8c5bNo7lJDdI2qXlWWJk6a9EAFG7vbhTjElYhBVS3/miuE0uOuoLdb8Mc/rVfsmm6eo5o9GA==", - "license": "ISC", "bin": { "nodetouch": "bin/nodetouch.js" } @@ -807,38 +741,32 @@ "node_modules/tr46": { "version": "0.0.3", "resolved": "https://registry.npmjs.org/tr46/-/tr46-0.0.3.tgz", - "integrity": "sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw==", - "license": "MIT" + "integrity": "sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw==" }, "node_modules/ts-mixer": { "version": "6.0.4", "resolved": "https://registry.npmjs.org/ts-mixer/-/ts-mixer-6.0.4.tgz", - "integrity": "sha512-ufKpbmrugz5Aou4wcr5Wc1UUFWOLhq+Fm6qa6P0w0K5Qw2yhaUoiWszhCVuNQyNwrlGiscHOmqYoAox1PtvgjA==", - "license": "MIT" + "integrity": "sha512-ufKpbmrugz5Aou4wcr5Wc1UUFWOLhq+Fm6qa6P0w0K5Qw2yhaUoiWszhCVuNQyNwrlGiscHOmqYoAox1PtvgjA==" }, "node_modules/tslib": { "version": "2.8.1", "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.8.1.tgz", - "integrity": "sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w==", - "license": "0BSD" + "integrity": "sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w==" }, "node_modules/undefsafe": { "version": "2.0.5", "resolved": "https://registry.npmjs.org/undefsafe/-/undefsafe-2.0.5.tgz", - "integrity": "sha512-WxONCrssBM8TSPRqN5EmsjVrsv4A8X12J4ArBiiayv3DyyG3ZlIg6yysuuSYdZsVz3TKcTg2fd//Ujd4CHV1iA==", - "license": "MIT" + "integrity": "sha512-WxONCrssBM8TSPRqN5EmsjVrsv4A8X12J4ArBiiayv3DyyG3ZlIg6yysuuSYdZsVz3TKcTg2fd//Ujd4CHV1iA==" }, "node_modules/undici-types": { "version": "6.20.0", "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-6.20.0.tgz", - "integrity": "sha512-Ny6QZ2Nju20vw1SRHe3d9jVu6gJ+4e3+MMpqu7pqE5HT6WsTSlce++GQmK5UXS8mzV8DSYHrQH+Xrf2jVcuKNg==", - "license": "MIT" + "integrity": "sha512-Ny6QZ2Nju20vw1SRHe3d9jVu6gJ+4e3+MMpqu7pqE5HT6WsTSlce++GQmK5UXS8mzV8DSYHrQH+Xrf2jVcuKNg==" }, "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==", - "license": "MIT", "bin": { "uuid": "dist/bin/uuid" } @@ -847,7 +775,6 @@ "version": "3.3.3", "resolved": "https://registry.npmjs.org/web-streams-polyfill/-/web-streams-polyfill-3.3.3.tgz", "integrity": "sha512-d2JWLCivmZYTSIoge9MsgFCZrt571BikcWGYkjC1khllbTeDlGqZ2D8vD8E/lJa8WGWbb7Plm8/XJYV7IJHZZw==", - "license": "MIT", "engines": { "node": ">= 8" } @@ -855,14 +782,12 @@ "node_modules/webidl-conversions": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-3.0.1.tgz", - "integrity": "sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ==", - "license": "BSD-2-Clause" + "integrity": "sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ==" }, "node_modules/whatwg-url": { "version": "5.0.0", "resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-5.0.0.tgz", "integrity": "sha512-saE57nupxk6v3HY35+jzBwYa0rKSy0XR8JSxZPwgLr7ys0IBzhGviA1/TUGJLmSVqs8pb9AnvICXEuOHLprYTw==", - "license": "MIT", "dependencies": { "tr46": "~0.0.3", "webidl-conversions": "^3.0.0" @@ -872,7 +797,6 @@ "version": "8.18.0", "resolved": "https://registry.npmjs.org/ws/-/ws-8.18.0.tgz", "integrity": "sha512-8VbfWfHLbbwu3+N6OKsOMpBdT4kXPDDB9cJk2bJ6mh9ucxdlnNvH1e+roYkKmN9Nxw2yjz7VzeO9oOz2zJ04Pw==", - "license": "MIT", "engines": { "node": ">=10.0.0" }, diff --git a/package.json b/package.json index 2319543..1408ef5 100644 --- a/package.json +++ b/package.json @@ -19,9 +19,9 @@ "license": "ISC", "dependencies": { "@sapphire/framework": "^3.2.0", - "discord.js": "^13.16.0", - "dotenv": "^16.0.3", - "node-cron": "^3.0.2", + "discord.js": "^13.17.1", + "dotenv": "^16.4.7", + "node-cron": "^3.0.3", "node-fetch": "^3.3.2", "nodemon": "^2.0.22" } From 9d467c5a6eb4933fc26949e052d06e23f8d42581 Mon Sep 17 00:00:00 2001 From: benrobson Date: Tue, 14 Jan 2025 22:20:05 +1100 Subject: [PATCH 11/15] Log response for troubleshooting --- listeners/guildCreate.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/listeners/guildCreate.js b/listeners/guildCreate.js index 27b2cd3..d9ba117 100644 --- a/listeners/guildCreate.js +++ b/listeners/guildCreate.js @@ -21,13 +21,17 @@ export class GuildCreateListener extends Listener { }), }); + const responseData = await response.json(); + if (response.ok) { console.log( - `Successfully created tenant for guild: ${guild.name} (ID: ${guild.id})` + `Successfully created tenant for guild: ${guild.name} (ID: ${guild.id}). Response: `, + responseData ); } else { console.log( - `Failed to create tenant for guild: ${guild.name} (ID: ${guild.id}). Response status: ${response.status}` + `Failed to create tenant for guild: ${guild.name} (ID: ${guild.id}). Response status: ${response.status}, Response: `, + responseData ); } } catch (error) { @@ -37,4 +41,4 @@ export class GuildCreateListener extends Listener { ); } } -} +} \ No newline at end of file From 048dfcb625ce4f8263d2e19ce98790d8199aad47 Mon Sep 17 00:00:00 2001 From: benrobson Date: Tue, 14 Jan 2025 22:37:09 +1100 Subject: [PATCH 12/15] Fix apiKey to APIKEY --- listeners/guildCreate.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/listeners/guildCreate.js b/listeners/guildCreate.js index d9ba117..a7cf267 100644 --- a/listeners/guildCreate.js +++ b/listeners/guildCreate.js @@ -12,7 +12,7 @@ export class GuildCreateListener extends Listener { const response = await fetch(fetchURL, { method: "POST", headers: { - "x-access-token": process.env.apiKey, + "x-access-token": process.env.APIKEY, "Content-Type": "application/json", }, body: JSON.stringify({ @@ -23,13 +23,13 @@ export class GuildCreateListener extends Listener { const responseData = await response.json(); - if (response.ok) { + if (response.ok && responseData.success) { console.log( `Successfully created tenant for guild: ${guild.name} (ID: ${guild.id}). Response: `, responseData ); } else { - console.log( + console.error( `Failed to create tenant for guild: ${guild.name} (ID: ${guild.id}). Response status: ${response.status}, Response: `, responseData ); @@ -41,4 +41,4 @@ export class GuildCreateListener extends Listener { ); } } -} \ No newline at end of file +} From 448d18ce17f8478d9d1e230eac07d0190347772b Mon Sep 17 00:00:00 2001 From: benrobson Date: Tue, 14 Jan 2025 23:10:35 +1100 Subject: [PATCH 13/15] Fix APIKEY error on devotion post --- controller/devotionController.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/controller/devotionController.js b/controller/devotionController.js index 8954fa6..d98c89d 100644 --- a/controller/devotionController.js +++ b/controller/devotionController.js @@ -100,7 +100,7 @@ export async function sendDevotion(client) { const checkResponse = await fetch(checkURL, { method: "GET", headers: { - "x-access-token": process.env.apiKey, + "x-access-token": process.env.APIKEY, "Content-Type": "application/json", }, }); @@ -123,7 +123,7 @@ export async function sendDevotion(client) { const response = await fetch(fetchURL, { method: "POST", headers: { - "x-access-token": process.env.apiKey, + "x-access-token": process.env.APIKEY, "Content-Type": "application/json", }, body: JSON.stringify({ From ec40cd91c791380b197c955d099a6d483263154a Mon Sep 17 00:00:00 2001 From: benrobson Date: Thu, 16 Jan 2025 22:23:29 +1100 Subject: [PATCH 14/15] Added message create and delete events, removed faulty admin catch error --- app.js | 25 ++++++++++++++----------- controller/devotionController.js | 9 --------- controller/votdController.js | 10 ---------- listeners/messageDelete.js | 16 ++++++++++++++++ listeners/messageUpdate.js | 17 +++++++++++++++++ 5 files changed, 47 insertions(+), 30 deletions(-) create mode 100644 listeners/messageDelete.js create mode 100644 listeners/messageUpdate.js diff --git a/app.js b/app.js index 291817d..3dcb566 100644 --- a/app.js +++ b/app.js @@ -9,18 +9,21 @@ dotenv.config(); // Discord // const client = new SapphireClient({ - intents: [ - 'GUILDS', - 'GUILD_MESSAGES', - 'GUILD_MEMBERS', + intents: [ + "GUILDS", + "GUILD_MESSAGES", + "GUILD_MEMBERS", + "GUILD_MESSAGE_REACTIONS", + ], + presence: { + status: "online", + activities: [ + { + name: "https://modularsoft.org/docs/products/devoteMe/", + type: "PLAYING", + }, ], - presence: { - status: "online", - activities: [{ - name: 'https://modularsoft.org/docs/products/devoteMe/', - type: 'PLAYING' - }] - } + }, }); // diff --git a/controller/devotionController.js b/controller/devotionController.js index d98c89d..29562f7 100644 --- a/controller/devotionController.js +++ b/controller/devotionController.js @@ -156,14 +156,5 @@ export async function sendDevotion(client) { } } catch (error) { console.log(error); - const errorEmbed = new MessageEmbed() - .setColor("RED") - .setTitle("Error") - .setDescription( - "An error occurred while processing the devotion. Please try again later." - ); - await client.users.fetch(process.env.ADMIN_USER_ID).then((admin) => { - admin.send({ embeds: [errorEmbed] }); - }); } } \ No newline at end of file diff --git a/controller/votdController.js b/controller/votdController.js index 3beec3d..7bee837 100644 --- a/controller/votdController.js +++ b/controller/votdController.js @@ -156,15 +156,5 @@ export async function sendVotd(client) { } } catch (error) { console.log(error); - - const errorEmbed = new MessageEmbed() - .setColor("RED") - .setTitle("Error") - .setDescription( - "An error occurred while processing the VOTD. Please try again later." - ); - await client.users.fetch(process.env.ADMIN_USER_ID).then((admin) => { - admin.send({ embeds: [errorEmbed] }); - }); } } diff --git a/listeners/messageDelete.js b/listeners/messageDelete.js new file mode 100644 index 0000000..6b65658 --- /dev/null +++ b/listeners/messageDelete.js @@ -0,0 +1,16 @@ +import { Listener } from "@sapphire/framework"; + +export class MessageDeleteListener extends Listener { + constructor(context) { + super(context, { + event: "messageDelete", + }); + } + + async run(message) { + console.log( + `Message deleted in guild: ${message.guild.name} (ID: ${message.guild.id}), channel: ${message.channel.name} (ID: ${message.channel.id})` + ); + console.log(`Deleted Message ID: ${message.id}`); + } +} \ No newline at end of file diff --git a/listeners/messageUpdate.js b/listeners/messageUpdate.js new file mode 100644 index 0000000..5ff2834 --- /dev/null +++ b/listeners/messageUpdate.js @@ -0,0 +1,17 @@ +import { Listener } from "@sapphire/framework"; + +export class MessageUpdateListener extends Listener { + constructor(context) { + super(context, { + event: "messageUpdate", + }); + } + + async run(oldMessage, newMessage) { + console.log( + `Message updated in guild: ${newMessage.guild.name} (ID: ${newMessage.guild.id}), channel: ${newMessage.channel.name} (ID: ${newMessage.channel.id})` + ); + console.log(`Old Content: ${oldMessage.content}`); + console.log(`New Content: ${newMessage.content}`); + } +} \ No newline at end of file From edbcbdb307d66aeb9f5d94f46b0155b1371c92e3 Mon Sep 17 00:00:00 2001 From: benrobson Date: Fri, 17 Jan 2025 23:22:37 +1100 Subject: [PATCH 15/15] Have getTenants retrieve all guilds. --- controller/devotionController.js | 8 +++----- controller/tenantController.js | 6 +++--- listeners/ready.js | 1 + 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/controller/devotionController.js b/controller/devotionController.js index 29562f7..ab9e2b9 100644 --- a/controller/devotionController.js +++ b/controller/devotionController.js @@ -57,14 +57,12 @@ export async function sendDevotion(client) { const actionRow = new MessageActionRow().addComponents(doneButton); - let tenants = await getTenants(); + let tenants = await getTenants(); if (!Array.isArray(tenants)) { tenants = [tenants]; } for (const tenant of tenants) { - console.log(tenant.tenantId); - const guild = await client.guilds.cache.get(tenant.tenantId); if (!guild) { console.log("Guild not found."); @@ -72,8 +70,6 @@ export async function sendDevotion(client) { } const tenantConfig = await getTenantConfiguration(tenant.tenantId); - console.log(tenantConfig); - const devotionChannel = guild.channels.cache.get( tenantConfig.devotion_channel ); @@ -87,6 +83,8 @@ export async function sendDevotion(client) { components: [actionRow], }); + console.log(`Devotion Message sent to: ${tenant.tenantName}`); + const filter = (interaction) => interaction.customId === "done_button"; const collector = message.createMessageComponentCollector({ filter, diff --git a/controller/tenantController.js b/controller/tenantController.js index 6c9cf66..9d83a31 100644 --- a/controller/tenantController.js +++ b/controller/tenantController.js @@ -6,18 +6,18 @@ export async function getTenants() { headers: { "x-access-token": process.env.APIKEY, }, - }); + }); if (!response.ok) { throw new Error("Failed to fetch tenants."); } - const data = await response.json(); + const data = await response.json(); if (!data.success) { throw new Error(`API response: ${data.message}`); } - return data.data[0]; + return data.data; } catch (error) { console.error(`Error fetching configuration: ${error.message}`); throw new Error("Failed to fetch tenants."); diff --git a/listeners/ready.js b/listeners/ready.js index a6d4a6c..5a5d181 100644 --- a/listeners/ready.js +++ b/listeners/ready.js @@ -1,4 +1,5 @@ import { Listener } from '@sapphire/framework'; +import { sendDevotion } from '../controller/devotionController.js'; export class ReadyListener extends Listener { async run(client) {