Update bot

This commit is contained in:
MajMongoose 2024-08-29 11:57:38 -04:00
parent 3e0352d35b
commit 94071e4c35
4 changed files with 136 additions and 115 deletions

2
.gitignore vendored
View File

@ -2,3 +2,5 @@ node_modules
config.json config.json
roles.csv roles.csv
*.bat *.bat
package.json
package-lock.json

219
package-lock.json generated
View File

@ -7,26 +7,29 @@
"": { "": {
"name": "discordroles", "name": "discordroles",
"version": "1.0.0", "version": "1.0.0",
"license": "AGPL", "license": "AGPL-3.0-only",
"dependencies": { "dependencies": {
"discord.js": "^14.14.1" "discord.js": "^14.15.3"
} }
}, },
"node_modules/@discordjs/builders": { "node_modules/@discordjs/builders": {
"version": "1.7.0", "version": "1.8.2",
"resolved": "https://registry.npmjs.org/@discordjs/builders/-/builders-1.7.0.tgz", "resolved": "https://registry.npmjs.org/@discordjs/builders/-/builders-1.8.2.tgz",
"integrity": "sha512-GDtbKMkg433cOZur8Dv6c25EHxduNIBsxeHrsRoIM8+AwmEZ8r0tEpckx/sHwTLwQPOF3e2JWloZh9ofCaMfAw==", "integrity": "sha512-6wvG3QaCjtMu0xnle4SoOIeFB4y6fKMN6WZfy3BMKJdQQtPLik8KGzDwBVL/+wTtcE/ZlFjgEk74GublyEVZ7g==",
"dependencies": { "dependencies": {
"@discordjs/formatters": "^0.3.3", "@discordjs/formatters": "^0.4.0",
"@discordjs/util": "^1.0.2", "@discordjs/util": "^1.1.0",
"@sapphire/shapeshift": "^3.9.3", "@sapphire/shapeshift": "^3.9.7",
"discord-api-types": "0.37.61", "discord-api-types": "0.37.83",
"fast-deep-equal": "^3.1.3", "fast-deep-equal": "^3.1.3",
"ts-mixer": "^6.0.3", "ts-mixer": "^6.0.4",
"tslib": "^2.6.2" "tslib": "^2.6.2"
}, },
"engines": { "engines": {
"node": ">=16.11.0" "node": ">=16.11.0"
},
"funding": {
"url": "https://github.com/discordjs/discord.js?sponsor"
} }
}, },
"node_modules/@discordjs/collection": { "node_modules/@discordjs/collection": {
@ -38,168 +41,179 @@
} }
}, },
"node_modules/@discordjs/formatters": { "node_modules/@discordjs/formatters": {
"version": "0.3.3", "version": "0.4.0",
"resolved": "https://registry.npmjs.org/@discordjs/formatters/-/formatters-0.3.3.tgz", "resolved": "https://registry.npmjs.org/@discordjs/formatters/-/formatters-0.4.0.tgz",
"integrity": "sha512-wTcI1Q5cps1eSGhl6+6AzzZkBBlVrBdc9IUhJbijRgVjCNIIIZPgqnUj3ntFODsHrdbGU8BEG9XmDQmgEEYn3w==", "integrity": "sha512-fJ06TLC1NiruF35470q3Nr1bi95BdvKFAF+T5bNfZJ4bNdqZ3VZ+Ttg6SThqTxm6qumSG3choxLBHMC69WXNXQ==",
"dependencies": { "dependencies": {
"discord-api-types": "0.37.61" "discord-api-types": "0.37.83"
}, },
"engines": { "engines": {
"node": ">=16.11.0" "node": ">=16.11.0"
},
"funding": {
"url": "https://github.com/discordjs/discord.js?sponsor"
} }
}, },
"node_modules/@discordjs/rest": { "node_modules/@discordjs/rest": {
"version": "2.2.0", "version": "2.3.0",
"resolved": "https://registry.npmjs.org/@discordjs/rest/-/rest-2.2.0.tgz", "resolved": "https://registry.npmjs.org/@discordjs/rest/-/rest-2.3.0.tgz",
"integrity": "sha512-nXm9wT8oqrYFRMEqTXQx9DUTeEtXUDMmnUKIhZn6O2EeDY9VCdwj23XCPq7fkqMPKdF7ldAfeVKyxxFdbZl59A==", "integrity": "sha512-C1kAJK8aSYRv3ZwMG8cvrrW4GN0g5eMdP8AuN8ODH5DyOCbHgJspze1my3xHOAgwLJdKUbWNVyAeJ9cEdduqIg==",
"dependencies": { "dependencies": {
"@discordjs/collection": "^2.0.0", "@discordjs/collection": "^2.1.0",
"@discordjs/util": "^1.0.2", "@discordjs/util": "^1.1.0",
"@sapphire/async-queue": "^1.5.0", "@sapphire/async-queue": "^1.5.2",
"@sapphire/snowflake": "^3.5.1", "@sapphire/snowflake": "^3.5.3",
"@vladfrangu/async_event_emitter": "^2.2.2", "@vladfrangu/async_event_emitter": "^2.2.4",
"discord-api-types": "0.37.61", "discord-api-types": "0.37.83",
"magic-bytes.js": "^1.5.0", "magic-bytes.js": "^1.10.0",
"tslib": "^2.6.2", "tslib": "^2.6.2",
"undici": "5.27.2" "undici": "6.13.0"
}, },
"engines": { "engines": {
"node": ">=16.11.0" "node": ">=16.11.0"
},
"funding": {
"url": "https://github.com/discordjs/discord.js?sponsor"
} }
}, },
"node_modules/@discordjs/rest/node_modules/@discordjs/collection": { "node_modules/@discordjs/rest/node_modules/@discordjs/collection": {
"version": "2.0.0", "version": "2.1.0",
"resolved": "https://registry.npmjs.org/@discordjs/collection/-/collection-2.0.0.tgz", "resolved": "https://registry.npmjs.org/@discordjs/collection/-/collection-2.1.0.tgz",
"integrity": "sha512-YTWIXLrf5FsrLMycpMM9Q6vnZoR/lN2AWX23/Cuo8uOOtS8eHB2dyQaaGnaF8aZPYnttf2bkLMcXn/j6JUOi3w==", "integrity": "sha512-mLcTACtXUuVgutoznkh6hS3UFqYirDYAg5Dc1m8xn6OvPjetnUlf/xjtqnnc47OwWdaoCQnHmHh9KofhD6uRqw==",
"engines": { "engines": {
"node": ">=18" "node": ">=18"
},
"funding": {
"url": "https://github.com/discordjs/discord.js?sponsor"
} }
}, },
"node_modules/@discordjs/util": { "node_modules/@discordjs/util": {
"version": "1.0.2", "version": "1.1.0",
"resolved": "https://registry.npmjs.org/@discordjs/util/-/util-1.0.2.tgz", "resolved": "https://registry.npmjs.org/@discordjs/util/-/util-1.1.0.tgz",
"integrity": "sha512-IRNbimrmfb75GMNEjyznqM1tkI7HrZOf14njX7tCAAUetyZM1Pr8hX/EK2lxBCOgWDRmigbp24fD1hdMfQK5lw==", "integrity": "sha512-IndcI5hzlNZ7GS96RV3Xw1R2kaDuXEp7tRIy/KlhidpN/BQ1qh1NZt3377dMLTa44xDUNKT7hnXkA/oUAzD/lg==",
"engines": { "engines": {
"node": ">=16.11.0" "node": ">=16.11.0"
},
"funding": {
"url": "https://github.com/discordjs/discord.js?sponsor"
} }
}, },
"node_modules/@discordjs/ws": { "node_modules/@discordjs/ws": {
"version": "1.0.2", "version": "1.1.1",
"resolved": "https://registry.npmjs.org/@discordjs/ws/-/ws-1.0.2.tgz", "resolved": "https://registry.npmjs.org/@discordjs/ws/-/ws-1.1.1.tgz",
"integrity": "sha512-+XI82Rm2hKnFwAySXEep4A7Kfoowt6weO6381jgW+wVdTpMS/56qCvoXyFRY0slcv7c/U8My2PwIB2/wEaAh7Q==", "integrity": "sha512-PZ+vLpxGCRtmr2RMkqh8Zp+BenUaJqlS6xhgWKEZcgC/vfHLEzpHtKkB0sl3nZWpwtcKk6YWy+pU3okL2I97FA==",
"dependencies": { "dependencies": {
"@discordjs/collection": "^2.0.0", "@discordjs/collection": "^2.1.0",
"@discordjs/rest": "^2.1.0", "@discordjs/rest": "^2.3.0",
"@discordjs/util": "^1.0.2", "@discordjs/util": "^1.1.0",
"@sapphire/async-queue": "^1.5.0", "@sapphire/async-queue": "^1.5.2",
"@types/ws": "^8.5.9", "@types/ws": "^8.5.10",
"@vladfrangu/async_event_emitter": "^2.2.2", "@vladfrangu/async_event_emitter": "^2.2.4",
"discord-api-types": "0.37.61", "discord-api-types": "0.37.83",
"tslib": "^2.6.2", "tslib": "^2.6.2",
"ws": "^8.14.2" "ws": "^8.16.0"
}, },
"engines": { "engines": {
"node": ">=16.11.0" "node": ">=16.11.0"
},
"funding": {
"url": "https://github.com/discordjs/discord.js?sponsor"
} }
}, },
"node_modules/@discordjs/ws/node_modules/@discordjs/collection": { "node_modules/@discordjs/ws/node_modules/@discordjs/collection": {
"version": "2.0.0", "version": "2.1.0",
"resolved": "https://registry.npmjs.org/@discordjs/collection/-/collection-2.0.0.tgz", "resolved": "https://registry.npmjs.org/@discordjs/collection/-/collection-2.1.0.tgz",
"integrity": "sha512-YTWIXLrf5FsrLMycpMM9Q6vnZoR/lN2AWX23/Cuo8uOOtS8eHB2dyQaaGnaF8aZPYnttf2bkLMcXn/j6JUOi3w==", "integrity": "sha512-mLcTACtXUuVgutoznkh6hS3UFqYirDYAg5Dc1m8xn6OvPjetnUlf/xjtqnnc47OwWdaoCQnHmHh9KofhD6uRqw==",
"engines": { "engines": {
"node": ">=18" "node": ">=18"
}
}, },
"node_modules/@fastify/busboy": { "funding": {
"version": "2.1.0", "url": "https://github.com/discordjs/discord.js?sponsor"
"resolved": "https://registry.npmjs.org/@fastify/busboy/-/busboy-2.1.0.tgz",
"integrity": "sha512-+KpH+QxZU7O4675t3mnkQKcZZg56u+K/Ct2K+N2AZYNVK8kyeo/bI18tI8aPm3tvNNRyTWfj6s5tnGNlcbQRsA==",
"engines": {
"node": ">=14"
} }
}, },
"node_modules/@sapphire/async-queue": { "node_modules/@sapphire/async-queue": {
"version": "1.5.2", "version": "1.5.3",
"resolved": "https://registry.npmjs.org/@sapphire/async-queue/-/async-queue-1.5.2.tgz", "resolved": "https://registry.npmjs.org/@sapphire/async-queue/-/async-queue-1.5.3.tgz",
"integrity": "sha512-7X7FFAA4DngXUl95+hYbUF19bp1LGiffjJtu7ygrZrbdCSsdDDBaSjB7Akw0ZbOu6k0xpXyljnJ6/RZUvLfRdg==", "integrity": "sha512-x7zadcfJGxFka1Q3f8gCts1F0xMwCKbZweM85xECGI0hBTeIZJGGCrHgLggihBoprlQ/hBmDR5LKfIPqnmHM3w==",
"engines": { "engines": {
"node": ">=v14.0.0", "node": ">=v14.0.0",
"npm": ">=7.0.0" "npm": ">=7.0.0"
} }
}, },
"node_modules/@sapphire/shapeshift": { "node_modules/@sapphire/shapeshift": {
"version": "3.9.6", "version": "3.9.7",
"resolved": "https://registry.npmjs.org/@sapphire/shapeshift/-/shapeshift-3.9.6.tgz", "resolved": "https://registry.npmjs.org/@sapphire/shapeshift/-/shapeshift-3.9.7.tgz",
"integrity": "sha512-4+Na/fxu2SEepZRb9z0dbsVh59QtwPuBg/UVaDib3av7ZY14b14+z09z6QVn0P6Dv6eOU2NDTsjIi0mbtgP56g==", "integrity": "sha512-4It2mxPSr4OGn4HSQWGmhFMsNFGfFVhWeRPCRwbH972Ek2pzfGRZtb0pJ4Ze6oIzcyh2jw7nUDa6qGlWofgd9g==",
"dependencies": { "dependencies": {
"fast-deep-equal": "^3.1.3", "fast-deep-equal": "^3.1.3",
"lodash": "^4.17.21" "lodash": "^4.17.21"
}, },
"engines": { "engines": {
"node": ">=v18" "node": ">=v16"
} }
}, },
"node_modules/@sapphire/snowflake": { "node_modules/@sapphire/snowflake": {
"version": "3.5.1", "version": "3.5.3",
"resolved": "https://registry.npmjs.org/@sapphire/snowflake/-/snowflake-3.5.1.tgz", "resolved": "https://registry.npmjs.org/@sapphire/snowflake/-/snowflake-3.5.3.tgz",
"integrity": "sha512-BxcYGzgEsdlG0dKAyOm0ehLGm2CafIrfQTZGWgkfKYbj+pNNsorZ7EotuZukc2MT70E0UbppVbtpBrqpzVzjNA==", "integrity": "sha512-jjmJywLAFoWeBi1W7994zZyiNWPIiqRRNAmSERxyg93xRGzNYvGjlZ0gR6x0F4gPRi2+0O6S71kOZYyr3cxaIQ==",
"engines": { "engines": {
"node": ">=v14.0.0", "node": ">=v14.0.0",
"npm": ">=7.0.0" "npm": ">=7.0.0"
} }
}, },
"node_modules/@types/node": { "node_modules/@types/node": {
"version": "20.11.20", "version": "22.5.1",
"resolved": "https://registry.npmjs.org/@types/node/-/node-20.11.20.tgz", "resolved": "https://registry.npmjs.org/@types/node/-/node-22.5.1.tgz",
"integrity": "sha512-7/rR21OS+fq8IyHTgtLkDK949uzsa6n8BkziAKtPVpugIkO6D+/ooXMvzXxDnZrmtXVfjb1bKQafYpb8s89LOg==", "integrity": "sha512-KkHsxej0j9IW1KKOOAA/XBA0z08UFSrRQHErzEfA3Vgq57eXIMYboIlHJuYIfd+lwCQjtKqUu3UnmKbtUc9yRw==",
"dependencies": { "dependencies": {
"undici-types": "~5.26.4" "undici-types": "~6.19.2"
} }
}, },
"node_modules/@types/ws": { "node_modules/@types/ws": {
"version": "8.5.9", "version": "8.5.12",
"resolved": "https://registry.npmjs.org/@types/ws/-/ws-8.5.9.tgz", "resolved": "https://registry.npmjs.org/@types/ws/-/ws-8.5.12.tgz",
"integrity": "sha512-jbdrY0a8lxfdTp/+r7Z4CkycbOFN8WX+IOchLJr3juT/xzbJ8URyTVSJ/hvNdadTgM1mnedb47n+Y31GsFnQlg==", "integrity": "sha512-3tPRkv1EtkDpzlgyKyI8pGsGZAGPEaXeu0DOj5DI25Ja91bdAYddYHbADRYVrZMRbfW+1l5YwXVDKohDJNQxkQ==",
"dependencies": { "dependencies": {
"@types/node": "*" "@types/node": "*"
} }
}, },
"node_modules/@vladfrangu/async_event_emitter": { "node_modules/@vladfrangu/async_event_emitter": {
"version": "2.2.4", "version": "2.4.6",
"resolved": "https://registry.npmjs.org/@vladfrangu/async_event_emitter/-/async_event_emitter-2.2.4.tgz", "resolved": "https://registry.npmjs.org/@vladfrangu/async_event_emitter/-/async_event_emitter-2.4.6.tgz",
"integrity": "sha512-ButUPz9E9cXMLgvAW8aLAKKJJsPu1dY1/l/E8xzLFuysowXygs6GBcyunK9rnGC4zTsnIc2mQo71rGw9U+Ykug==", "integrity": "sha512-RaI5qZo6D2CVS6sTHFKg1v5Ohq/+Bo2LZ5gzUEwZ/WkHhwtGTCB/sVLw8ijOkAUxasZ+WshN/Rzj4ywsABJ5ZA==",
"engines": { "engines": {
"node": ">=v14.0.0", "node": ">=v14.0.0",
"npm": ">=7.0.0" "npm": ">=7.0.0"
} }
}, },
"node_modules/discord-api-types": { "node_modules/discord-api-types": {
"version": "0.37.61", "version": "0.37.83",
"resolved": "https://registry.npmjs.org/discord-api-types/-/discord-api-types-0.37.61.tgz", "resolved": "https://registry.npmjs.org/discord-api-types/-/discord-api-types-0.37.83.tgz",
"integrity": "sha512-o/dXNFfhBpYHpQFdT6FWzeO7pKc838QeeZ9d91CfVAtpr5XLK4B/zYxQbYgPdoMiTDvJfzcsLW5naXgmHGDNXw==" "integrity": "sha512-urGGYeWtWNYMKnYlZnOnDHm8fVRffQs3U0SpE8RHeiuLKb/u92APS8HoQnPTFbnXmY1vVnXjXO4dOxcAn3J+DA=="
}, },
"node_modules/discord.js": { "node_modules/discord.js": {
"version": "14.14.1", "version": "14.15.3",
"resolved": "https://registry.npmjs.org/discord.js/-/discord.js-14.14.1.tgz", "resolved": "https://registry.npmjs.org/discord.js/-/discord.js-14.15.3.tgz",
"integrity": "sha512-/hUVzkIerxKHyRKopJy5xejp4MYKDPTszAnpYxzVVv4qJYf+Tkt+jnT2N29PIPschicaEEpXwF2ARrTYHYwQ5w==", "integrity": "sha512-/UJDQO10VuU6wQPglA4kz2bw2ngeeSbogiIPx/TsnctfzV/tNf+q+i1HlgtX1OGpeOBpJH9erZQNO5oRM2uAtQ==",
"dependencies": { "dependencies": {
"@discordjs/builders": "^1.7.0", "@discordjs/builders": "^1.8.2",
"@discordjs/collection": "1.5.3", "@discordjs/collection": "1.5.3",
"@discordjs/formatters": "^0.3.3", "@discordjs/formatters": "^0.4.0",
"@discordjs/rest": "^2.1.0", "@discordjs/rest": "^2.3.0",
"@discordjs/util": "^1.0.2", "@discordjs/util": "^1.1.0",
"@discordjs/ws": "^1.0.2", "@discordjs/ws": "^1.1.1",
"@sapphire/snowflake": "3.5.1", "@sapphire/snowflake": "3.5.3",
"@types/ws": "8.5.9", "discord-api-types": "0.37.83",
"discord-api-types": "0.37.61",
"fast-deep-equal": "3.1.3", "fast-deep-equal": "3.1.3",
"lodash.snakecase": "4.1.1", "lodash.snakecase": "4.1.1",
"tslib": "2.6.2", "tslib": "2.6.2",
"undici": "5.27.2", "undici": "6.13.0"
"ws": "8.14.2"
}, },
"engines": { "engines": {
"node": ">=16.11.0" "node": ">=16.11.0"
},
"funding": {
"url": "https://github.com/discordjs/discord.js?sponsor"
} }
}, },
"node_modules/fast-deep-equal": { "node_modules/fast-deep-equal": {
@ -218,9 +232,9 @@
"integrity": "sha512-QZ1d4xoBHYUeuouhEq3lk3Uq7ldgyFXGBhg04+oRLnIz8o9T65Eh+8YdroUwn846zchkA9yDsDl5CVVaV2nqYw==" "integrity": "sha512-QZ1d4xoBHYUeuouhEq3lk3Uq7ldgyFXGBhg04+oRLnIz8o9T65Eh+8YdroUwn846zchkA9yDsDl5CVVaV2nqYw=="
}, },
"node_modules/magic-bytes.js": { "node_modules/magic-bytes.js": {
"version": "1.8.0", "version": "1.10.0",
"resolved": "https://registry.npmjs.org/magic-bytes.js/-/magic-bytes.js-1.8.0.tgz", "resolved": "https://registry.npmjs.org/magic-bytes.js/-/magic-bytes.js-1.10.0.tgz",
"integrity": "sha512-lyWpfvNGVb5lu8YUAbER0+UMBTdR63w2mcSUlhhBTyVbxJvjgqwyAf3AZD6MprgK0uHuBoWXSDAMWLupX83o3Q==" "integrity": "sha512-/k20Lg2q8LE5xiaaSkMXk4sfvI+9EGEykFS4b0CHHGWqDYU0bGUFSwchNOMA56D7TCs9GwVTkqe9als1/ns8UQ=="
}, },
"node_modules/ts-mixer": { "node_modules/ts-mixer": {
"version": "6.0.4", "version": "6.0.4",
@ -233,25 +247,22 @@
"integrity": "sha512-AEYxH93jGFPn/a2iVAwW87VuUIkR1FVUKB77NwMF7nBTDkDrrT/Hpt/IrCJ0QXhW27jTBDcf5ZY7w6RiqTMw2Q==" "integrity": "sha512-AEYxH93jGFPn/a2iVAwW87VuUIkR1FVUKB77NwMF7nBTDkDrrT/Hpt/IrCJ0QXhW27jTBDcf5ZY7w6RiqTMw2Q=="
}, },
"node_modules/undici": { "node_modules/undici": {
"version": "5.27.2", "version": "6.13.0",
"resolved": "https://registry.npmjs.org/undici/-/undici-5.27.2.tgz", "resolved": "https://registry.npmjs.org/undici/-/undici-6.13.0.tgz",
"integrity": "sha512-iS857PdOEy/y3wlM3yRp+6SNQQ6xU0mmZcwRSriqk+et/cwWAtwmIGf6WkoDN2EK/AMdCO/dfXzIwi+rFMrjjQ==", "integrity": "sha512-Q2rtqmZWrbP8nePMq7mOJIN98M0fYvSgV89vwl/BQRT4mDOeY2GXZngfGpcBBhtky3woM7G24wZV3Q304Bv6cw==",
"dependencies": {
"@fastify/busboy": "^2.0.0"
},
"engines": { "engines": {
"node": ">=14.0" "node": ">=18.0"
} }
}, },
"node_modules/undici-types": { "node_modules/undici-types": {
"version": "5.26.5", "version": "6.19.8",
"resolved": "https://registry.npmjs.org/undici-types/-/undici-types-5.26.5.tgz", "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-6.19.8.tgz",
"integrity": "sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA==" "integrity": "sha512-ve2KP6f/JnbPBFyobGHuerC9g1FYGn/F8n1LWTwNxCEzd6IfqTwUQcNXgEtmmQ6DlRrC1hrSrBnCZPokRrDHjw=="
}, },
"node_modules/ws": { "node_modules/ws": {
"version": "8.14.2", "version": "8.18.0",
"resolved": "https://registry.npmjs.org/ws/-/ws-8.14.2.tgz", "resolved": "https://registry.npmjs.org/ws/-/ws-8.18.0.tgz",
"integrity": "sha512-wEBG1ftX4jcglPxgFCMJmZ2PLtSbJ2Peg6TmpJFTbe9GZYOQCDPdMYu/Tm0/bGZkw8paZnJY45J4K2PZrLYq8g==", "integrity": "sha512-8VbfWfHLbbwu3+N6OKsOMpBdT4kXPDDB9cJk2bJ6mh9ucxdlnNvH1e+roYkKmN9Nxw2yjz7VzeO9oOz2zJ04Pw==",
"engines": { "engines": {
"node": ">=10.0.0" "node": ">=10.0.0"
}, },

View File

@ -10,6 +10,6 @@
"author": "MajorMongoose/MajMongoose", "author": "MajorMongoose/MajMongoose",
"license": "AGPL-3.0-only", "license": "AGPL-3.0-only",
"dependencies": { "dependencies": {
"discord.js": "^14.14.1" "discord.js": "^14.15.3"
} }
} }

View File

@ -40,6 +40,13 @@ async function createButtonsFromCSV() {
for (let i = 0; i < rows.length; i++) { for (let i = 0; i < rows.length; i++) {
const [roleName, buttonName] = rows[i]; const [roleName, buttonName] = rows[i];
// Validate roleName and buttonName
if (!roleName || !buttonName) {
console.error(`Invalid data in CSV at line ${i + 1}: roleName="${roleName}", buttonName="${buttonName}"`);
continue; // Skip this iteration if data is invalid
}
const button = new ButtonBuilder() const button = new ButtonBuilder()
.setCustomId(roleName) .setCustomId(roleName)
.setLabel(buttonName) .setLabel(buttonName)
@ -61,36 +68,37 @@ async function createButtonsFromCSV() {
return messages; return messages;
} }
// Runs when someone presses a button.
client.on('interactionCreate', async interaction => { client.on('interactionCreate', async interaction => {
if (!interaction.isButton()) return; if (!interaction.isButton()) return;
try{ try {
interaction.deferReply(); await interaction.deferReply({ ephemeral: true }); // Acknowledge the interaction
const { member, guild } = interaction; const { member, guild } = interaction;
const role = guild.roles.cache.find(role => role.name === interaction.customId); const role = guild.roles.cache.find(role => role.name === interaction.customId);
if (!role) { if (!role) {
await interaction.reply({ content: 'Role not found.', ephemeral: true }); await interaction.editReply({ content: 'Role not found.' }); // Use editReply to send the response
console.error(`Role not found: ${role.name}`); console.error(`Role not found: ${interaction.customId}`);
return; return;
} }
if (member.roles.cache.has(role.id)) { if (member.roles.cache.has(role.id)) {
await member.roles.remove(role); await member.roles.remove(role);
console.log(`Role ${role.name} removed from user ${member.displayName}`); console.log(`Role ${role.name} removed from user ${member.displayName}`);
await interaction.reply({ content: `Role "${role.name}" removed.`, ephemeral: true }); await interaction.editReply({ content: `Role "${role.name}" removed.` }); // Use editReply here
} else { } else {
await member.roles.add(role); await member.roles.add(role);
console.log(`Role ${role.name} added to user ${member.displayName}`); console.log(`Role ${role.name} added to user ${member.displayName}`);
await interaction.reply({ content: `Role "${role.name}" added.`, ephemeral: true }); await interaction.editReply({ content: `Role "${role.name}" added.` }); // Use editReply here
} }
}catch(e){ } catch (e) {
console.error(e); console.error(e);
} }
}); });
async function deleteAllMessagesInChannel(channel) { async function deleteAllMessagesInChannel(channel) {
try { try {
const fetchedMessages = await channel.messages.fetch({ limit: 100 }); // Fetch up to 100 messages const fetchedMessages = await channel.messages.fetch({ limit: 100 }); // Fetch up to 100 messages