From 7450d5d72fbfe68ffe6fd3234a4a10a47e3c428b Mon Sep 17 00:00:00 2001 From: MARCROCK22 Date: Sat, 21 Dec 2024 22:47:38 -0400 Subject: [PATCH] fix: transformers types --- package.json | 6 +- pnpm-lock.yaml | 301 ++++++++++++---------- src/commands/applications/chatcontext.ts | 9 +- src/commands/applications/entrycontext.ts | 27 +- src/commands/applications/menucontext.ts | 24 +- src/commands/handle.ts | 2 +- src/commands/optionresolver.ts | 14 +- src/common/shorters/application.ts | 6 +- src/common/shorters/bans.ts | 4 +- src/common/shorters/channels.ts | 6 +- src/common/shorters/emojis.ts | 16 +- src/common/shorters/guilds.ts | 53 ++-- src/common/shorters/interaction.ts | 16 +- src/common/shorters/members.ts | 34 ++- src/common/shorters/messages.ts | 22 +- src/common/shorters/roles.ts | 19 +- src/common/shorters/templates.ts | 14 +- src/common/shorters/threads.ts | 25 +- src/common/shorters/users.ts | 15 +- src/common/shorters/webhook.ts | 27 +- src/components/componentcontext.ts | 29 ++- src/components/modalcontext.ts | 29 ++- src/events/hooks/auto_moderation.ts | 17 +- src/events/hooks/channel.ts | 4 +- src/events/hooks/custom.ts | 20 +- src/events/hooks/dispatch.ts | 4 +- src/events/hooks/entitlement.ts | 8 +- src/events/hooks/guild.ts | 68 ++++- src/events/hooks/integration.ts | 28 +- src/events/hooks/message.ts | 7 +- src/events/hooks/soundboard.ts | 27 +- src/events/hooks/thread.ts | 11 +- src/events/hooks/typing.ts | 13 +- src/structures/AutoModerationRule.ts | 23 +- src/structures/ClientUser.ts | 5 +- src/structures/Guild.ts | 3 +- src/structures/GuildBan.ts | 10 +- src/structures/GuildEmoji.ts | 17 +- src/structures/GuildMember.ts | 47 ++-- src/structures/GuildRole.ts | 21 +- src/structures/GuildTemplate.ts | 24 +- src/structures/Interaction.ts | 26 +- src/structures/Message.ts | 30 ++- src/structures/Poll.ts | 5 +- src/structures/Sticker.ts | 17 +- src/structures/User.ts | 7 +- src/structures/VoiceState.ts | 18 +- src/structures/Webhook.ts | 26 +- src/structures/channels.ts | 58 +++-- 49 files changed, 784 insertions(+), 458 deletions(-) diff --git a/package.json b/package.json index 1e104bb..4327f41 100644 --- a/package.json +++ b/package.json @@ -22,11 +22,11 @@ "license": "MIT", "devDependencies": { "@biomejs/biome": "1.9.4", - "@commitlint/cli": "^19.6.0", + "@commitlint/cli": "^19.6.1", "@commitlint/config-conventional": "^19.6.0", - "@types/node": "^22.10.1", + "@types/node": "^22.10.2", "husky": "^9.1.7", - "lint-staged": "^15.2.10", + "lint-staged": "^15.2.11", "typescript": "^5.7.2", "vitest": "^2.1.8" }, diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 166290d..e20f95f 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -12,26 +12,26 @@ importers: specifier: 1.9.4 version: 1.9.4 '@commitlint/cli': - specifier: ^19.6.0 - version: 19.6.0(@types/node@22.10.1)(typescript@5.7.2) + specifier: ^19.6.1 + version: 19.6.1(@types/node@22.10.2)(typescript@5.7.2) '@commitlint/config-conventional': specifier: ^19.6.0 version: 19.6.0 '@types/node': - specifier: ^22.10.1 - version: 22.10.1 + specifier: ^22.10.2 + version: 22.10.2 husky: specifier: ^9.1.7 version: 9.1.7 lint-staged: - specifier: ^15.2.10 - version: 15.2.10 + specifier: ^15.2.11 + version: 15.2.11 typescript: specifier: ^5.7.2 version: 5.7.2 vitest: specifier: ^2.1.8 - version: 2.1.8(@types/node@22.10.1) + version: 2.1.8(@types/node@22.10.2) packages: @@ -96,8 +96,8 @@ packages: cpu: [x64] os: [win32] - '@commitlint/cli@19.6.0': - resolution: {integrity: sha512-v17BgGD9w5KnthaKxXnEg6KLq6DYiAxyiN44TpiRtqyW8NSq+Kx99mkEG8Qo6uu6cI5eMzMojW2muJxjmPnF8w==} + '@commitlint/cli@19.6.1': + resolution: {integrity: sha512-8hcyA6ZoHwWXC76BoC8qVOSr8xHy00LZhZpauiD0iO0VYbVhMnED0da85lTfIULxl7Lj4c6vZgF0Wu/ed1+jlQ==} engines: {node: '>=v18'} hasBin: true @@ -129,8 +129,8 @@ packages: resolution: {integrity: sha512-LRo7zDkXtcIrpco9RnfhOKeg8PAnE3oDDoalnrVU/EVaKHYBWYL1DlRR7+3AWn0JiBqD8yKOfetVxJGdEtZ0tg==} engines: {node: '>=v18'} - '@commitlint/load@19.5.0': - resolution: {integrity: sha512-INOUhkL/qaKqwcTUvCE8iIUf5XHsEPCLY9looJ/ipzi7jtGhgmtH7OOFiNvwYgH7mA8osUWOUDV8t4E2HAi4xA==} + '@commitlint/load@19.6.1': + resolution: {integrity: sha512-kE4mRKWWNju2QpsCWt428XBvUH55OET2N4QKQ0bF85qS/XbsRGG1MiTByDNlEVpEPceMkDr46LNH95DtRwcsfA==} engines: {node: '>=v18'} '@commitlint/message@19.5.0': @@ -306,93 +306,98 @@ packages: '@jridgewell/sourcemap-codec@1.5.0': resolution: {integrity: sha512-gv3ZRaISU3fjPAgNsriBRqGWQL6quFx04YMPW/zD8XMLsU32mhCCbfbO6KZFLjvYpCZ8zyDEgqsgf+PwPaM7GQ==} - '@rollup/rollup-android-arm-eabi@4.28.0': - resolution: {integrity: sha512-wLJuPLT6grGZsy34g4N1yRfYeouklTgPhH1gWXCYspenKYD0s3cR99ZevOGw5BexMNywkbV3UkjADisozBmpPQ==} + '@rollup/rollup-android-arm-eabi@4.29.1': + resolution: {integrity: sha512-ssKhA8RNltTZLpG6/QNkCSge+7mBQGUqJRisZ2MDQcEGaK93QESEgWK2iOpIDZ7k9zPVkG5AS3ksvD5ZWxmItw==} cpu: [arm] os: [android] - '@rollup/rollup-android-arm64@4.28.0': - resolution: {integrity: sha512-eiNkznlo0dLmVG/6wf+Ifi/v78G4d4QxRhuUl+s8EWZpDewgk7PX3ZyECUXU0Zq/Ca+8nU8cQpNC4Xgn2gFNDA==} + '@rollup/rollup-android-arm64@4.29.1': + resolution: {integrity: sha512-CaRfrV0cd+NIIcVVN/jx+hVLN+VRqnuzLRmfmlzpOzB87ajixsN/+9L5xNmkaUUvEbI5BmIKS+XTwXsHEb65Ew==} cpu: [arm64] os: [android] - '@rollup/rollup-darwin-arm64@4.28.0': - resolution: {integrity: sha512-lmKx9yHsppblnLQZOGxdO66gT77bvdBtr/0P+TPOseowE7D9AJoBw8ZDULRasXRWf1Z86/gcOdpBrV6VDUY36Q==} + '@rollup/rollup-darwin-arm64@4.29.1': + resolution: {integrity: sha512-2ORr7T31Y0Mnk6qNuwtyNmy14MunTAMx06VAPI6/Ju52W10zk1i7i5U3vlDRWjhOI5quBcrvhkCHyF76bI7kEw==} cpu: [arm64] os: [darwin] - '@rollup/rollup-darwin-x64@4.28.0': - resolution: {integrity: sha512-8hxgfReVs7k9Js1uAIhS6zq3I+wKQETInnWQtgzt8JfGx51R1N6DRVy3F4o0lQwumbErRz52YqwjfvuwRxGv1w==} + '@rollup/rollup-darwin-x64@4.29.1': + resolution: {integrity: sha512-j/Ej1oanzPjmN0tirRd5K2/nncAhS9W6ICzgxV+9Y5ZsP0hiGhHJXZ2JQ53iSSjj8m6cRY6oB1GMzNn2EUt6Ng==} cpu: [x64] os: [darwin] - '@rollup/rollup-freebsd-arm64@4.28.0': - resolution: {integrity: sha512-lA1zZB3bFx5oxu9fYud4+g1mt+lYXCoch0M0V/xhqLoGatbzVse0wlSQ1UYOWKpuSu3gyN4qEc0Dxf/DII1bhQ==} + '@rollup/rollup-freebsd-arm64@4.29.1': + resolution: {integrity: sha512-91C//G6Dm/cv724tpt7nTyP+JdN12iqeXGFM1SqnljCmi5yTXriH7B1r8AD9dAZByHpKAumqP1Qy2vVNIdLZqw==} cpu: [arm64] os: [freebsd] - '@rollup/rollup-freebsd-x64@4.28.0': - resolution: {integrity: sha512-aI2plavbUDjCQB/sRbeUZWX9qp12GfYkYSJOrdYTL/C5D53bsE2/nBPuoiJKoWp5SN78v2Vr8ZPnB+/VbQ2pFA==} + '@rollup/rollup-freebsd-x64@4.29.1': + resolution: {integrity: sha512-hEioiEQ9Dec2nIRoeHUP6hr1PSkXzQaCUyqBDQ9I9ik4gCXQZjJMIVzoNLBRGet+hIUb3CISMh9KXuCcWVW/8w==} cpu: [x64] os: [freebsd] - '@rollup/rollup-linux-arm-gnueabihf@4.28.0': - resolution: {integrity: sha512-WXveUPKtfqtaNvpf0iOb0M6xC64GzUX/OowbqfiCSXTdi/jLlOmH0Ba94/OkiY2yTGTwteo4/dsHRfh5bDCZ+w==} + '@rollup/rollup-linux-arm-gnueabihf@4.29.1': + resolution: {integrity: sha512-Py5vFd5HWYN9zxBv3WMrLAXY3yYJ6Q/aVERoeUFwiDGiMOWsMs7FokXihSOaT/PMWUty/Pj60XDQndK3eAfE6A==} cpu: [arm] os: [linux] - '@rollup/rollup-linux-arm-musleabihf@4.28.0': - resolution: {integrity: sha512-yLc3O2NtOQR67lI79zsSc7lk31xjwcaocvdD1twL64PK1yNaIqCeWI9L5B4MFPAVGEVjH5k1oWSGuYX1Wutxpg==} + '@rollup/rollup-linux-arm-musleabihf@4.29.1': + resolution: {integrity: sha512-RiWpGgbayf7LUcuSNIbahr0ys2YnEERD4gYdISA06wa0i8RALrnzflh9Wxii7zQJEB2/Eh74dX4y/sHKLWp5uQ==} cpu: [arm] os: [linux] - '@rollup/rollup-linux-arm64-gnu@4.28.0': - resolution: {integrity: sha512-+P9G9hjEpHucHRXqesY+3X9hD2wh0iNnJXX/QhS/J5vTdG6VhNYMxJ2rJkQOxRUd17u5mbMLHM7yWGZdAASfcg==} + '@rollup/rollup-linux-arm64-gnu@4.29.1': + resolution: {integrity: sha512-Z80O+taYxTQITWMjm/YqNoe9d10OX6kDh8X5/rFCMuPqsKsSyDilvfg+vd3iXIqtfmp+cnfL1UrYirkaF8SBZA==} cpu: [arm64] os: [linux] - '@rollup/rollup-linux-arm64-musl@4.28.0': - resolution: {integrity: sha512-1xsm2rCKSTpKzi5/ypT5wfc+4bOGa/9yI/eaOLW0oMs7qpC542APWhl4A37AENGZ6St6GBMWhCCMM6tXgTIplw==} + '@rollup/rollup-linux-arm64-musl@4.29.1': + resolution: {integrity: sha512-fOHRtF9gahwJk3QVp01a/GqS4hBEZCV1oKglVVq13kcK3NeVlS4BwIFzOHDbmKzt3i0OuHG4zfRP0YoG5OF/rA==} cpu: [arm64] os: [linux] - '@rollup/rollup-linux-powerpc64le-gnu@4.28.0': - resolution: {integrity: sha512-zgWxMq8neVQeXL+ouSf6S7DoNeo6EPgi1eeqHXVKQxqPy1B2NvTbaOUWPn/7CfMKL7xvhV0/+fq/Z/J69g1WAQ==} + '@rollup/rollup-linux-loongarch64-gnu@4.29.1': + resolution: {integrity: sha512-5a7q3tnlbcg0OodyxcAdrrCxFi0DgXJSoOuidFUzHZ2GixZXQs6Tc3CHmlvqKAmOs5eRde+JJxeIf9DonkmYkw==} + cpu: [loong64] + os: [linux] + + '@rollup/rollup-linux-powerpc64le-gnu@4.29.1': + resolution: {integrity: sha512-9b4Mg5Yfz6mRnlSPIdROcfw1BU22FQxmfjlp/CShWwO3LilKQuMISMTtAu/bxmmrE6A902W2cZJuzx8+gJ8e9w==} cpu: [ppc64] os: [linux] - '@rollup/rollup-linux-riscv64-gnu@4.28.0': - resolution: {integrity: sha512-VEdVYacLniRxbRJLNtzwGt5vwS0ycYshofI7cWAfj7Vg5asqj+pt+Q6x4n+AONSZW/kVm+5nklde0qs2EUwU2g==} + '@rollup/rollup-linux-riscv64-gnu@4.29.1': + resolution: {integrity: sha512-G5pn0NChlbRM8OJWpJFMX4/i8OEU538uiSv0P6roZcbpe/WfhEO+AT8SHVKfp8qhDQzaz7Q+1/ixMy7hBRidnQ==} cpu: [riscv64] os: [linux] - '@rollup/rollup-linux-s390x-gnu@4.28.0': - resolution: {integrity: sha512-LQlP5t2hcDJh8HV8RELD9/xlYtEzJkm/aWGsauvdO2ulfl3QYRjqrKW+mGAIWP5kdNCBheqqqYIGElSRCaXfpw==} + '@rollup/rollup-linux-s390x-gnu@4.29.1': + resolution: {integrity: sha512-WM9lIkNdkhVwiArmLxFXpWndFGuOka4oJOZh8EP3Vb8q5lzdSCBuhjavJsw68Q9AKDGeOOIHYzYm4ZFvmWez5g==} cpu: [s390x] os: [linux] - '@rollup/rollup-linux-x64-gnu@4.28.0': - resolution: {integrity: sha512-Nl4KIzteVEKE9BdAvYoTkW19pa7LR/RBrT6F1dJCV/3pbjwDcaOq+edkP0LXuJ9kflW/xOK414X78r+K84+msw==} + '@rollup/rollup-linux-x64-gnu@4.29.1': + resolution: {integrity: sha512-87xYCwb0cPGZFoGiErT1eDcssByaLX4fc0z2nRM6eMtV9njAfEE6OW3UniAoDhX4Iq5xQVpE6qO9aJbCFumKYQ==} cpu: [x64] os: [linux] - '@rollup/rollup-linux-x64-musl@4.28.0': - resolution: {integrity: sha512-eKpJr4vBDOi4goT75MvW+0dXcNUqisK4jvibY9vDdlgLx+yekxSm55StsHbxUsRxSTt3JEQvlr3cGDkzcSP8bw==} + '@rollup/rollup-linux-x64-musl@4.29.1': + resolution: {integrity: sha512-xufkSNppNOdVRCEC4WKvlR1FBDyqCSCpQeMMgv9ZyXqqtKBfkw1yfGMTUTs9Qsl6WQbJnsGboWCp7pJGkeMhKA==} cpu: [x64] os: [linux] - '@rollup/rollup-win32-arm64-msvc@4.28.0': - resolution: {integrity: sha512-Vi+WR62xWGsE/Oj+mD0FNAPY2MEox3cfyG0zLpotZdehPFXwz6lypkGs5y38Jd/NVSbOD02aVad6q6QYF7i8Bg==} + '@rollup/rollup-win32-arm64-msvc@4.29.1': + resolution: {integrity: sha512-F2OiJ42m77lSkizZQLuC+jiZ2cgueWQL5YC9tjo3AgaEw+KJmVxHGSyQfDUoYR9cci0lAywv2Clmckzulcq6ig==} cpu: [arm64] os: [win32] - '@rollup/rollup-win32-ia32-msvc@4.28.0': - resolution: {integrity: sha512-kN/Vpip8emMLn/eOza+4JwqDZBL6MPNpkdaEsgUtW1NYN3DZvZqSQrbKzJcTL6hd8YNmFTn7XGWMwccOcJBL0A==} + '@rollup/rollup-win32-ia32-msvc@4.29.1': + resolution: {integrity: sha512-rYRe5S0FcjlOBZQHgbTKNrqxCBUmgDJem/VQTCcTnA2KCabYSWQDrytOzX7avb79cAAweNmMUb/Zw18RNd4mng==} cpu: [ia32] os: [win32] - '@rollup/rollup-win32-x64-msvc@4.28.0': - resolution: {integrity: sha512-Bvno2/aZT6usSa7lRDL2+hMjVAGjuqaymF1ApZm31JXzniR/hvr14jpU+/z4X6Gt5BPlzosscyJZGUvguXIqeQ==} + '@rollup/rollup-win32-x64-msvc@4.29.1': + resolution: {integrity: sha512-+10CMg9vt1MoHj6x1pxyjPSMjHTIlqs8/tBztXvPAx24SKs9jwVnKqHJumlH/IzhaPUaj3T6T6wfZr8okdXaIg==} cpu: [x64] os: [win32] @@ -402,8 +407,8 @@ packages: '@types/estree@1.0.6': resolution: {integrity: sha512-AYnb1nQyY49te+VRAVgmzfcgjYS91mY5P0TKUDCLEM+gNnA+3T6rWITXRLYCpahpqSQbN5cE+gHpnPyXjHWxcw==} - '@types/node@22.10.1': - resolution: {integrity: sha512-qKgsUwfHZV2WCWLAnVP1JqnpE6Im6h3Y0+fYgMTasNQ7V++CBX5OT1as0g0f+OyubbFqhf6XVNIsmN4IIhEgGQ==} + '@types/node@22.10.2': + resolution: {integrity: sha512-Xxr6BBRCAOQixvonOye19wnzyDiUtTeqldOOmj3CkeblonbccA12PFwlufvRdrpjXxqnmUaeiU5EOA+7s5diUQ==} '@vitest/expect@2.1.8': resolution: {integrity: sha512-8ytZ/fFHq2g4PJVAtDX57mayemKgDR6X3Oa2Foro+EygiOJHUXhCqBAAKQYYajZpFoIfvBCF1j6R6IYRSIUFuw==} @@ -491,6 +496,10 @@ packages: resolution: {integrity: sha512-dLitG79d+GV1Nb/VYcCDFivJeK1hiukt9QjRNVOsUtTy1rR1YJsmpGGTZ3qJos+uw7WmWF4wUwBd9jxjocFC2w==} engines: {node: ^12.17.0 || ^14.13 || >=16.0.0} + chalk@5.4.1: + resolution: {integrity: sha512-zgVZuo2WcZgfUEmsn6eO3kINexW8RAE4maiQ8QNs8CtpPCSyMiYsULR3HQYkm3w8FIA3SberyMJMSldGsW+U3w==} + engines: {node: ^12.17.0 || ^14.13 || >=16.0.0} + check-error@2.1.1: resolution: {integrity: sha512-OAlb+T7V4Op9OwdkjmguYRqncdlx5JiofwOAUkmTF+jNdHwzTaTs4sRAGpzLF3oOz5xAyDGrPgeIDFQmDOTiJw==} engines: {node: '>= 16'} @@ -537,13 +546,13 @@ packages: engines: {node: '>=16'} hasBin: true - cosmiconfig-typescript-loader@5.1.0: - resolution: {integrity: sha512-7PtBB+6FdsOvZyJtlF3hEPpACq7RQX6BVGsgC7/lfVXnKMvNCu/XY3ykreqG5w/rBNdu2z8LCIKoF3kpHHdHlA==} - engines: {node: '>=v16'} + cosmiconfig-typescript-loader@6.1.0: + resolution: {integrity: sha512-tJ1w35ZRUiM5FeTzT7DtYWAFFv37ZLqSRkGi2oeCK1gPhvaWjkAtfXvLmvE1pRfxxp9aQo6ba/Pvg1dKj05D4g==} + engines: {node: '>=v18'} peerDependencies: '@types/node': '*' - cosmiconfig: '>=8.2' - typescript: '>=4' + cosmiconfig: '>=9' + typescript: '>=5' cosmiconfig@9.0.0: resolution: {integrity: sha512-itvL5h8RETACmOTFc4UfIyB2RfEHi71Ax6E/PivVxq9NseKbOWpeyHEOIbmAw1rs8Ak0VursQNww7lf7YtUwzg==} @@ -562,8 +571,8 @@ packages: resolution: {integrity: sha512-wAV9QHOsNbwnWdNW2FYvE1P56wtgSbM+3SZcdGiWQILwVjACCXDCI3Ai8QlCjMDB8YK5zySiXZYBiwGmNY3lnw==} engines: {node: '>=12'} - debug@4.3.7: - resolution: {integrity: sha512-Er2nc/H7RrMXZBFCEim6TCmMk02Z8vLC2Rbi1KEBggpo0fS6l0S1nnapwmIi3yW/+GOJap1Krg4w0Hg80oCqgQ==} + debug@4.4.0: + resolution: {integrity: sha512-6WTZ/IxCY/T6BALoZHaE4ctp9xm+Z5kY/pzYaCHRFeyVhojxlrm+46y68HA6hr0TcwEssoxNiDEUJQjfPZ/RYA==} engines: {node: '>=6.0'} peerDependencies: supports-color: '*' @@ -716,8 +725,8 @@ packages: isexe@2.0.0: resolution: {integrity: sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==} - jiti@1.21.6: - resolution: {integrity: sha512-2yTgeWTWzMWkHu6Jp9NKgePDaYHbntiwvYuuJLbbN9vl7DC9DvXKOB2BC3ZZ92D3cvV/aflH0osDfwpHepQ53w==} + jiti@2.4.2: + resolution: {integrity: sha512-rg9zJN+G4n2nfJl5MW3BMygZX56zKPNVEYYqq7adpmMh4Jn2QNEwhvQlFy6jPVdcod7txZtKHWnyZiA3a0zP7A==} hasBin: true js-tokens@4.0.0: @@ -737,15 +746,15 @@ packages: resolution: {integrity: sha512-POQXvpdL69+CluYsillJ7SUhKvytYjW9vG/GKpnf+xP8UWgYEM/RaMzHHofbALDiKbbP1W8UEYmgGl39WkPZsg==} engines: {'0': node >= 0.2.0} - lilconfig@3.1.2: - resolution: {integrity: sha512-eop+wDAvpItUys0FWkHIKeC9ybYrTGbU41U5K7+bttZZeohvnY7M9dZ5kB21GNWiFT2q1OoPTvncPCgSOVO5ow==} + lilconfig@3.1.3: + resolution: {integrity: sha512-/vlFKAoH5Cgt3Ie+JLhRbwOsCQePABiU3tJ1egGvyQ+33R/vcwM2Zl2QR/LzjsBeItPt3oSVXapn+m4nQDvpzw==} engines: {node: '>=14'} lines-and-columns@1.2.4: resolution: {integrity: sha512-7ylylesZQ/PV29jhEDl3Ufjo6ZX7gCqJr5F7PKrqc93v7fzSymt1BpwEU8nAUXs8qzzvqhbjhK5QZg6Mt/HkBg==} - lint-staged@15.2.10: - resolution: {integrity: sha512-5dY5t743e1byO19P9I4b3x8HJwalIznL5E1FWYnU6OWw33KxNBSLAc6Cy7F2PsFEO8FKnLwjwm5hx7aMF0jzZg==} + lint-staged@15.2.11: + resolution: {integrity: sha512-Ev6ivCTYRTGs9ychvpVw35m/bcNDuBN+mnTeObCL5h+boS5WzBEC6LHI4I9F/++sZm1m+J2LEiy0gxL/R9TBqQ==} engines: {node: '>=18.12.0'} hasBin: true @@ -791,8 +800,8 @@ packages: loupe@3.1.2: resolution: {integrity: sha512-23I4pFZHmAemUnz8WZXbYRSKYj801VDaNv9ETuMh7IrMc7VuVVSo+Z9iLE3ni30+U48iDWfi30d3twAXBYmnCg==} - magic-string@0.30.14: - resolution: {integrity: sha512-5c99P1WKTed11ZC0HMJOj6CDIue6F8ySu+bJL+85q1zBEIY8IklrJ1eiKC2NDRh3Ct3FcvmJPyQHb9erXMTJNw==} + magic-string@0.30.17: + resolution: {integrity: sha512-sNPKHvyjVf7gyjwS4xGTaW/mCnF8wnjtifKBEhxfZ7E/S8tQ0rssrwGNn6q8JH/ohItJfSQp9mBtQYuTlH5QnA==} meow@12.1.1: resolution: {integrity: sha512-BhXM0Au22RwUneMPwSCnyhTOizdWoIEPU9sp0Aqa1PnDMR5Wv2FGXYDjuzJEIX+Eo2Rb8xuYe5jrnm5QowQFkw==} @@ -910,8 +919,8 @@ packages: rfdc@1.4.1: resolution: {integrity: sha512-q1b3N5QkRUWUl7iyylaaj3kOpIT0N2i9MqIEQXP73GVsN9cw3fdx8X63cEmWhJGi2PPCF23Ijp7ktmd39rawIA==} - rollup@4.28.0: - resolution: {integrity: sha512-G9GOrmgWHBma4YfCcX8PjH0qhXSdH8B4HDE2o4/jaxj93S4DPCIDoLcXz99eWMji4hB29UFCEd7B2gwGJDR9cQ==} + rollup@4.29.1: + resolution: {integrity: sha512-RaJ45M/kmJUzSWDs1Nnd5DdV4eerC98idtUOVr6FfKcgxqvjwHmxc5upLF9qZU9EpsVzzhleFahrT3shLuJzIw==} engines: {node: '>=18.0.0', npm: '>=8.0.0'} hasBin: true @@ -1105,8 +1114,8 @@ packages: resolution: {integrity: sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA==} engines: {node: '>=10'} - yaml@2.5.1: - resolution: {integrity: sha512-bLQOjaX/ADgQ20isPJRvF0iRUHIxVhYvr53Of7wGcWlO2jvtUlH5m87DsmulFVxRpNLOnI4tB6p/oh8D7kpn9Q==} + yaml@2.6.1: + resolution: {integrity: sha512-7r0XPzioN/Q9kXBro/XPnA6kznR73DHq+GXh5ON7ZozRO6aMjbmiBuKste2wslTFkC5d1dw0GooOCepZXJ2SAg==} engines: {node: '>= 14'} hasBin: true @@ -1167,11 +1176,11 @@ snapshots: '@biomejs/cli-win32-x64@1.9.4': optional: true - '@commitlint/cli@19.6.0(@types/node@22.10.1)(typescript@5.7.2)': + '@commitlint/cli@19.6.1(@types/node@22.10.2)(typescript@5.7.2)': dependencies: '@commitlint/format': 19.5.0 '@commitlint/lint': 19.6.0 - '@commitlint/load': 19.5.0(@types/node@22.10.1)(typescript@5.7.2) + '@commitlint/load': 19.6.1(@types/node@22.10.2)(typescript@5.7.2) '@commitlint/read': 19.5.0 '@commitlint/types': 19.5.0 tinyexec: 0.3.1 @@ -1204,7 +1213,7 @@ snapshots: '@commitlint/format@19.5.0': dependencies: '@commitlint/types': 19.5.0 - chalk: 5.3.0 + chalk: 5.4.1 '@commitlint/is-ignored@19.6.0': dependencies: @@ -1218,15 +1227,15 @@ snapshots: '@commitlint/rules': 19.6.0 '@commitlint/types': 19.5.0 - '@commitlint/load@19.5.0(@types/node@22.10.1)(typescript@5.7.2)': + '@commitlint/load@19.6.1(@types/node@22.10.2)(typescript@5.7.2)': dependencies: '@commitlint/config-validator': 19.5.0 '@commitlint/execute-rule': 19.5.0 '@commitlint/resolve-extends': 19.5.0 '@commitlint/types': 19.5.0 - chalk: 5.3.0 + chalk: 5.4.1 cosmiconfig: 9.0.0(typescript@5.7.2) - cosmiconfig-typescript-loader: 5.1.0(@types/node@22.10.1)(cosmiconfig@9.0.0(typescript@5.7.2))(typescript@5.7.2) + cosmiconfig-typescript-loader: 6.1.0(@types/node@22.10.2)(cosmiconfig@9.0.0(typescript@5.7.2))(typescript@5.7.2) lodash.isplainobject: 4.0.6 lodash.merge: 4.6.2 lodash.uniq: 4.5.0 @@ -1275,7 +1284,7 @@ snapshots: '@commitlint/types@19.5.0': dependencies: '@types/conventional-commits-parser': 5.0.1 - chalk: 5.3.0 + chalk: 5.4.1 '@esbuild/aix-ppc64@0.21.5': optional: true @@ -1348,67 +1357,70 @@ snapshots: '@jridgewell/sourcemap-codec@1.5.0': {} - '@rollup/rollup-android-arm-eabi@4.28.0': + '@rollup/rollup-android-arm-eabi@4.29.1': optional: true - '@rollup/rollup-android-arm64@4.28.0': + '@rollup/rollup-android-arm64@4.29.1': optional: true - '@rollup/rollup-darwin-arm64@4.28.0': + '@rollup/rollup-darwin-arm64@4.29.1': optional: true - '@rollup/rollup-darwin-x64@4.28.0': + '@rollup/rollup-darwin-x64@4.29.1': optional: true - '@rollup/rollup-freebsd-arm64@4.28.0': + '@rollup/rollup-freebsd-arm64@4.29.1': optional: true - '@rollup/rollup-freebsd-x64@4.28.0': + '@rollup/rollup-freebsd-x64@4.29.1': optional: true - '@rollup/rollup-linux-arm-gnueabihf@4.28.0': + '@rollup/rollup-linux-arm-gnueabihf@4.29.1': optional: true - '@rollup/rollup-linux-arm-musleabihf@4.28.0': + '@rollup/rollup-linux-arm-musleabihf@4.29.1': optional: true - '@rollup/rollup-linux-arm64-gnu@4.28.0': + '@rollup/rollup-linux-arm64-gnu@4.29.1': optional: true - '@rollup/rollup-linux-arm64-musl@4.28.0': + '@rollup/rollup-linux-arm64-musl@4.29.1': optional: true - '@rollup/rollup-linux-powerpc64le-gnu@4.28.0': + '@rollup/rollup-linux-loongarch64-gnu@4.29.1': optional: true - '@rollup/rollup-linux-riscv64-gnu@4.28.0': + '@rollup/rollup-linux-powerpc64le-gnu@4.29.1': optional: true - '@rollup/rollup-linux-s390x-gnu@4.28.0': + '@rollup/rollup-linux-riscv64-gnu@4.29.1': optional: true - '@rollup/rollup-linux-x64-gnu@4.28.0': + '@rollup/rollup-linux-s390x-gnu@4.29.1': optional: true - '@rollup/rollup-linux-x64-musl@4.28.0': + '@rollup/rollup-linux-x64-gnu@4.29.1': optional: true - '@rollup/rollup-win32-arm64-msvc@4.28.0': + '@rollup/rollup-linux-x64-musl@4.29.1': optional: true - '@rollup/rollup-win32-ia32-msvc@4.28.0': + '@rollup/rollup-win32-arm64-msvc@4.29.1': optional: true - '@rollup/rollup-win32-x64-msvc@4.28.0': + '@rollup/rollup-win32-ia32-msvc@4.29.1': + optional: true + + '@rollup/rollup-win32-x64-msvc@4.29.1': optional: true '@types/conventional-commits-parser@5.0.1': dependencies: - '@types/node': 22.10.1 + '@types/node': 22.10.2 '@types/estree@1.0.6': {} - '@types/node@22.10.1': + '@types/node@22.10.2': dependencies: undici-types: 6.20.0 @@ -1419,13 +1431,13 @@ snapshots: chai: 5.1.2 tinyrainbow: 1.2.0 - '@vitest/mocker@2.1.8(vite@5.4.11(@types/node@22.10.1))': + '@vitest/mocker@2.1.8(vite@5.4.11(@types/node@22.10.2))': dependencies: '@vitest/spy': 2.1.8 estree-walker: 3.0.3 - magic-string: 0.30.14 + magic-string: 0.30.17 optionalDependencies: - vite: 5.4.11(@types/node@22.10.1) + vite: 5.4.11(@types/node@22.10.2) '@vitest/pretty-format@2.1.8': dependencies: @@ -1439,7 +1451,7 @@ snapshots: '@vitest/snapshot@2.1.8': dependencies: '@vitest/pretty-format': 2.1.8 - magic-string: 0.30.14 + magic-string: 0.30.17 pathe: 1.1.2 '@vitest/spy@2.1.8': @@ -1502,6 +1514,8 @@ snapshots: chalk@5.3.0: {} + chalk@5.4.1: {} + check-error@2.1.1: {} cli-cursor@5.0.0: @@ -1549,11 +1563,11 @@ snapshots: meow: 12.1.1 split2: 4.2.0 - cosmiconfig-typescript-loader@5.1.0(@types/node@22.10.1)(cosmiconfig@9.0.0(typescript@5.7.2))(typescript@5.7.2): + cosmiconfig-typescript-loader@6.1.0(@types/node@22.10.2)(cosmiconfig@9.0.0(typescript@5.7.2))(typescript@5.7.2): dependencies: - '@types/node': 22.10.1 + '@types/node': 22.10.2 cosmiconfig: 9.0.0(typescript@5.7.2) - jiti: 1.21.6 + jiti: 2.4.2 typescript: 5.7.2 cosmiconfig@9.0.0(typescript@5.7.2): @@ -1573,7 +1587,7 @@ snapshots: dargs@8.1.0: {} - debug@4.3.7: + debug@4.4.0: dependencies: ms: 2.1.3 @@ -1713,7 +1727,7 @@ snapshots: isexe@2.0.0: {} - jiti@1.21.6: {} + jiti@2.4.2: {} js-tokens@4.0.0: {} @@ -1727,22 +1741,22 @@ snapshots: jsonparse@1.3.1: {} - lilconfig@3.1.2: {} + lilconfig@3.1.3: {} lines-and-columns@1.2.4: {} - lint-staged@15.2.10: + lint-staged@15.2.11: dependencies: chalk: 5.3.0 commander: 12.1.0 - debug: 4.3.7 + debug: 4.4.0 execa: 8.0.1 - lilconfig: 3.1.2 + lilconfig: 3.1.3 listr2: 8.2.5 micromatch: 4.0.8 pidtree: 0.6.0 string-argv: 0.3.2 - yaml: 2.5.1 + yaml: 2.6.1 transitivePeerDependencies: - supports-color @@ -1787,7 +1801,7 @@ snapshots: loupe@3.1.2: {} - magic-string@0.30.14: + magic-string@0.30.17: dependencies: '@jridgewell/sourcemap-codec': 1.5.0 @@ -1878,28 +1892,29 @@ snapshots: rfdc@1.4.1: {} - rollup@4.28.0: + rollup@4.29.1: dependencies: '@types/estree': 1.0.6 optionalDependencies: - '@rollup/rollup-android-arm-eabi': 4.28.0 - '@rollup/rollup-android-arm64': 4.28.0 - '@rollup/rollup-darwin-arm64': 4.28.0 - '@rollup/rollup-darwin-x64': 4.28.0 - '@rollup/rollup-freebsd-arm64': 4.28.0 - '@rollup/rollup-freebsd-x64': 4.28.0 - '@rollup/rollup-linux-arm-gnueabihf': 4.28.0 - '@rollup/rollup-linux-arm-musleabihf': 4.28.0 - '@rollup/rollup-linux-arm64-gnu': 4.28.0 - '@rollup/rollup-linux-arm64-musl': 4.28.0 - '@rollup/rollup-linux-powerpc64le-gnu': 4.28.0 - '@rollup/rollup-linux-riscv64-gnu': 4.28.0 - '@rollup/rollup-linux-s390x-gnu': 4.28.0 - '@rollup/rollup-linux-x64-gnu': 4.28.0 - '@rollup/rollup-linux-x64-musl': 4.28.0 - '@rollup/rollup-win32-arm64-msvc': 4.28.0 - '@rollup/rollup-win32-ia32-msvc': 4.28.0 - '@rollup/rollup-win32-x64-msvc': 4.28.0 + '@rollup/rollup-android-arm-eabi': 4.29.1 + '@rollup/rollup-android-arm64': 4.29.1 + '@rollup/rollup-darwin-arm64': 4.29.1 + '@rollup/rollup-darwin-x64': 4.29.1 + '@rollup/rollup-freebsd-arm64': 4.29.1 + '@rollup/rollup-freebsd-x64': 4.29.1 + '@rollup/rollup-linux-arm-gnueabihf': 4.29.1 + '@rollup/rollup-linux-arm-musleabihf': 4.29.1 + '@rollup/rollup-linux-arm64-gnu': 4.29.1 + '@rollup/rollup-linux-arm64-musl': 4.29.1 + '@rollup/rollup-linux-loongarch64-gnu': 4.29.1 + '@rollup/rollup-linux-powerpc64le-gnu': 4.29.1 + '@rollup/rollup-linux-riscv64-gnu': 4.29.1 + '@rollup/rollup-linux-s390x-gnu': 4.29.1 + '@rollup/rollup-linux-x64-gnu': 4.29.1 + '@rollup/rollup-linux-x64-musl': 4.29.1 + '@rollup/rollup-win32-arm64-msvc': 4.29.1 + '@rollup/rollup-win32-ia32-msvc': 4.29.1 + '@rollup/rollup-win32-x64-msvc': 4.29.1 fsevents: 2.3.3 semver@7.6.3: {} @@ -1980,13 +1995,13 @@ snapshots: unicorn-magic@0.1.0: {} - vite-node@2.1.8(@types/node@22.10.1): + vite-node@2.1.8(@types/node@22.10.2): dependencies: cac: 6.7.14 - debug: 4.3.7 + debug: 4.4.0 es-module-lexer: 1.5.4 pathe: 1.1.2 - vite: 5.4.11(@types/node@22.10.1) + vite: 5.4.11(@types/node@22.10.2) transitivePeerDependencies: - '@types/node' - less @@ -1998,39 +2013,39 @@ snapshots: - supports-color - terser - vite@5.4.11(@types/node@22.10.1): + vite@5.4.11(@types/node@22.10.2): dependencies: esbuild: 0.21.5 postcss: 8.4.49 - rollup: 4.28.0 + rollup: 4.29.1 optionalDependencies: - '@types/node': 22.10.1 + '@types/node': 22.10.2 fsevents: 2.3.3 - vitest@2.1.8(@types/node@22.10.1): + vitest@2.1.8(@types/node@22.10.2): dependencies: '@vitest/expect': 2.1.8 - '@vitest/mocker': 2.1.8(vite@5.4.11(@types/node@22.10.1)) + '@vitest/mocker': 2.1.8(vite@5.4.11(@types/node@22.10.2)) '@vitest/pretty-format': 2.1.8 '@vitest/runner': 2.1.8 '@vitest/snapshot': 2.1.8 '@vitest/spy': 2.1.8 '@vitest/utils': 2.1.8 chai: 5.1.2 - debug: 4.3.7 + debug: 4.4.0 expect-type: 1.1.0 - magic-string: 0.30.14 + magic-string: 0.30.17 pathe: 1.1.2 std-env: 3.8.0 tinybench: 2.9.0 tinyexec: 0.3.1 tinypool: 1.0.2 tinyrainbow: 1.2.0 - vite: 5.4.11(@types/node@22.10.1) - vite-node: 2.1.8(@types/node@22.10.1) + vite: 5.4.11(@types/node@22.10.2) + vite-node: 2.1.8(@types/node@22.10.2) why-is-node-running: 2.3.0 optionalDependencies: - '@types/node': 22.10.1 + '@types/node': 22.10.2 transitivePeerDependencies: - less - lightningcss @@ -2065,7 +2080,7 @@ snapshots: y18n@5.0.8: {} - yaml@2.5.1: {} + yaml@2.6.1: {} yargs-parser@21.1.1: {} diff --git a/src/commands/applications/chatcontext.ts b/src/commands/applications/chatcontext.ts index 63596e9..63a969c 100644 --- a/src/commands/applications/chatcontext.ts +++ b/src/commands/applications/chatcontext.ts @@ -1,4 +1,4 @@ -import type { AllChannels, InferWithPrefix, Message, ReturnCache } from '../..'; +import type { ReturnCache } from '../..'; import type { Client, WorkerClient } from '../../client'; import type { GuildMemberStructure, @@ -6,16 +6,17 @@ import type { InteractionGuildMemberStructure, MessageStructure, OptionResolverStructure, + UserStructure, WebhookMessageStructure, } from '../../client/transformers'; import type { If, MakeRequired, UnionToTuple, When } from '../../common'; import type { InteractionCreateBodyRequest, InteractionMessageUpdateBodyRequest } from '../../common/types/write'; -import { ChatInputCommandInteraction } from '../../structures'; +import { type AllChannels, ChatInputCommandInteraction, type Message } from '../../structures'; import { MessageFlags } from '../../types'; import { BaseContext } from '../basecontext'; import type { RegisteredMiddlewares } from '../decorators'; import type { Command, ContextOptions, OptionsRecord, SubCommand } from './chat'; -import type { CommandMetadata, ExtendContext, GlobalMetadata, UsingClient } from './shared'; +import type { CommandMetadata, ExtendContext, GlobalMetadata, InferWithPrefix, UsingClient } from './shared'; export interface CommandContext extends BaseContext, @@ -202,7 +203,7 @@ export class CommandContext< return this.interaction?.channelId || (this.message! as MessageStructure).channelId; } - get author() { + get author(): UserStructure { return this.interaction?.user || (this.message! as MessageStructure).author; } diff --git a/src/commands/applications/entrycontext.ts b/src/commands/applications/entrycontext.ts index 84c9312..102e73c 100644 --- a/src/commands/applications/entrycontext.ts +++ b/src/commands/applications/entrycontext.ts @@ -1,11 +1,18 @@ import type { ReturnCache } from '../..'; -import type { GuildMemberStructure, GuildStructure } from '../../client/transformers'; +import type { + GuildMemberStructure, + GuildStructure, + InteractionGuildMemberStructure, + UserStructure, + WebhookMessageStructure, +} from '../../client/transformers'; import type { InteractionCreateBodyRequest, InteractionMessageUpdateBodyRequest, MakeRequired, ModalCreateBodyRequest, UnionToTuple, + When, } from '../../common'; import type { AllChannels, EntryPointInteraction } from '../../structures'; import { MessageFlags } from '../../types'; @@ -37,7 +44,10 @@ export class EntryPointContext ex return this.command.name; } - write(body: InteractionCreateBodyRequest, withResponse?: WR) { + write( + body: InteractionCreateBodyRequest, + withResponse?: WR, + ): Promise> { return this.interaction.write(body, withResponse); } @@ -45,11 +55,14 @@ export class EntryPointContext ex return this.interaction.modal(body); } - deferReply(ephemeral = false, withResponse?: WR) { + deferReply( + ephemeral = false, + withResponse?: WR, + ): Promise> { return this.interaction.deferReply(ephemeral ? MessageFlags.Ephemeral : undefined, withResponse); } - editResponse(body: InteractionMessageUpdateBodyRequest) { + editResponse(body: InteractionMessageUpdateBodyRequest): Promise { return this.interaction.editResponse(body); } @@ -60,7 +73,7 @@ export class EntryPointContext ex editOrReply( body: InteractionCreateBodyRequest | InteractionMessageUpdateBodyRequest, withResponse?: WR, - ) { + ): Promise> { return this.interaction.editOrReply(body as InteractionCreateBodyRequest, withResponse); } @@ -112,11 +125,11 @@ export class EntryPointContext ex return this.interaction.channelId!; } - get author() { + get author(): UserStructure { return this.interaction.user; } - get member() { + get member(): InteractionGuildMemberStructure | undefined { return this.interaction.member; } diff --git a/src/commands/applications/menucontext.ts b/src/commands/applications/menucontext.ts index 12515ac..4a1c9dd 100644 --- a/src/commands/applications/menucontext.ts +++ b/src/commands/applications/menucontext.ts @@ -1,10 +1,11 @@ -import type { ContextMenuCommand, ReturnCache } from '../..'; +import type { ContextMenuCommand, InteractionGuildMemberStructure, ReturnCache } from '../..'; import { type GuildMemberStructure, type GuildStructure, type MessageStructure, Transformers, type UserStructure, + type WebhookMessageStructure, } from '../../client/transformers'; import { type InteractionCreateBodyRequest, @@ -12,6 +13,7 @@ import { type MakeRequired, type ModalCreateBodyRequest, type UnionToTuple, + type When, toSnakeCase, } from '../../common'; import type { AllChannels, MessageCommandInteraction, UserCommandInteraction } from '../../structures'; @@ -66,7 +68,10 @@ export class MenuCommandContext< return this.command.name; } - write(body: InteractionCreateBodyRequest, withResponse?: WR) { + write( + body: InteractionCreateBodyRequest, + withResponse?: WR, + ): Promise> { return this.interaction.write(body, withResponse); } @@ -74,11 +79,14 @@ export class MenuCommandContext< return this.interaction.modal(body); } - deferReply(ephemeral = false, withResponse?: WR) { + deferReply( + ephemeral = false, + withResponse?: WR, + ): Promise> { return this.interaction.deferReply(ephemeral ? MessageFlags.Ephemeral : undefined, withResponse); } - editResponse(body: InteractionMessageUpdateBodyRequest) { + editResponse(body: InteractionMessageUpdateBodyRequest): Promise { return this.interaction.editResponse(body); } @@ -89,11 +97,11 @@ export class MenuCommandContext< editOrReply( body: InteractionCreateBodyRequest | InteractionMessageUpdateBodyRequest, withResponse?: WR, - ) { + ): Promise> { return this.interaction.editOrReply(body as InteractionCreateBodyRequest, withResponse); } - fetchResponse() { + fetchResponse(): Promise { return this.interaction.fetchResponse(); } @@ -141,11 +149,11 @@ export class MenuCommandContext< return this.interaction.channelId!; } - get author() { + get author(): UserStructure { return this.interaction.user; } - get member() { + get member(): InteractionGuildMemberStructure | undefined { return this.interaction.member; } diff --git a/src/commands/handle.ts b/src/commands/handle.ts index c0ef426..b3a8570 100644 --- a/src/commands/handle.ts +++ b/src/commands/handle.ts @@ -495,7 +495,7 @@ export class HandleCommand { }; } - makeResolver(...args: Parameters<(typeof Transformers)['OptionResolver']>) { + makeResolver(...args: Parameters<(typeof Transformers)['OptionResolver']>): OptionResolverStructure { return Transformers.OptionResolver(...args); } diff --git a/src/commands/optionresolver.ts b/src/commands/optionresolver.ts index 622731c..2a5b32b 100644 --- a/src/commands/optionresolver.ts +++ b/src/commands/optionresolver.ts @@ -99,7 +99,19 @@ export class OptionResolver { return this.hoistedOptions.find(x => x.name === name); } - getValue(name: string) { + getValue( + name: string, + ): + | AllChannels + | Attachment + | boolean + | number + | string + | UserStructure + | GuildMemberStructure + | InteractionGuildMemberStructure + | GuildRoleStructure + | undefined { const option = this.getHoisted(name); if (!option) { return; diff --git a/src/common/shorters/application.ts b/src/common/shorters/application.ts index dd9224f..b949128 100644 --- a/src/common/shorters/application.ts +++ b/src/common/shorters/application.ts @@ -1,4 +1,4 @@ -import { Transformers } from '../../client'; +import { type EntitlementStructure, Transformers } from '../../client'; import type { APIEntitlement, RESTGetAPIEntitlementsQuery, @@ -42,7 +42,7 @@ export class ApplicationShorter extends BaseShorter { * @param applicationId The ID of the application. * @param [query] The query parameters. */ - listEntitlements(applicationId: string, query?: RESTGetAPIEntitlementsQuery) { + listEntitlements(applicationId: string, query?: RESTGetAPIEntitlementsQuery): Promise { return this.client.proxy .applications(applicationId) .entitlements.get({ query }) @@ -63,7 +63,7 @@ export class ApplicationShorter extends BaseShorter { * @param applicationId The ID of the application. * @param body The body of the request. */ - createTestEntitlement(applicationId: string, body: RESTPostAPIEntitlementBody) { + createTestEntitlement(applicationId: string, body: RESTPostAPIEntitlementBody): Promise { return this.client.proxy .applications(applicationId) .entitlements.post({ body }) diff --git a/src/common/shorters/bans.ts b/src/common/shorters/bans.ts index 361ef04..e29a953 100644 --- a/src/common/shorters/bans.ts +++ b/src/common/shorters/bans.ts @@ -49,7 +49,7 @@ export class BanShorter extends BaseShorter { * @param force Whether to force fetching the ban from the API even if it exists in the cache. * @returns A Promise that resolves to the fetched ban. */ - async fetch(guildId: string, userId: string, force = false) { + async fetch(guildId: string, userId: string, force = false): Promise { let ban: APIBan | GuildBanStructure | undefined; if (!force) { ban = await this.client.cache.bans?.get(userId, guildId); @@ -68,7 +68,7 @@ export class BanShorter extends BaseShorter { * @param force Whether to force listing bans from the API even if they exist in the cache. * @returns A Promise that resolves to an array of listed bans. */ - async list(guildId: string, query?: RESTGetAPIGuildBansQuery, force = false) { + async list(guildId: string, query?: RESTGetAPIGuildBansQuery, force = false): Promise { let bans: APIBan[] | GuildBanStructure[]; if (!force) { bans = (await this.client.cache.bans?.values(guildId)) ?? []; diff --git a/src/common/shorters/channels.ts b/src/common/shorters/channels.ts index e52a6ad..b0a0ea7 100644 --- a/src/common/shorters/channels.ts +++ b/src/common/shorters/channels.ts @@ -1,6 +1,6 @@ import type { Channels } from '../../cache/resources/channels'; import type { Overwrites } from '../../cache/resources/overwrites'; -import { type MessageStructure, Transformers } from '../../client/transformers'; +import { type MessageStructure, type ThreadChannelStructure, Transformers } from '../../client/transformers'; import { type AllChannels, BaseChannel, type GuildMember, type GuildRole, channelFrom } from '../../structures'; import { PermissionsBitField } from '../../structures/extra/Permissions'; import type { @@ -133,7 +133,7 @@ export class ChannelShorter extends BaseShorter { channelId: string, body: RESTPostAPIChannelThreadsJSONBody | RESTPostAPIGuildForumThreadsJSONBody, reason?: string, - ) { + ): Promise { return this.client.threads.create(channelId, body, reason); } @@ -197,7 +197,7 @@ export class ChannelShorter extends BaseShorter { return permissions; } - async fetchMessages(channelId: string, query?: RESTGetAPIChannelMessagesQuery) { + async fetchMessages(channelId: string, query?: RESTGetAPIChannelMessagesQuery): Promise { const result = await this.client.proxy.channels(channelId).messages.get({ query, }); diff --git a/src/common/shorters/emojis.ts b/src/common/shorters/emojis.ts index d87f338..e4bf7e4 100644 --- a/src/common/shorters/emojis.ts +++ b/src/common/shorters/emojis.ts @@ -12,7 +12,7 @@ export class EmojiShorter extends BaseShorter { * @param force Whether to force fetching emojis from the API even if they exist in the cache. * @returns A Promise that resolves to an array of emojis. */ - async list(guildId: string, force = false) { + async list(guildId: string, force = false): Promise { let emojis: APIEmoji[] | GuildEmojiStructure[]; if (!force) { emojis = (await this.client.cache.emojis?.values(guildId)) ?? []; @@ -34,7 +34,10 @@ export class EmojiShorter extends BaseShorter { * @param body The data for creating the emoji. * @returns A Promise that resolves to the created emoji. */ - async create(guildId: string, body: OmitInsert) { + async create( + guildId: string, + body: OmitInsert, + ): Promise { const bodyResolved = { ...body, image: await resolveImage(body.image) }; const emoji = await this.client.proxy.guilds(guildId).emojis.post({ body: bodyResolved, @@ -52,7 +55,7 @@ export class EmojiShorter extends BaseShorter { * @param force Whether to force fetching the emoji from the API even if it exists in the cache. * @returns A Promise that resolves to the fetched emoji. */ - async fetch(guildId: string, emojiId: string, force = false) { + async fetch(guildId: string, emojiId: string, force = false): Promise { let emoji: APIEmoji | GuildEmojiStructure | undefined; if (!force) { emoji = await this.client.cache.emojis?.get(emojiId); @@ -81,7 +84,12 @@ export class EmojiShorter extends BaseShorter { * @param reason The reason for editing the emoji. * @returns A Promise that resolves to the edited emoji. */ - async edit(guildId: string, emojiId: string, body: RESTPatchAPIGuildEmojiJSONBody, reason?: string) { + async edit( + guildId: string, + emojiId: string, + body: RESTPatchAPIGuildEmojiJSONBody, + reason?: string, + ): Promise { const emoji = await this.client.proxy.guilds(guildId).emojis(emojiId).patch({ body, reason }); await this.client.cache.emojis?.setIfNI('GuildExpressions', emoji.id!, guildId, emoji); return Transformers.GuildEmoji(this.client, emoji, guildId); diff --git a/src/common/shorters/guilds.ts b/src/common/shorters/guilds.ts index bbabc1d..6023c0b 100644 --- a/src/common/shorters/guilds.ts +++ b/src/common/shorters/guilds.ts @@ -1,7 +1,14 @@ import { resolveFiles } from '../../builders'; import type { Channels } from '../../cache/resources/channels'; -import { type GuildStructure, type StickerStructure, Transformers } from '../../client/transformers'; -import { BaseChannel, type CreateStickerBodyRequest, Guild, GuildMember, channelFrom } from '../../structures'; +import { + type AnonymousGuildStructure, + type AutoModerationRuleStructure, + type GuildMemberStructure, + type GuildStructure, + type StickerStructure, + Transformers, +} from '../../client/transformers'; +import { type AllChannels, BaseChannel, type CreateStickerBodyRequest, Guild, channelFrom } from '../../structures'; import type { APIChannel, APISticker, @@ -36,7 +43,7 @@ export class GuildShorter extends BaseShorter { * @param force Whether to force fetching the guild from the API even if it exists in the cache. * @returns A Promise that resolves to the fetched guild. */ - async fetch(id: string, force = false) { + async fetch(id: string, force = false): Promise> { return Transformers.Guild<'api'>(this.client, await this.raw(id, force)); } @@ -68,21 +75,21 @@ export class GuildShorter extends BaseShorter { return new Guild(this.client, guild); } - list(query?: RESTGetAPICurrentUserGuildsQuery) { + list(query?: RESTGetAPICurrentUserGuildsQuery): Promise { return this.client.proxy .users('@me') .guilds.get({ query }) .then(guilds => guilds.map(guild => Transformers.AnonymousGuild(this.client, { ...guild, splash: null }))); } - async fetchSelf(id: string, force = false) { + async fetchSelf(id: string, force = false): Promise { if (!force) { const self = await this.client.cache.members?.raw(this.client.botId, id); - if (self?.user) return new GuildMember(this.client, self, self.user, id); + if (self?.user) return Transformers.GuildMember(this.client, self, self.user, id); } const self = await this.client.proxy.guilds(id).members(this.client.botId).get(); await this.client.cache.members?.patch(self.user.id, id, self); - return new GuildMember(this.client, self, self.user, id); + return Transformers.GuildMember(this.client, self, self.user, id); } leave(id: string) { @@ -104,7 +111,7 @@ export class GuildShorter extends BaseShorter { * @param force Whether to force fetching channels from the API even if they exist in the cache. * @returns A Promise that resolves to an array of channels. */ - list: async (guildId: string, force = false) => { + list: async (guildId: string, force = false): Promise => { let channels: ReturnType | APIChannel[]; if (!force) { channels = (await this.client.cache.channels?.values(guildId)) ?? []; @@ -207,7 +214,7 @@ export class GuildShorter extends BaseShorter { * @param guildId The ID of the guild. * @returns A Promise that resolves to an array of auto-moderation rules. */ - list: (guildId: string) => + list: (guildId: string): Promise => this.client.proxy .guilds(guildId) ['auto-moderation'].rules.get() @@ -219,7 +226,7 @@ export class GuildShorter extends BaseShorter { * @param body The data for creating the auto-moderation rule. * @returns A Promise that resolves to the created auto-moderation rule. */ - create: (guildId: string, body: RESTPostAPIAutoModerationRuleJSONBody) => + create: (guildId: string, body: RESTPostAPIAutoModerationRuleJSONBody): Promise => this.client.proxy .guilds(guildId) ['auto-moderation'].rules.post({ body }) @@ -242,7 +249,7 @@ export class GuildShorter extends BaseShorter { * @param ruleId The ID of the rule to fetch. * @returns A Promise that resolves to the fetched auto-moderation rule. */ - fetch: (guildId: string, ruleId: string) => { + fetch: (guildId: string, ruleId: string): Promise => { return this.client.proxy .guilds(guildId) ['auto-moderation'].rules(ruleId) @@ -258,7 +265,12 @@ export class GuildShorter extends BaseShorter { * @param reason The reason for editing the rule. * @returns A Promise that resolves to the edited auto-moderation rule. */ - edit: (guildId: string, ruleId: string, body: RESTPatchAPIAutoModerationRuleJSONBody, reason?: string) => { + edit: ( + guildId: string, + ruleId: string, + body: RESTPatchAPIAutoModerationRuleJSONBody, + reason?: string, + ): Promise => { return this.client.proxy .guilds(guildId) ['auto-moderation'].rules(ruleId) @@ -278,7 +290,7 @@ export class GuildShorter extends BaseShorter { * @param guildId The ID of the guild. * @returns A Promise that resolves to an array of stickers. */ - list: async (guildId: string) => { + list: async (guildId: string): Promise => { const stickers = await this.client.proxy.guilds(guildId).stickers.get(); await this.client.cache.stickers?.set( stickers.map(st => [st.id, st] as any), @@ -294,7 +306,11 @@ export class GuildShorter extends BaseShorter { * @param reason The reason for creating the sticker. * @returns A Promise that resolves to the created sticker. */ - create: async (guildId: string, { file, ...json }: CreateStickerBodyRequest, reason?: string) => { + create: async ( + guildId: string, + { file, ...json }: CreateStickerBodyRequest, + reason?: string, + ): Promise => { const fileResolve = await resolveFiles([file]); const sticker = await this.client.proxy .guilds(guildId) @@ -311,7 +327,12 @@ export class GuildShorter extends BaseShorter { * @param reason The reason for editing the sticker. * @returns A Promise that resolves to the edited sticker. */ - edit: async (guildId: string, stickerId: string, body: RESTPatchAPIGuildStickerJSONBody, reason?: string) => { + edit: async ( + guildId: string, + stickerId: string, + body: RESTPatchAPIGuildStickerJSONBody, + reason?: string, + ): Promise => { const sticker = await this.client.proxy.guilds(guildId).stickers(stickerId).patch({ body, reason }); await this.client.cache.stickers?.setIfNI('GuildExpressions', stickerId, guildId, sticker); return Transformers.Sticker(this.client, sticker); @@ -324,7 +345,7 @@ export class GuildShorter extends BaseShorter { * @param force Whether to force fetching the sticker from the API even if it exists in the cache. * @returns A Promise that resolves to the fetched sticker. */ - fetch: async (guildId: string, stickerId: string, force = false) => { + fetch: async (guildId: string, stickerId: string, force = false): Promise => { let sticker: APISticker | StickerStructure | undefined; if (!force) { sticker = await this.client.cache.stickers?.get(stickerId); diff --git a/src/common/shorters/interaction.ts b/src/common/shorters/interaction.ts index d0c9ece..76bf081 100644 --- a/src/common/shorters/interaction.ts +++ b/src/common/shorters/interaction.ts @@ -1,5 +1,5 @@ import { BaseInteraction, Modal, type ReplyInteractionBody, resolveFiles } from '../..'; -import { Transformers } from '../../client/transformers'; +import { Transformers, type WebhookMessageStructure } from '../../client/transformers'; import type { InteractionMessageUpdateBodyRequest, MessageWebhookCreateBodyRequest } from '../types/write'; import { BaseShorter } from './base'; @@ -26,15 +26,19 @@ export class InteractionShorter extends BaseShorter { }); } - fetchResponse(token: string, messageId: string) { + fetchResponse(token: string, messageId: string): Promise { return this.client.webhooks.fetchMessage(this.client.applicationId, token, messageId); } - fetchOriginal(token: string) { + fetchOriginal(token: string): Promise { return this.fetchResponse(token, '@original'); } - async editMessage(token: string, messageId: string, body: InteractionMessageUpdateBodyRequest) { + async editMessage( + token: string, + messageId: string, + body: InteractionMessageUpdateBodyRequest, + ): Promise { const { files, ...data } = body; const parsedFiles = files ? await resolveFiles(files) : undefined; const apiMessage = await this.client.proxy @@ -47,7 +51,7 @@ export class InteractionShorter extends BaseShorter { return Transformers.WebhookMessage(this.client, apiMessage, this.client.applicationId, token); } - editOriginal(token: string, body: InteractionMessageUpdateBodyRequest) { + editOriginal(token: string, body: InteractionMessageUpdateBodyRequest): Promise { return this.editMessage(token, '@original', body); } @@ -63,7 +67,7 @@ export class InteractionShorter extends BaseShorter { return this.deleteResponse(token, '@original'); } - async followup(token: string, { files, ...body }: MessageWebhookCreateBodyRequest) { + async followup(token: string, { files, ...body }: MessageWebhookCreateBodyRequest): Promise { const parsedFiles = files ? await resolveFiles(files) : undefined; const apiMessage = await this.client.proxy .webhooks(this.client.applicationId)(token) diff --git a/src/common/shorters/members.ts b/src/common/shorters/members.ts index 9d7c4ae..ef17e0f 100644 --- a/src/common/shorters/members.ts +++ b/src/common/shorters/members.ts @@ -1,4 +1,9 @@ -import { type GuildMemberStructure, Transformers, type VoiceStateStructure } from '../../client/transformers'; +import { + type GuildMemberStructure, + type GuildRoleStructure, + Transformers, + type VoiceStateStructure, +} from '../../client/transformers'; import { PermissionsBitField } from '../../structures/extra/Permissions'; import { type APIGuildMember, @@ -19,7 +24,7 @@ export class MemberShorter extends BaseShorter { * @param resolve The GuildMemberResolvable to resolve. * @returns A Promise that resolves to the resolved member. */ - async resolve(guildId: string, resolve: GuildMemberResolvable) { + async resolve(guildId: string, resolve: GuildMemberResolvable): Promise { if (typeof resolve === 'string') { const match: { id?: string } | undefined = resolve.match(FormattingPatterns.User)?.groups; if (match?.id) { @@ -48,7 +53,7 @@ export class MemberShorter extends BaseShorter { * @param query The query parameters for searching members. * @returns A Promise that resolves to an array of matched members. */ - async search(guildId: string, query?: RESTGetAPIGuildMembersSearchQuery) { + async search(guildId: string, query?: RESTGetAPIGuildMembersSearchQuery): Promise { const members = await this.client.proxy.guilds(guildId).members.search.get({ query, }); @@ -100,7 +105,12 @@ export class MemberShorter extends BaseShorter { * @param reason The reason for editing the member. * @returns A Promise that resolves to the edited member. */ - async edit(guildId: string, memberId: string, body: RESTPatchAPIGuildMemberJSONBody, reason?: string) { + async edit( + guildId: string, + memberId: string, + body: RESTPatchAPIGuildMemberJSONBody, + reason?: string, + ): Promise { const member = await this.client.proxy.guilds(guildId).members(memberId).patch({ body, reason }); await this.client.cache.members?.setIfNI('GuildMembers', memberId, guildId, member); return Transformers.GuildMember(this.client, member, member.user, guildId); @@ -113,7 +123,11 @@ export class MemberShorter extends BaseShorter { * @param body The request body for adding the member. * @returns A Promise that resolves to the added member. */ - async add(guildId: string, memberId: string, body: RESTPutAPIGuildMemberJSONBody) { + async add( + guildId: string, + memberId: string, + body: RESTPutAPIGuildMemberJSONBody, + ): Promise { const member = await this.client.proxy.guilds(guildId).members(memberId).put({ body, }); @@ -135,7 +149,7 @@ export class MemberShorter extends BaseShorter { * @param force Whether to force fetching the member from the API even if it exists in the cache. * @returns A Promise that resolves to the fetched member. */ - async fetch(guildId: string, memberId: string, force = false) { + async fetch(guildId: string, memberId: string, force = false): Promise { const member = await this.raw(guildId, memberId, force); return Transformers.GuildMember(this.client, member, member.user, guildId); } @@ -159,7 +173,7 @@ export class MemberShorter extends BaseShorter { * @param force Whether to force listing members from the API even if they exist in the cache. * @returns A Promise that resolves to an array of listed members. */ - async list(guildId: string, query?: RESTGetAPIGuildMembersQuery, force = false) { + async list(guildId: string, query?: RESTGetAPIGuildMembersQuery, force = false): Promise { let members: APIGuildMember[] | GuildMemberStructure[]; if (!force) { members = (await this.client.cache.members?.values(guildId)) ?? []; @@ -191,7 +205,7 @@ export class MemberShorter extends BaseShorter { return this.client.proxy.guilds(guildId).members(memberId).roles(id).delete(); } - async listRoles(guildId: string, memberId: string, force = false) { + async listRoles(guildId: string, memberId: string, force = false): Promise { if (!force) { const member = await this.client.cache.members?.get(memberId, guildId); if (member) { @@ -206,7 +220,7 @@ export class MemberShorter extends BaseShorter { return allRoles.filter(role => rolesId.includes(role.id)); } - async sortRoles(guildId: string, memberId: string, force = false) { + async sortRoles(guildId: string, memberId: string, force = false): Promise { const roles = await this.listRoles(guildId, memberId, force); return roles.sort((a, b) => b.position - a.position); } @@ -241,7 +255,7 @@ export class MemberShorter extends BaseShorter { * @param time The time in seconds to timeout the member for. * @param reason The reason for the timeout. */ - timeout(guildId: string, memberId: string, time: number | null, reason?: string) { + timeout(guildId: string, memberId: string, time: number | null, reason?: string): Promise { return this.edit( guildId, memberId, diff --git a/src/common/shorters/messages.ts b/src/common/shorters/messages.ts index ecf967c..a57579e 100644 --- a/src/common/shorters/messages.ts +++ b/src/common/shorters/messages.ts @@ -8,12 +8,12 @@ import type { } from '../../types'; import type { ValidAnswerId } from '../../api/Routes/channels'; -import { Transformers } from '../../client'; +import { type MessageStructure, type ThreadChannelStructure, Transformers, type UserStructure } from '../../client'; import type { MessageCreateBodyRequest, MessageUpdateBodyRequest } from '../types/write'; import { BaseShorter } from './base'; export class MessageShorter extends BaseShorter { - async write(channelId: string, { files, ...body }: MessageCreateBodyRequest) { + async write(channelId: string, { files, ...body }: MessageCreateBodyRequest): Promise { const parsedFiles = files ? await resolveFiles(files) : undefined; const transformedBody = MessagesMethods.transformMessageBody( @@ -33,7 +33,11 @@ export class MessageShorter extends BaseShorter { }); } - async edit(messageId: string, channelId: string, { files, ...body }: MessageUpdateBodyRequest) { + async edit( + messageId: string, + channelId: string, + { files, ...body }: MessageUpdateBodyRequest, + ): Promise { const parsedFiles = files ? await resolveFiles(files) : undefined; return this.client.proxy .channels(channelId) @@ -48,7 +52,7 @@ export class MessageShorter extends BaseShorter { }); } - crosspost(messageId: string, channelId: string, reason?: string) { + crosspost(messageId: string, channelId: string, reason?: string): Promise { return this.client.proxy .channels(channelId) .messages(messageId) @@ -70,7 +74,7 @@ export class MessageShorter extends BaseShorter { }); } - async fetch(messageId: string, channelId: string, force = false) { + async fetch(messageId: string, channelId: string, force = false): Promise { if (!force) { const message = await this.client.cache.messages?.get(messageId); if (message) return message; @@ -97,11 +101,11 @@ export class MessageShorter extends BaseShorter { channelId: string, messageId: string, options: RESTPostAPIChannelMessagesThreadsJSONBody & { reason?: string }, - ) { + ): Promise { return this.client.threads.fromMessage(channelId, messageId, options); } - endPoll(channelId: string, messageId: string) { + endPoll(channelId: string, messageId: string): Promise { return this.client.proxy .channels(channelId) .polls(messageId) @@ -109,7 +113,7 @@ export class MessageShorter extends BaseShorter { .then(message => Transformers.Message(this.client, message)); } - getAnswerVoters(channelId: string, messageId: string, answerId: ValidAnswerId) { + getAnswerVoters(channelId: string, messageId: string, answerId: ValidAnswerId): Promise { return this.client.proxy .channels(channelId) .polls(messageId) @@ -118,7 +122,7 @@ export class MessageShorter extends BaseShorter { .then(data => data.users.map(user => Transformers.User(this.client, user))); } - list(channelId: string, fetchOptions: RESTGetAPIChannelMessagesQuery) { + list(channelId: string, fetchOptions: RESTGetAPIChannelMessagesQuery): Promise { return this.client.proxy .channels(channelId) .messages.get({ query: fetchOptions }) diff --git a/src/common/shorters/roles.ts b/src/common/shorters/roles.ts index 81b8a47..31fad86 100644 --- a/src/common/shorters/roles.ts +++ b/src/common/shorters/roles.ts @@ -1,4 +1,4 @@ -import { Transformers } from '../../client/transformers'; +import { type GuildRoleStructure, Transformers } from '../../client/transformers'; import type { APIRole, RESTPatchAPIGuildRoleJSONBody, @@ -15,13 +15,13 @@ export class RoleShorter extends BaseShorter { * @param reason The reason for creating the role. * @returns A Promise that resolves when the role is created. */ - async create(guildId: string, body: RESTPostAPIGuildRoleJSONBody, reason?: string) { + async create(guildId: string, body: RESTPostAPIGuildRoleJSONBody, reason?: string): Promise { const res = await this.client.proxy.guilds(guildId).roles.post({ body, reason }); await this.client.cache.roles?.setIfNI('Guilds', res.id, guildId, res); return Transformers.GuildRole(this.client, res, guildId); } - async fetch(guildId: string, roleId: string, force = false) { + async fetch(guildId: string, roleId: string, force = false): Promise { const role = await this.raw(guildId, roleId, force); return Transformers.GuildRole(this.client, role, guildId); } @@ -43,7 +43,7 @@ export class RoleShorter extends BaseShorter { * @param force Whether to force fetching roles from the API even if they exist in the cache. * @returns A Promise that resolves to an array of roles. */ - async list(guildId: string, force = false) { + async list(guildId: string, force = false): Promise { const roles = await this.listRaw(guildId, force); return roles.map(r => Transformers.GuildRole(this.client, r, guildId)); } @@ -72,7 +72,12 @@ export class RoleShorter extends BaseShorter { * @param reason The reason for editing the role. * @returns A Promise that resolves when the role is edited. */ - async edit(guildId: string, roleId: string, body: RESTPatchAPIGuildRoleJSONBody, reason?: string) { + async edit( + guildId: string, + roleId: string, + body: RESTPatchAPIGuildRoleJSONBody, + reason?: string, + ): Promise { const res = await this.client.proxy.guilds(guildId).roles(roleId).patch({ body, reason }); await this.client.cache.roles?.setIfNI('Guilds', roleId, guildId, res); return Transformers.GuildRole(this.client, res, guildId); @@ -85,7 +90,7 @@ export class RoleShorter extends BaseShorter { * @param reason The reason for deleting the role. * @returns A Promise that resolves when the role is deleted. */ - async delete(guildId: string, roleId: string, reason?: string) { + async delete(guildId: string, roleId: string, reason?: string): Promise { const res = await this.client.proxy.guilds(guildId).roles(roleId).delete({ reason }); this.client.cache.roles?.removeIfNI('Guilds', roleId, guildId); return Transformers.GuildRole(this.client, res, guildId); @@ -97,7 +102,7 @@ export class RoleShorter extends BaseShorter { * @param body The data to update the positions of roles with. * @returns A Promise that resolves to an array of edited roles. */ - async editPositions(guildId: string, body: RESTPatchAPIGuildRolePositionsJSONBody) { + async editPositions(guildId: string, body: RESTPatchAPIGuildRolePositionsJSONBody): Promise { const roles = await this.client.proxy.guilds(guildId).roles.patch({ body, }); diff --git a/src/common/shorters/templates.ts b/src/common/shorters/templates.ts index 3662f22..d813766 100644 --- a/src/common/shorters/templates.ts +++ b/src/common/shorters/templates.ts @@ -1,30 +1,30 @@ -import { Transformers } from '../../client/transformers'; +import { type GuildTemplateStructure, Transformers } from '../../client/transformers'; import type { RESTPatchAPIGuildTemplateJSONBody, RESTPostAPIGuildTemplatesJSONBody } from '../../types'; import { BaseShorter } from './base'; export class TemplateShorter extends BaseShorter { - fetch(code: string) { + fetch(code: string): Promise { return this.client.proxy.guilds .templates(code) .get() .then(template => Transformers.GuildTemplate(this.client, template)); } - list(guildId: string) { + list(guildId: string): Promise { return this.client.proxy .guilds(guildId) .templates.get() .then(list => list.map(template => Transformers.GuildTemplate(this.client, template))); } - create(guildId: string, body: RESTPostAPIGuildTemplatesJSONBody) { + create(guildId: string, body: RESTPostAPIGuildTemplatesJSONBody): Promise { return this.client.proxy .guilds(guildId) .templates.post({ body }) .then(template => Transformers.GuildTemplate(this.client, template)); } - sync(guildId: string, code: string) { + sync(guildId: string, code: string): Promise { return this.client.proxy .guilds(guildId) .templates(code) @@ -32,7 +32,7 @@ export class TemplateShorter extends BaseShorter { .then(template => Transformers.GuildTemplate(this.client, template)); } - edit(guildId: string, code: string, body: RESTPatchAPIGuildTemplateJSONBody) { + edit(guildId: string, code: string, body: RESTPatchAPIGuildTemplateJSONBody): Promise { return this.client.proxy .guilds(guildId) .templates(code) @@ -40,7 +40,7 @@ export class TemplateShorter extends BaseShorter { .then(template => Transformers.GuildTemplate(this.client, template)); } - delete(guildId: string, code: string) { + delete(guildId: string, code: string): Promise { return this.client.proxy .guilds(guildId) .templates(code) diff --git a/src/common/shorters/threads.ts b/src/common/shorters/threads.ts index f868dd4..016aec9 100644 --- a/src/common/shorters/threads.ts +++ b/src/common/shorters/threads.ts @@ -24,7 +24,7 @@ export class ThreadShorter extends BaseShorter { channelId: string, body: RESTPostAPIChannelThreadsJSONBody | RESTPostAPIGuildForumThreadsJSONBody, reason?: string, - ) { + ): Promise { return ( this.client.proxy .channels(channelId) @@ -46,7 +46,7 @@ export class ThreadShorter extends BaseShorter { channelId: string, messageId: string, options: RESTPostAPIChannelMessagesThreadsJSONBody & { reason?: string }, - ) { + ): Promise { const { reason, ...body } = options; return this.client.proxy @@ -67,12 +67,12 @@ export class ThreadShorter extends BaseShorter { return this.client.proxy.channels(threadId)['thread-members']('@me').delete(); } - lock(threadId: string, locked = true, reason?: string) { + lock(threadId: string, locked = true, reason?: string): Promise { return this.edit(threadId, { locked }, reason).then(x => channelFrom(x, this.client) as ThreadChannelStructure); } - edit(threadId: string, body: RESTPatchAPIChannelJSONBody, reason?: string) { - return this.client.channels.edit(threadId, body, { reason }); + async edit(threadId: string, body: RESTPatchAPIChannelJSONBody, reason?: string): Promise { + return (await this.client.channels.edit(threadId, body, { reason })) as ThreadChannelStructure; } removeMember(threadId: string, memberId: string) { @@ -106,7 +106,11 @@ export class ThreadShorter extends BaseShorter { channelId: string, type: 'public' | 'private', query?: RESTGetAPIChannelThreadsArchivedQuery, - ) { + ): Promise<{ + threads: ThreadChannelStructure[]; + members: GetAPIChannelThreadMemberResult[]; + hasMore: boolean; + }> { const data = await this.client.proxy.channels(channelId).threads.archived[type].get({ query }); return { @@ -116,7 +120,14 @@ export class ThreadShorter extends BaseShorter { }; } - async listJoinedArchivedPrivate(channelId: string, query?: RESTGetAPIChannelThreadsArchivedQuery) { + async listJoinedArchivedPrivate( + channelId: string, + query?: RESTGetAPIChannelThreadsArchivedQuery, + ): Promise<{ + threads: ThreadChannelStructure[]; + members: GetAPIChannelThreadMemberResult[]; + hasMore: boolean; + }> { const data = await this.client.proxy.channels(channelId).users('@me').threads.archived.private.get({ query }); return { threads: data.threads.map(thread => channelFrom(thread, this.client) as ThreadChannelStructure), diff --git a/src/common/shorters/users.ts b/src/common/shorters/users.ts index 84de776..5bfd210 100644 --- a/src/common/shorters/users.ts +++ b/src/common/shorters/users.ts @@ -1,10 +1,15 @@ -import { type DMChannelStructure, Transformers } from '../../client/transformers'; +import { + type DMChannelStructure, + type MessageStructure, + Transformers, + type UserStructure, +} from '../../client/transformers'; import { BaseChannel } from '../../structures'; import type { MessageCreateBodyRequest } from '../types/write'; import { BaseShorter } from './base'; export class UsersShorter extends BaseShorter { - async createDM(userId: string, force = false) { + async createDM(userId: string, force = false): Promise { if (!force) { const dm = await this.client.cache.channels?.get(userId); if (dm) return dm as DMChannelStructure; @@ -16,13 +21,13 @@ export class UsersShorter extends BaseShorter { return Transformers.DMChannel(this.client, data); } - async deleteDM(userId: string, reason?: string) { + async deleteDM(userId: string, reason?: string): Promise { const res = await this.client.proxy.channels(userId).delete({ reason }); await this.client.cache.channels?.removeIfNI(BaseChannel.__intent__('@me'), res.id, '@me'); return Transformers.DMChannel(this.client, res); } - async fetch(userId: string, force = false) { + async fetch(userId: string, force = false): Promise { return Transformers.User(this.client, await this.raw(userId, force)); } @@ -37,7 +42,7 @@ export class UsersShorter extends BaseShorter { return data; } - async write(userId: string, body: MessageCreateBodyRequest) { + async write(userId: string, body: MessageCreateBodyRequest): Promise { return (await this.client.users.createDM(userId)).messages.write(body); } } diff --git a/src/common/shorters/webhook.ts b/src/common/shorters/webhook.ts index dbeb0bc..fc5106e 100644 --- a/src/common/shorters/webhook.ts +++ b/src/common/shorters/webhook.ts @@ -1,5 +1,5 @@ import { resolveFiles } from '../../builders'; -import { Transformers } from '../../client/transformers'; +import { Transformers, type WebhookMessageStructure, type WebhookStructure } from '../../client/transformers'; import { type MessageWebhookMethodEditParams, type MessageWebhookMethodWriteParams, @@ -15,7 +15,7 @@ import type { import { BaseShorter } from './base'; export class WebhookShorter extends BaseShorter { - async create(channelId: string, body: RESTPostAPIChannelWebhookJSONBody) { + async create(channelId: string, body: RESTPostAPIChannelWebhookJSONBody): Promise { const webhook = await this.client.proxy.channels(channelId).webhooks.post({ body, }); @@ -45,7 +45,7 @@ export class WebhookShorter extends BaseShorter { webhookId: string, body: RESTPatchAPIWebhookWithTokenJSONBody | RESTPatchAPIWebhookJSONBody, options: WebhookShorterOptionalParams, - ) { + ): Promise { if (options.token) { return this.client.proxy .webhooks(webhookId)(options.token) @@ -64,7 +64,7 @@ export class WebhookShorter extends BaseShorter { * @param token The token of the webhook (optional). * @returns A Promise that resolves to the fetched webhook. */ - async fetch(webhookId: string, token?: string) { + async fetch(webhookId: string, token?: string): Promise { let webhook: APIWebhook; if (token) { webhook = await this.client.proxy.webhooks(webhookId)(token).get({ auth: false }); @@ -81,7 +81,11 @@ export class WebhookShorter extends BaseShorter { * @param data The data for writing the message. * @returns A Promise that resolves to the written message. */ - async writeMessage(webhookId: string, token: string, { body: data, ...payload }: MessageWebhookMethodWriteParams) { + async writeMessage( + webhookId: string, + token: string, + { body: data, ...payload }: MessageWebhookMethodWriteParams, + ): Promise { const { files, ...body } = data; const parsedFiles = files ? await resolveFiles(files) : undefined; const transformedBody = MessagesMethods.transformMessageBody( @@ -107,7 +111,7 @@ export class WebhookShorter extends BaseShorter { webhookId: string, token: string, { messageId, body: data, ...json }: MessageWebhookMethodEditParams, - ) { + ): Promise { const { files, ...body } = data; const parsedFiles = files ? await resolveFiles(files) : undefined; const transformedBody = MessagesMethods.transformMessageBody( @@ -142,7 +146,12 @@ export class WebhookShorter extends BaseShorter { * @param threadId The ID of the thread the message belongs to. * @returns A Promise that resolves to the fetched message */ - async fetchMessage(webhookId: string, token: string, messageId: string, threadId?: string) { + async fetchMessage( + webhookId: string, + token: string, + messageId: string, + threadId?: string, + ): Promise { const message = await this.client.proxy .webhooks(webhookId)(token) .messages(messageId) @@ -150,12 +159,12 @@ export class WebhookShorter extends BaseShorter { return Transformers.WebhookMessage(this.client, message, webhookId, token); } - async listFromGuild(guildId: string) { + async listFromGuild(guildId: string): Promise { const webhooks = await this.client.proxy.guilds(guildId).webhooks.get(); return webhooks.map(webhook => Transformers.Webhook(this.client, webhook)); } - async listFromChannel(channelId: string) { + async listFromChannel(channelId: string): Promise { const webhooks = await this.client.proxy.channels(channelId).webhooks.get(); return webhooks.map(webhook => Transformers.Webhook(this.client, webhook)); } diff --git a/src/components/componentcontext.ts b/src/components/componentcontext.ts index f11dbfd..76a40d1 100644 --- a/src/components/componentcontext.ts +++ b/src/components/componentcontext.ts @@ -9,7 +9,13 @@ import type { StringSelectMenuInteraction, UserSelectMenuInteraction, } from '..'; -import type { GuildMemberStructure, GuildStructure } from '../client/transformers'; +import type { + GuildMemberStructure, + GuildStructure, + InteractionGuildMemberStructure, + UserStructure, + WebhookMessageStructure, +} from '../client/transformers'; import type { CommandMetadata, ExtendContext, GlobalMetadata, RegisteredMiddlewares, UsingClient } from '../commands'; import { BaseContext } from '../commands/basecontext'; import type { @@ -19,6 +25,7 @@ import type { MakeRequired, ModalCreateBodyRequest, UnionToTuple, + When, } from '../common'; import { ComponentType, MessageFlags } from '../types'; @@ -70,7 +77,10 @@ export class ComponentContext< * @param body - The body of the response. * @param fetchReply - Whether to fetch the reply or not. */ - write(body: InteractionCreateBodyRequest, fetchReply?: FR) { + write( + body: InteractionCreateBodyRequest, + fetchReply?: FR, + ): Promise> { return this.interaction.write(body, fetchReply); } @@ -78,7 +88,10 @@ export class ComponentContext< * Defers the reply to the interaction. * @param ephemeral - Whether the reply should be ephemeral or not. */ - deferReply(ephemeral = false, fetchReply?: FR) { + deferReply( + ephemeral = false, + fetchReply?: FR, + ): Promise> { return this.interaction.deferReply(ephemeral ? MessageFlags.Ephemeral : undefined, fetchReply); } @@ -93,7 +106,7 @@ export class ComponentContext< * Edits the response of the interaction. * @param body - The updated body of the response. */ - editResponse(body: InteractionMessageUpdateBodyRequest) { + editResponse(body: InteractionMessageUpdateBodyRequest): Promise { return this.interaction.editResponse(body); } @@ -113,14 +126,14 @@ export class ComponentContext< editOrReply( body: InteractionCreateBodyRequest | InteractionMessageUpdateBodyRequest, fetchReply?: FR, - ) { + ): Promise> { return this.interaction.editOrReply(body as InteractionCreateBodyRequest, fetchReply); } /** * @returns A Promise that resolves to the fetched message */ - fetchResponse() { + fetchResponse(): Promise { return this.interaction.fetchResponse(); } @@ -204,14 +217,14 @@ export class ComponentContext< /** * Gets the author of the interaction. */ - get author() { + get author(): UserStructure { return this.interaction.user; } /** * Gets the member of the interaction. */ - get member() { + get member(): InteractionGuildMemberStructure | undefined { return this.interaction.member; } diff --git a/src/components/modalcontext.ts b/src/components/modalcontext.ts index aaf225c..a0d10d6 100644 --- a/src/components/modalcontext.ts +++ b/src/components/modalcontext.ts @@ -1,5 +1,11 @@ import type { AllChannels, Interaction, ModalCommand, ModalSubmitInteraction, ReturnCache } from '..'; -import type { GuildMemberStructure, GuildStructure } from '../client/transformers'; +import type { + GuildMemberStructure, + GuildStructure, + InteractionGuildMemberStructure, + UserStructure, + WebhookMessageStructure, +} from '../client/transformers'; import type { CommandMetadata, ExtendContext, GlobalMetadata, RegisteredMiddlewares, UsingClient } from '../commands'; import { BaseContext } from '../commands/basecontext'; import type { @@ -8,6 +14,7 @@ import type { MakeRequired, ModalCreateBodyRequest, UnionToTuple, + When, } from '../common'; import { MessageFlags } from '../types'; @@ -54,7 +61,10 @@ export class ModalContext extends * @param body - The body of the response. * @param fetchReply - Whether to fetch the reply or not. */ - write(body: InteractionCreateBodyRequest, fetchReply?: FR) { + write( + body: InteractionCreateBodyRequest, + fetchReply?: FR, + ): Promise> { return this.interaction.write(body, fetchReply); } @@ -62,7 +72,10 @@ export class ModalContext extends * Defers the reply to the interaction. * @param ephemeral - Whether the reply should be ephemeral or not. */ - deferReply(ephemeral = false, fetchReply?: FR) { + deferReply( + ephemeral = false, + fetchReply?: FR, + ): Promise> { return this.interaction.deferReply(ephemeral ? MessageFlags.Ephemeral : undefined, fetchReply); } @@ -70,7 +83,7 @@ export class ModalContext extends * Edits the response of the interaction. * @param body - The updated body of the response. */ - editResponse(body: InteractionMessageUpdateBodyRequest) { + editResponse(body: InteractionMessageUpdateBodyRequest): Promise { return this.interaction.editResponse(body); } @@ -82,14 +95,14 @@ export class ModalContext extends editOrReply( body: InteractionCreateBodyRequest | InteractionMessageUpdateBodyRequest, fetchReply?: FR, - ) { + ): Promise> { return this.interaction.editOrReply(body as InteractionCreateBodyRequest, fetchReply); } /** * @returns A Promise that resolves to the fetched message */ - fetchResponse() { + fetchResponse(): Promise { return this.interaction.fetchResponse(); } @@ -174,14 +187,14 @@ export class ModalContext extends /** * Gets the author of the interaction. */ - get author() { + get author(): UserStructure { return this.interaction.user; } /** * Gets the member of the interaction. */ - get member() { + get member(): InteractionGuildMemberStructure | undefined { return this.interaction.member; } diff --git a/src/events/hooks/auto_moderation.ts b/src/events/hooks/auto_moderation.ts index e65ae49..42982e9 100644 --- a/src/events/hooks/auto_moderation.ts +++ b/src/events/hooks/auto_moderation.ts @@ -1,4 +1,4 @@ -import { Transformers } from '../../client/transformers'; +import { type AutoModerationRuleStructure, Transformers } from '../../client/transformers'; import type { UsingClient } from '../../commands'; import { toCamelCase } from '../../common'; import type { @@ -15,14 +15,23 @@ export const AUTO_MODERATION_ACTION_EXECUTION = ( return toCamelCase(data); }; -export const AUTO_MODERATION_RULE_CREATE = (self: UsingClient, data: GatewayAutoModerationRuleCreateDispatchData) => { +export const AUTO_MODERATION_RULE_CREATE = ( + self: UsingClient, + data: GatewayAutoModerationRuleCreateDispatchData, +): AutoModerationRuleStructure => { return Transformers.AutoModerationRule(self, data); }; -export const AUTO_MODERATION_RULE_DELETE = (self: UsingClient, data: GatewayAutoModerationRuleDeleteDispatchData) => { +export const AUTO_MODERATION_RULE_DELETE = ( + self: UsingClient, + data: GatewayAutoModerationRuleDeleteDispatchData, +): AutoModerationRuleStructure => { return Transformers.AutoModerationRule(self, data); }; -export const AUTO_MODERATION_RULE_UPDATE = (self: UsingClient, data: GatewayAutoModerationRuleUpdateDispatchData) => { +export const AUTO_MODERATION_RULE_UPDATE = ( + self: UsingClient, + data: GatewayAutoModerationRuleUpdateDispatchData, +): AutoModerationRuleStructure => { return Transformers.AutoModerationRule(self, data); }; diff --git a/src/events/hooks/channel.ts b/src/events/hooks/channel.ts index 11b05e1..0b11738 100644 --- a/src/events/hooks/channel.ts +++ b/src/events/hooks/channel.ts @@ -9,11 +9,11 @@ import type { UsingClient } from '../../commands'; import { toCamelCase } from '../../common'; import { type AllChannels, channelFrom } from '../../structures'; -export const CHANNEL_CREATE = (self: UsingClient, data: GatewayChannelCreateDispatchData) => { +export const CHANNEL_CREATE = (self: UsingClient, data: GatewayChannelCreateDispatchData): AllChannels => { return channelFrom(data, self); }; -export const CHANNEL_DELETE = (self: UsingClient, data: GatewayChannelDeleteDispatchData) => { +export const CHANNEL_DELETE = (self: UsingClient, data: GatewayChannelDeleteDispatchData): AllChannels => { return channelFrom(data, self); }; diff --git a/src/events/hooks/custom.ts b/src/events/hooks/custom.ts index 494d224..9e1973b 100644 --- a/src/events/hooks/custom.ts +++ b/src/events/hooks/custom.ts @@ -1,24 +1,30 @@ -import { type ClientUserStructure, Transformers } from '../../client/transformers'; +import { type ClientUserStructure, type GuildStructure, Transformers } from '../../client/transformers'; import type { UsingClient } from '../../commands'; -import type { GatewayRawGuildCreateDispatch, GatewayRawGuildDeleteDispatch } from '../../types'; +import type { APIUnavailableGuild, GatewayRawGuildCreateDispatch, GatewayRawGuildDeleteDispatch } from '../../types'; -export const BOT_READY = (_self: UsingClient, me: ClientUserStructure) => { +export const BOT_READY = (_self: UsingClient, me: ClientUserStructure): ClientUserStructure => { return me; }; -export const WORKER_READY = (_self: UsingClient, me: ClientUserStructure) => { +export const WORKER_READY = (_self: UsingClient, me: ClientUserStructure): ClientUserStructure => { return me; }; -export const WORKER_SHARDS_CONNECTED = (_self: UsingClient, me: ClientUserStructure) => { +export const WORKER_SHARDS_CONNECTED = (_self: UsingClient, me: ClientUserStructure): ClientUserStructure => { return me; }; -export const RAW_GUILD_CREATE = (self: UsingClient, data: GatewayRawGuildCreateDispatch['d']) => { +export const RAW_GUILD_CREATE = ( + self: UsingClient, + data: GatewayRawGuildCreateDispatch['d'], +): GuildStructure<'create'> => { return Transformers.Guild<'create'>(self, data); }; -export const RAW_GUILD_DELETE = async (self: UsingClient, data: GatewayRawGuildDeleteDispatch['d']) => { +export const RAW_GUILD_DELETE = async ( + self: UsingClient, + data: GatewayRawGuildDeleteDispatch['d'], +): Promise | APIUnavailableGuild> => { return (await self.cache.guilds?.get(data.id)) ?? data; }; diff --git a/src/events/hooks/dispatch.ts b/src/events/hooks/dispatch.ts index 4717251..1d47fb7 100644 --- a/src/events/hooks/dispatch.ts +++ b/src/events/hooks/dispatch.ts @@ -1,8 +1,8 @@ -import { Transformers } from '../../client/transformers'; +import { type ClientUserStructure, Transformers } from '../../client/transformers'; import type { UsingClient } from '../../commands'; import type { GatewayDispatchPayload, GatewayReadyDispatchData, GatewayResumedDispatch } from '../../types'; -export const READY = (self: UsingClient, data: GatewayReadyDispatchData) => { +export const READY = (self: UsingClient, data: GatewayReadyDispatchData): ClientUserStructure => { return Transformers.ClientUser(self, data.user, data.application); }; diff --git a/src/events/hooks/entitlement.ts b/src/events/hooks/entitlement.ts index 97b3fe7..ef673ff 100644 --- a/src/events/hooks/entitlement.ts +++ b/src/events/hooks/entitlement.ts @@ -1,15 +1,15 @@ -import { Transformers } from '../../client'; +import { type EntitlementStructure, Transformers } from '../../client'; import type { UsingClient } from '../../commands'; import type { APIEntitlement } from '../../types'; -export const ENTITLEMENT_CREATE = (client: UsingClient, data: APIEntitlement) => { +export const ENTITLEMENT_CREATE = (client: UsingClient, data: APIEntitlement): EntitlementStructure => { return Transformers.Entitlement(client, data); }; -export const ENTITLEMENT_UPDATE = (client: UsingClient, data: APIEntitlement) => { +export const ENTITLEMENT_UPDATE = (client: UsingClient, data: APIEntitlement): EntitlementStructure => { return Transformers.Entitlement(client, data); }; -export const ENTITLEMENT_DELETE = (client: UsingClient, data: APIEntitlement) => { +export const ENTITLEMENT_DELETE = (client: UsingClient, data: APIEntitlement): EntitlementStructure => { return Transformers.Entitlement(client, data); }; diff --git a/src/events/hooks/guild.ts b/src/events/hooks/guild.ts index 9195424..ef68bbd 100644 --- a/src/events/hooks/guild.ts +++ b/src/events/hooks/guild.ts @@ -1,12 +1,16 @@ import { + type GuildEmojiStructure, type GuildMemberStructure, type GuildRoleStructure, type GuildStructure, + type StickerStructure, Transformers, + type UserStructure, } from '../../client/transformers'; import type { UsingClient } from '../../commands'; -import { toCamelCase } from '../../common'; +import { type ObjectToLower, toCamelCase } from '../../common'; import type { + APIUnavailableGuild, GatewayGuildAuditLogEntryCreateDispatchData, GatewayGuildBanAddDispatchData, GatewayGuildBanRemoveDispatchData, @@ -34,23 +38,41 @@ export const GUILD_AUDIT_LOG_ENTRY_CREATE = (_self: UsingClient, data: GatewayGu return toCamelCase(data); }; -export const GUILD_BAN_ADD = (self: UsingClient, data: GatewayGuildBanAddDispatchData) => { +export const GUILD_BAN_ADD = ( + self: UsingClient, + data: GatewayGuildBanAddDispatchData, +): ObjectToLower> & { + user: UserStructure; +} => { return { ...toCamelCase(data), user: Transformers.User(self, data.user) }; }; -export const GUILD_BAN_REMOVE = (self: UsingClient, data: GatewayGuildBanRemoveDispatchData) => { +export const GUILD_BAN_REMOVE = ( + self: UsingClient, + data: GatewayGuildBanRemoveDispatchData, +): ObjectToLower> & { + user: UserStructure; +} => { return { ...toCamelCase(data), user: Transformers.User(self, data.user) }; }; -export const GUILD_CREATE = (self: UsingClient, data: GatewayGuildCreateDispatchData) => { +export const GUILD_CREATE = (self: UsingClient, data: GatewayGuildCreateDispatchData): GuildStructure<'create'> => { return Transformers.Guild<'create'>(self, data); }; -export const GUILD_DELETE = async (self: UsingClient, data: GatewayGuildDeleteDispatchData) => { +export const GUILD_DELETE = async ( + self: UsingClient, + data: GatewayGuildDeleteDispatchData, +): Promise | APIUnavailableGuild> => { return (await self.cache.guilds?.get(data.id)) ?? data; }; -export const GUILD_EMOJIS_UPDATE = (self: UsingClient, data: GatewayGuildEmojisUpdateDispatchData) => { +export const GUILD_EMOJIS_UPDATE = ( + self: UsingClient, + data: GatewayGuildEmojisUpdateDispatchData, +): ObjectToLower> & { + emojis: GuildEmojiStructure[]; +} => { return { ...toCamelCase(data), emojis: data.emojis.map(x => Transformers.GuildEmoji(self, x, data.guild_id)), @@ -61,11 +83,20 @@ export const GUILD_INTEGRATIONS_UPDATE = (_self: UsingClient, data: GatewayGuild return toCamelCase(data); }; -export const GUILD_MEMBER_ADD = (self: UsingClient, data: GatewayGuildMemberAddDispatchData) => { +export const GUILD_MEMBER_ADD = (self: UsingClient, data: GatewayGuildMemberAddDispatchData): GuildMemberStructure => { return Transformers.GuildMember(self, data, data.user, data.guild_id); }; -export const GUILD_MEMBER_REMOVE = async (self: UsingClient, data: GatewayGuildMemberRemoveDispatchData) => { +export const GUILD_MEMBER_REMOVE = async ( + self: UsingClient, + data: GatewayGuildMemberRemoveDispatchData, +): Promise< + | GuildMemberStructure + | { + user: UserStructure; + guildId: string; + } +> => { return ( (await self.cache.members?.get(data.user.id, data.guild_id)) ?? { ...toCamelCase(data), @@ -74,7 +105,12 @@ export const GUILD_MEMBER_REMOVE = async (self: UsingClient, data: GatewayGuildM ); }; -export const GUILD_MEMBERS_CHUNK = (self: UsingClient, data: GatewayGuildMembersChunkDispatchData) => { +export const GUILD_MEMBERS_CHUNK = ( + self: UsingClient, + data: GatewayGuildMembersChunkDispatchData, +): ObjectToLower> & { + members: GuildMemberStructure[]; +} => { return { ...toCamelCase(data), members: data.members.map(x => Transformers.GuildMember(self, x, x.user, data.guild_id)), @@ -124,11 +160,14 @@ export const GUILD_SCHEDULED_EVENT_USER_REMOVE = ( return toCamelCase(data); }; -export const GUILD_ROLE_CREATE = (self: UsingClient, data: GatewayGuildRoleCreateDispatchData) => { +export const GUILD_ROLE_CREATE = (self: UsingClient, data: GatewayGuildRoleCreateDispatchData): GuildRoleStructure => { return Transformers.GuildRole(self, data.role, data.guild_id); }; -export const GUILD_ROLE_DELETE = async (self: UsingClient, data: GatewayGuildRoleDeleteDispatchData) => { +export const GUILD_ROLE_DELETE = async ( + self: UsingClient, + data: GatewayGuildRoleDeleteDispatchData, +): Promise> => { return (await self.cache.roles?.get(data.role_id)) || toCamelCase(data); }; @@ -139,7 +178,12 @@ export const GUILD_ROLE_UPDATE = async ( return [Transformers.GuildRole(self, data.role, data.guild_id), await self.cache.roles?.get(data.role.id)]; }; -export const GUILD_STICKERS_UPDATE = (self: UsingClient, data: GatewayGuildStickersUpdateDispatchData) => { +export const GUILD_STICKERS_UPDATE = ( + self: UsingClient, + data: GatewayGuildStickersUpdateDispatchData, +): ObjectToLower> & { + stickers: StickerStructure[]; +} => { return { ...toCamelCase(data), stickers: data.stickers.map(x => Transformers.Sticker(self, x)), diff --git a/src/events/hooks/integration.ts b/src/events/hooks/integration.ts index a53d0d5..50db51b 100644 --- a/src/events/hooks/integration.ts +++ b/src/events/hooks/integration.ts @@ -1,13 +1,20 @@ -import { Transformers } from '../../client/transformers'; +import { Transformers, type UserStructure } from '../../client/transformers'; import type { UsingClient } from '../../commands'; -import { toCamelCase } from '../../common'; +import { type ObjectToLower, toCamelCase } from '../../common'; import type { GatewayIntegrationCreateDispatchData, GatewayIntegrationDeleteDispatchData, GatewayIntegrationUpdateDispatchData, } from '../../types'; -export const INTEGRATION_CREATE = (self: UsingClient, data: GatewayIntegrationCreateDispatchData) => { +export const INTEGRATION_CREATE = ( + self: UsingClient, + data: GatewayIntegrationCreateDispatchData, +): + | (ObjectToLower> & { + user: UserStructure; + }) + | ObjectToLower> => { return data.user ? { ...toCamelCase(data), @@ -16,7 +23,14 @@ export const INTEGRATION_CREATE = (self: UsingClient, data: GatewayIntegrationCr : toCamelCase(data); }; -export const INTEGRATION_UPDATE = (self: UsingClient, data: GatewayIntegrationUpdateDispatchData) => { +export const INTEGRATION_UPDATE = ( + self: UsingClient, + data: GatewayIntegrationUpdateDispatchData, +): + | (ObjectToLower> & { + user: UserStructure; + }) + | ObjectToLower> => { return data.user ? { ...toCamelCase(data), @@ -25,10 +39,6 @@ export const INTEGRATION_UPDATE = (self: UsingClient, data: GatewayIntegrationUp : toCamelCase(data); }; -export const INTEGRATION_DELETE = ( - _self: UsingClient, - - data: GatewayIntegrationDeleteDispatchData, -) => { +export const INTEGRATION_DELETE = (_self: UsingClient, data: GatewayIntegrationDeleteDispatchData) => { return toCamelCase(data); }; diff --git a/src/events/hooks/message.ts b/src/events/hooks/message.ts index 985c0d9..b71e197 100644 --- a/src/events/hooks/message.ts +++ b/src/events/hooks/message.ts @@ -13,7 +13,7 @@ import type { GatewayMessageUpdateDispatchData, } from '../../types'; -export const MESSAGE_CREATE = (self: UsingClient, data: GatewayMessageCreateDispatchData) => { +export const MESSAGE_CREATE = (self: UsingClient, data: GatewayMessageCreateDispatchData): MessageStructure => { return Transformers.Message(self, data); }; @@ -24,7 +24,10 @@ export const MESSAGE_DELETE = async ( return (await self.cache.messages?.get(data.id)) ?? toCamelCase(data); }; -export const MESSAGE_DELETE_BULK = async (self: UsingClient, data: GatewayMessageDeleteBulkDispatchData) => { +export const MESSAGE_DELETE_BULK = async ( + self: UsingClient, + data: GatewayMessageDeleteBulkDispatchData, +): Promise => { return { ...data, messages: await Promise.all(data.ids.map(id => fakePromise(self.cache.messages?.get(id)).then(x => x ?? id))), diff --git a/src/events/hooks/soundboard.ts b/src/events/hooks/soundboard.ts index 80998d2..8e1aba9 100644 --- a/src/events/hooks/soundboard.ts +++ b/src/events/hooks/soundboard.ts @@ -1,7 +1,8 @@ -import { Transformers } from '../../client'; +import { Transformers, type UserStructure } from '../../client'; import type { UsingClient } from '../../commands'; -import { toCamelCase } from '../../common'; +import { type ObjectToLower, toCamelCase } from '../../common'; import type { + APISoundBoard, GatewayGuildSoundboardSoundCreateDispatchData, GatewayGuildSoundboardSoundDeleteDispatchData, GatewayGuildSoundboardSoundUpdateDispatchData, @@ -12,21 +13,37 @@ import type { export const GUILD_SOUNDBOARD_SOUND_CREATE = ( self: UsingClient, data: GatewayGuildSoundboardSoundCreateDispatchData, -) => { +): + | (ObjectToLower> & { + user: UserStructure; + }) + | ObjectToLower> => { return data.user ? { ...toCamelCase(data), user: Transformers.User(self, data.user) } : toCamelCase(data); }; export const GUILD_SOUNDBOARD_SOUND_UPDATE = ( self: UsingClient, data: GatewayGuildSoundboardSoundUpdateDispatchData, -) => { +): + | (ObjectToLower> & { + user: UserStructure; + }) + | ObjectToLower> => { return data.user ? { ...toCamelCase(data), user: Transformers.User(self, data.user) } : toCamelCase(data); }; export const GUILD_SOUNDBOARD_SOUNDS_UPDATE = ( self: UsingClient, data: GatewayGuildSoundboardSoundsUpdateDispatchData, -) => { +): { + guildId: string; + sounds: ( + | (ObjectToLower> & { + user: UserStructure; + }) + | ObjectToLower> + )[]; +} => { return { guildId: data.guild_id, sounds: data.soundboard_sounds.map(d => diff --git a/src/events/hooks/thread.ts b/src/events/hooks/thread.ts index 16ea1c9..222960b 100644 --- a/src/events/hooks/thread.ts +++ b/src/events/hooks/thread.ts @@ -1,6 +1,6 @@ import { type ThreadChannelStructure, Transformers } from '../../client/transformers'; import type { UsingClient } from '../../commands'; -import { toCamelCase } from '../../common'; +import { type ObjectToLower, toCamelCase } from '../../common'; import type { GatewayThreadCreateDispatchData, GatewayThreadDeleteDispatchData, @@ -10,12 +10,15 @@ import type { GatewayThreadUpdateDispatchData, } from '../../types'; -export const THREAD_CREATE = (self: UsingClient, data: GatewayThreadCreateDispatchData) => { +export const THREAD_CREATE = (self: UsingClient, data: GatewayThreadCreateDispatchData): ThreadChannelStructure => { return Transformers.ThreadChannel(self, data); }; -export const THREAD_DELETE = async (self: UsingClient, data: GatewayThreadDeleteDispatchData) => { - return (await self.cache.channels?.get(data.id)) ?? toCamelCase(data); +export const THREAD_DELETE = async ( + self: UsingClient, + data: GatewayThreadDeleteDispatchData, +): Promise> => { + return ((await self.cache.channels?.get(data.id)) as ThreadChannelStructure | undefined) ?? toCamelCase(data); }; export const THREAD_LIST_SYNC = (_self: UsingClient, data: GatewayThreadListSyncDispatchData) => { diff --git a/src/events/hooks/typing.ts b/src/events/hooks/typing.ts index 404e04c..5e6044e 100644 --- a/src/events/hooks/typing.ts +++ b/src/events/hooks/typing.ts @@ -1,9 +1,16 @@ -import { Transformers } from '../../client/transformers'; +import { type GuildMemberStructure, Transformers } from '../../client/transformers'; import type { UsingClient } from '../../commands'; -import { toCamelCase } from '../../common'; +import { type ObjectToLower, toCamelCase } from '../../common'; import type { GatewayTypingStartDispatchData } from '../../types'; -export const TYPING_START = (self: UsingClient, data: GatewayTypingStartDispatchData) => { +export const TYPING_START = ( + self: UsingClient, + data: GatewayTypingStartDispatchData, +): + | (ObjectToLower> & { + member: GuildMemberStructure; + }) + | ObjectToLower> => { return data.member ? { ...toCamelCase(data), diff --git a/src/structures/AutoModerationRule.ts b/src/structures/AutoModerationRule.ts index 941d6c4..a964740 100644 --- a/src/structures/AutoModerationRule.ts +++ b/src/structures/AutoModerationRule.ts @@ -1,3 +1,4 @@ +import type { AutoModerationRuleStructure, GuildMemberStructure, GuildStructure } from '../client'; import type { UsingClient } from '../commands'; import type { MethodContext, ObjectToLower } from '../common'; import type { @@ -14,19 +15,19 @@ export class AutoModerationRule extends DiscordBase { super(client, data); } - fetchCreator(force = false) { + fetchCreator(force = false): Promise { return this.client.members.fetch(this.guildId, this.creatorId, force); } - guild(force = false) { + guild(force = false): Promise> { return this.client.guilds.fetch(this.guildId, force); } - fetch() { + fetch(): Promise { return this.client.guilds.moderation.fetch(this.guildId, this.id); } - edit(body: RESTPatchAPIAutoModerationRuleJSONBody, reason?: string) { + edit(body: RESTPatchAPIAutoModerationRuleJSONBody, reason?: string): Promise { return this.client.guilds.moderation.edit(this.guildId, this.id, body, reason); } @@ -36,12 +37,16 @@ export class AutoModerationRule extends DiscordBase { static methods({ client, guildId }: MethodContext<{ guildId: string }>) { return { - list: () => client.guilds.moderation.list(guildId), - create: (body: RESTPostAPIAutoModerationRuleJSONBody) => client.guilds.moderation.create(guildId, body), + list: (): Promise => client.guilds.moderation.list(guildId), + create: (body: RESTPostAPIAutoModerationRuleJSONBody): Promise => + client.guilds.moderation.create(guildId, body), delete: (ruleId: string, reason?: string) => client.guilds.moderation.delete(guildId, ruleId, reason), - fetch: (ruleId: string) => client.guilds.moderation.fetch(guildId, ruleId), - edit: (ruleId: string, body: RESTPatchAPIAutoModerationRuleJSONBody, reason?: string) => - client.guilds.moderation.edit(guildId, ruleId, body, reason), + fetch: (ruleId: string): Promise => client.guilds.moderation.fetch(guildId, ruleId), + edit: ( + ruleId: string, + body: RESTPatchAPIAutoModerationRuleJSONBody, + reason?: string, + ): Promise => client.guilds.moderation.edit(guildId, ruleId, body, reason), }; } } diff --git a/src/structures/ClientUser.ts b/src/structures/ClientUser.ts index 2bd8a8e..e2d651c 100644 --- a/src/structures/ClientUser.ts +++ b/src/structures/ClientUser.ts @@ -1,3 +1,4 @@ +import type { ClientUserStructure } from '../client'; import type { UsingClient } from '../commands'; import type { GatewayReadyDispatchData, RESTPatchAPICurrentUserJSONBody } from '../types'; import { User } from './User'; @@ -12,12 +13,12 @@ export class ClientUser extends User { super(client, data); } - async fetch() { + async fetch(): Promise { const data = await this.api.users('@me').get(); return new ClientUser(this.client, data, this.application); } - async edit(body: RESTPatchAPICurrentUserJSONBody) { + async edit(body: RESTPatchAPICurrentUserJSONBody): Promise { const data = await this.api.users('@me').patch({ body }); return new ClientUser(this.client, data, this.application); } diff --git a/src/structures/Guild.ts b/src/structures/Guild.ts index 6c9d7ef..00f88c8 100644 --- a/src/structures/Guild.ts +++ b/src/structures/Guild.ts @@ -1,3 +1,4 @@ +import type { GuildMemberStructure } from '../client'; import type { UsingClient } from '../commands'; import type { ObjectToLower, StructPropState, StructStates, ToClass } from '../common/types/util'; import type { APIGuild, APIPartialGuild, GatewayGuildCreateDispatchData, RESTPatchAPIGuildJSONBody } from '../types'; @@ -61,7 +62,7 @@ export class Guild extends (BaseGuild as unk } } - async fetchOwner(force = false) { + async fetchOwner(force = false): Promise { // For no reason, discord has some guilds without owner... 🤓 if (!this.ownerId) { return null; diff --git a/src/structures/GuildBan.ts b/src/structures/GuildBan.ts index 5722a7d..cc4f0a6 100644 --- a/src/structures/GuildBan.ts +++ b/src/structures/GuildBan.ts @@ -1,3 +1,4 @@ +import type { GuildBanStructure, GuildStructure } from '../client'; import type { UsingClient } from '../commands'; import { Formatter, type MethodContext, type ObjectToLower } from '../common'; import type { BanShorter } from '../common/shorters/bans'; @@ -23,11 +24,11 @@ export class GuildBan extends DiscordBase { return this.client.bans.remove(this.guildId, this.id, reason); } - guild(force = false) { + guild(force = false): Promise> { return this.client.guilds.fetch(this.guildId, force); } - fetch(force = false) { + fetch(force = false): Promise { return this.client.bans.fetch(this.guildId, this.id, force); } @@ -37,8 +38,9 @@ export class GuildBan extends DiscordBase { static methods({ client, guildId }: MethodContext<{ guildId: string }>) { return { - fetch: (userId: string, force = false) => client.bans.fetch(guildId, userId, force), - list: (query?: RESTGetAPIGuildBansQuery, force = false) => client.bans.list(guildId, query, force), + fetch: (userId: string, force = false): Promise => client.bans.fetch(guildId, userId, force), + list: (query?: RESTGetAPIGuildBansQuery, force = false): Promise => + client.bans.list(guildId, query, force), create: (memberId: string, body?: Parameters[2], reason?: string) => client.bans.create(guildId, memberId, body, reason), remove: (memberId: string, reason?: string) => client.bans.remove(guildId, memberId, reason), diff --git a/src/structures/GuildEmoji.ts b/src/structures/GuildEmoji.ts index 3842983..fbb35e8 100644 --- a/src/structures/GuildEmoji.ts +++ b/src/structures/GuildEmoji.ts @@ -1,4 +1,5 @@ import type { BaseCDNUrlOptions } from '../api'; +import type { GuildEmojiStructure, GuildStructure } from '../client'; import type { UsingClient } from '../commands'; import { type EmojiShorter, Formatter, type MethodContext, type ObjectToLower } from '../common'; import type { APIEmoji, RESTPatchAPIChannelJSONBody, RESTPatchAPIGuildEmojiJSONBody } from '../types'; @@ -15,12 +16,12 @@ export class GuildEmoji extends DiscordBase { super(client, { ...data, id: data.id! }); } - async guild(force = false) { + async guild(force = false): Promise | undefined> { if (!this.guildId) return; return this.client.guilds.fetch(this.guildId, force); } - edit(body: RESTPatchAPIChannelJSONBody, reason?: string) { + edit(body: RESTPatchAPIChannelJSONBody, reason?: string): Promise { return this.client.emojis.edit(this.guildId, this.id, body, reason); } @@ -28,7 +29,7 @@ export class GuildEmoji extends DiscordBase { return this.client.emojis.delete(this.guildId, this.id, reason); } - fetch(force = false) { + fetch(force = false): Promise { return this.client.emojis.fetch(this.guildId, this.id, force); } @@ -50,11 +51,13 @@ export class GuildEmoji extends DiscordBase { static methods({ client, guildId }: MethodContext<{ guildId: string }>) { return { - edit: (emojiId: string, body: RESTPatchAPIGuildEmojiJSONBody, reason?: string) => + edit: (emojiId: string, body: RESTPatchAPIGuildEmojiJSONBody, reason?: string): Promise => client.emojis.edit(guildId, emojiId, body, reason), - create: (body: Parameters[1]) => client.emojis.create(guildId, body), - fetch: (emojiId: string, force = false) => client.emojis.fetch(guildId, emojiId, force), - list: (force = false) => client.emojis.list(guildId, force), + create: (body: Parameters[1]): Promise => + client.emojis.create(guildId, body), + fetch: (emojiId: string, force = false): Promise => + client.emojis.fetch(guildId, emojiId, force), + list: (force = false): Promise => client.emojis.list(guildId, force), }; } } diff --git a/src/structures/GuildMember.ts b/src/structures/GuildMember.ts index 8ca0c55..99b4353 100644 --- a/src/structures/GuildMember.ts +++ b/src/structures/GuildMember.ts @@ -7,7 +7,15 @@ export type GuildMemberData = | GatewayGuildMemberAddDispatchData | APIInteractionDataResolvedGuildMember; -import { Transformers, type UserStructure } from '../client/transformers'; +import { + type DMChannelStructure, + type GuildMemberStructure, + type GuildStructure, + type MessageStructure, + Transformers, + type UserStructure, + type VoiceStateStructure, +} from '../client/transformers'; import type { UsingClient } from '../commands'; import { Formatter, @@ -30,6 +38,7 @@ import type { RESTPutAPIGuildBanJSONBody, RESTPutAPIGuildMemberJSONBody, } from '../types'; +import type { GuildRole } from './GuildRole'; import { PermissionsBitField } from './extra/Permissions'; export interface BaseGuildMember extends DiscordBase, ObjectToLower> {} @@ -50,11 +59,11 @@ export class BaseGuildMember extends DiscordBase { this.patch(data); } - guild(force = false) { + guild(force = false): Promise> { return this.client.guilds.fetch(this.guildId, force); } - fetch(force = false) { + fetch(force = false): Promise { return this.client.members.fetch(this.guildId, this.id, force); } @@ -66,7 +75,7 @@ export class BaseGuildMember extends DiscordBase { return this.client.members.kick(this.guildId, this.id, reason); } - edit(body: RESTPatchAPIGuildMemberJSONBody, reason?: string) { + edit(body: RESTPatchAPIGuildMemberJSONBody, reason?: string): Promise { return this.client.members.edit(this.guildId, this.id, body, reason); } @@ -74,7 +83,7 @@ export class BaseGuildMember extends DiscordBase { return this.client.members.presence(this.id); } - voice(force = false) { + voice(force = false): Promise { return this.client.members.voice(this.guildId, this.id, force); } @@ -82,7 +91,7 @@ export class BaseGuildMember extends DiscordBase { return Formatter.userMention(this.id); } - timeout(time: null | number, reason?: string) { + timeout(time: null | number, reason?: string): Promise { return this.client.members.timeout(this.guildId, this.id, time, reason); } @@ -104,7 +113,7 @@ export class BaseGuildMember extends DiscordBase { get roles() { return { keys: Object.freeze(this._roles.concat(this.guildId)) as string[], - list: (force = false) => + list: (force = false): Promise => this.client.roles .list(this.guildId, force) .then(roles => roles.filter(role => this.roles.keys.includes(role.id))), @@ -112,26 +121,32 @@ export class BaseGuildMember extends DiscordBase { remove: (id: string) => this.client.members.removeRole(this.guildId, this.id, id), permissions: (force = false) => this.roles.list(force).then(roles => new PermissionsBitField(roles.map(x => BigInt(x.permissions.bits)))), - sorted: (force = false) => this.roles.list(force).then(roles => roles.sort((a, b) => b.position - a.position)), - highest: (force = false) => this.roles.sorted(force).then(roles => roles[0]), + sorted: (force = false): Promise => + this.roles.list(force).then(roles => roles.sort((a, b) => b.position - a.position)), + highest: (force = false): Promise => this.roles.sorted(force).then(roles => roles[0]), }; } static methods({ client, guildId }: MethodContext<{ guildId: string }>) { return { - resolve: (resolve: GuildMemberResolvable) => client.members.resolve(guildId, resolve), - search: (query?: RESTGetAPIGuildMembersSearchQuery) => client.members.search(guildId, query), + resolve: (resolve: GuildMemberResolvable): Promise => + client.members.resolve(guildId, resolve), + search: (query?: RESTGetAPIGuildMembersSearchQuery): Promise => + client.members.search(guildId, query), unban: (id: string, reason?: string) => client.members.unban(guildId, id, reason), ban: (id: string, body?: RESTPutAPIGuildBanJSONBody, reason?: string) => client.members.ban(guildId, id, body, reason), kick: (id: string, reason?: string) => client.members.kick(guildId, id, reason), edit: (id: string, body: RESTPatchAPIGuildMemberJSONBody, reason?: string) => client.members.edit(guildId, id, body, reason), - add: (id: string, body: RESTPutAPIGuildMemberJSONBody) => client.members.add(guildId, id, body), + add: (id: string, body: RESTPutAPIGuildMemberJSONBody): Promise => + client.members.add(guildId, id, body), addRole: (memberId: string, id: string) => client.members.addRole(guildId, memberId, id), removeRole: (memberId: string, id: string) => client.members.removeRole(guildId, memberId, id), - fetch: (memberId: string, force = false) => client.members.fetch(guildId, memberId, force), - list: (query?: RESTGetAPIGuildMembersQuery, force = false) => client.members.list(guildId, query, force), + fetch: (memberId: string, force = false): Promise => + client.members.fetch(guildId, memberId, force), + list: (query?: RESTGetAPIGuildMembersQuery, force = false): Promise => + client.members.list(guildId, query, force), }; } } @@ -180,11 +195,11 @@ export class GuildMember extends BaseGuildMember { return this.nick ?? this.globalName ?? this.username; } - dm(force = false) { + dm(force = false): Promise { return this.user.dm(force); } - write(body: MessageCreateBodyRequest) { + write(body: MessageCreateBodyRequest): Promise { return this.user.write(body); } diff --git a/src/structures/GuildRole.ts b/src/structures/GuildRole.ts index ac1cbd1..b781fb6 100644 --- a/src/structures/GuildRole.ts +++ b/src/structures/GuildRole.ts @@ -1,3 +1,4 @@ +import type { GuildRoleStructure, GuildStructure } from '../client'; import type { UsingClient } from '../commands'; import { Formatter, type MethodContext, type ObjectToLower } from '../common'; import type { @@ -22,20 +23,20 @@ export class GuildRole extends DiscordBase { this.permissions = new PermissionsBitField(BigInt(data.permissions)); } - async guild(force = false) { + async guild(force = false): Promise | undefined> { if (!this.guildId) return; return this.client.guilds.fetch(this.guildId, force); } - fetch(force = false) { + fetch(force = false): Promise { return this.client.roles.fetch(this.guildId, this.id, force); } - edit(body: RESTPatchAPIGuildRoleJSONBody) { + edit(body: RESTPatchAPIGuildRoleJSONBody): Promise { return this.client.roles.edit(this.guildId, this.id, body); } - delete(reason?: string) { + delete(reason?: string): Promise { return this.client.roles.delete(this.guildId, this.id, reason); } @@ -45,12 +46,14 @@ export class GuildRole extends DiscordBase { static methods(ctx: MethodContext<{ guildId: string }>) { return { - create: (body: RESTPostAPIGuildRoleJSONBody) => ctx.client.roles.create(ctx.guildId, body), - list: (force = false) => ctx.client.roles.list(ctx.guildId, force), - edit: (roleId: string, body: RESTPatchAPIGuildRoleJSONBody, reason?: string) => + create: (body: RESTPostAPIGuildRoleJSONBody): Promise => + ctx.client.roles.create(ctx.guildId, body), + list: (force = false): Promise => ctx.client.roles.list(ctx.guildId, force), + edit: (roleId: string, body: RESTPatchAPIGuildRoleJSONBody, reason?: string): Promise => ctx.client.roles.edit(ctx.guildId, roleId, body, reason), - delete: (roleId: string, reason?: string) => ctx.client.roles.delete(ctx.guildId, roleId, reason), - editPositions: (body: RESTPatchAPIGuildRolePositionsJSONBody) => + delete: (roleId: string, reason?: string): Promise => + ctx.client.roles.delete(ctx.guildId, roleId, reason), + editPositions: (body: RESTPatchAPIGuildRolePositionsJSONBody): Promise => ctx.client.roles.editPositions(ctx.guildId, body), }; } diff --git a/src/structures/GuildTemplate.ts b/src/structures/GuildTemplate.ts index 93077c7..1ce102c 100644 --- a/src/structures/GuildTemplate.ts +++ b/src/structures/GuildTemplate.ts @@ -1,3 +1,4 @@ +import type { GuildStructure, GuildTemplateStructure } from '../client'; import type { UsingClient } from '../commands'; import type { MethodContext, ObjectToLower } from '../common'; import type { APITemplate, RESTPatchAPIGuildTemplateJSONBody, RESTPostAPIGuildTemplatesJSONBody } from '../types'; @@ -11,35 +12,36 @@ export class GuildTemplate extends Base { this.__patchThis(data); } - guild(force = false) { + guild(force = false): Promise> { return this.client.guilds.fetch(this.sourceGuildId, force); } - fetch() { + fetch(): Promise { return this.client.templates.fetch(this.sourceGuildId); } - sync() { + sync(): Promise { return this.client.templates.sync(this.sourceGuildId, this.code); } - edit(body: RESTPatchAPIGuildTemplateJSONBody) { + edit(body: RESTPatchAPIGuildTemplateJSONBody): Promise { return this.client.templates.edit(this.sourceGuildId, this.code, body); } - delete() { + delete(): Promise { return this.client.templates.delete(this.sourceGuildId, this.code); } static methods(ctx: MethodContext<{ guildId: string }>) { return { - fetch: (code: string) => ctx.client.templates.fetch(code), - list: () => ctx.client.templates.list(ctx.guildId), - create: (body: RESTPostAPIGuildTemplatesJSONBody) => ctx.client.templates.create(ctx.guildId, body), - sync: (code: string) => ctx.client.templates.sync(ctx.guildId, code), - edit: (code: string, body: RESTPatchAPIGuildTemplateJSONBody) => + fetch: (code: string): Promise => ctx.client.templates.fetch(code), + list: (): Promise => ctx.client.templates.list(ctx.guildId), + create: (body: RESTPostAPIGuildTemplatesJSONBody): Promise => + ctx.client.templates.create(ctx.guildId, body), + sync: (code: string): Promise => ctx.client.templates.sync(ctx.guildId, code), + edit: (code: string, body: RESTPatchAPIGuildTemplateJSONBody): Promise => ctx.client.templates.edit(ctx.guildId, code, body), - delete: (code: string) => ctx.client.templates.delete(ctx.guildId, code), + delete: (code: string): Promise => ctx.client.templates.delete(ctx.guildId, code), }; } } diff --git a/src/structures/Interaction.ts b/src/structures/Interaction.ts index 5653dab..e40490f 100644 --- a/src/structures/Interaction.ts +++ b/src/structures/Interaction.ts @@ -435,15 +435,15 @@ export class Interaction< FromGuild extends boolean = boolean, Type extends APIInteraction = APIInteraction, > extends BaseInteraction { - fetchMessage(messageId: string) { + fetchMessage(messageId: string): Promise { return this.client.interactions.fetchResponse(this.token, messageId); } - fetchResponse() { + fetchResponse(): Promise { return this.fetchMessage('@original'); } - async write( + write( body: InteractionCreateBodyRequest, withResponse?: FR, ): Promise> { @@ -467,7 +467,10 @@ export class Interaction< body: InteractionCreateBodyRequest, fetchReply?: FR, ): Promise>; - async editOrReply(body: InteractionMessageUpdateBodyRequest, fetchReply?: FR) { + async editOrReply( + body: InteractionMessageUpdateBodyRequest, + fetchReply?: FR, + ): Promise { if (await this.replied) { const { content, embeds, allowed_mentions, components, files, attachments, poll } = body; return this.editResponse({ content, embeds, allowed_mentions, components, files, attachments, poll }); @@ -475,11 +478,11 @@ export class Interaction< return this.write(body as InteractionCreateBodyRequest, fetchReply); } - editMessage(messageId: string, body: InteractionMessageUpdateBodyRequest) { + editMessage(messageId: string, body: InteractionMessageUpdateBodyRequest): Promise { return this.client.interactions.editMessage(this.token, messageId, body); } - editResponse(body: InteractionMessageUpdateBodyRequest) { + editResponse(body: InteractionMessageUpdateBodyRequest): Promise { return this.editMessage('@original', body); } @@ -491,7 +494,7 @@ export class Interaction< return this.client.interactions.deleteResponse(this.token, messageId); } - followup(body: MessageWebhookCreateBodyRequest) { + followup(body: MessageWebhookCreateBodyRequest): Promise { return this.client.interactions.followup(this.token, body); } } @@ -784,8 +787,11 @@ export interface ModalSubmitInteraction export class ModalSubmitInteraction extends BaseInteraction { declare data: ObjectToLower; - update(data: ComponentInteractionMessageUpdate, withResponse?: WR) { - return this.reply( + update( + data: ComponentInteractionMessageUpdate, + withResponse?: WR, + ): Promise> { + return this.reply( { type: InteractionResponseType.UpdateMessage, data, @@ -794,7 +800,7 @@ export class ModalSubmitInteraction extends ); } - deferUpdate(withResponse?: WR) { + deferUpdate(withResponse?: WR): Promise> { return this.reply( { type: InteractionResponseType.DeferredMessageUpdate, diff --git a/src/structures/Message.ts b/src/structures/Message.ts index 75f113a..d1d248b 100644 --- a/src/structures/Message.ts +++ b/src/structures/Message.ts @@ -1,10 +1,14 @@ -import { Embed } from '..'; +import { type AllChannels, Embed } from '..'; import type { ListenerOptions } from '../builders'; import { type GuildMemberStructure, + type GuildStructure, + type MessageStructure, type PollStructure, Transformers, type UserStructure, + type WebhookMessageStructure, + type WebhookStructure, } from '../client/transformers'; import type { UsingClient } from '../commands'; import { type ObjectToLower, toCamelCase } from '../common'; @@ -56,7 +60,7 @@ export class BaseMessage extends DiscordBase { this.patch(data); } - get user() { + get user(): UserStructure { return this.author; } @@ -68,12 +72,12 @@ export class BaseMessage extends DiscordBase { return Formatter.messageLink(this.guildId!, this.channelId, this.id); } - async guild(force = false) { + async guild(force = false): Promise | undefined> { if (!this.guildId) return; return this.client.guilds.fetch(this.guildId, force); } - channel(force = false) { + channel(force = false): Promise { return this.client.channels.fetch(this.channelId, force); } @@ -125,11 +129,11 @@ export class Message extends BaseMessage { super(client, data); } - fetch(force = false) { + fetch(force = false): Promise { return this.client.messages.fetch(this.id, this.channelId, force); } - reply(body: Omit, fail = true) { + reply(body: Omit, fail = true): Promise { return this.write({ ...body, message_reference: { @@ -141,11 +145,11 @@ export class Message extends BaseMessage { }); } - edit(body: MessageUpdateBodyRequest) { + edit(body: MessageUpdateBodyRequest): Promise { return this.client.messages.edit(this.id, this.channelId, body); } - write(body: MessageCreateBodyRequest) { + write(body: MessageCreateBodyRequest): Promise { return this.client.messages.write(this.channelId, body); } @@ -153,7 +157,7 @@ export class Message extends BaseMessage { return this.client.messages.delete(this.id, this.channelId, reason); } - crosspost(reason?: string) { + crosspost(reason?: string): Promise { return this.client.messages.crosspost(this.id, this.channelId, reason); } } @@ -173,15 +177,15 @@ export class WebhookMessage extends BaseMessage { super(client, data); } - fetchWebhook() { + fetchWebhook(): Promise { return this.client.webhooks.fetch(this.webhookId, this.webhookToken); } - fetch() { + fetch(): Promise { return this.client.webhooks.fetchMessage(this.webhookId, this.webhookToken, this.id, this.thread?.id); } - edit(body: EditMessageWebhook) { + edit(body: EditMessageWebhook): Promise { const { query, ...rest } = body; return this.client.webhooks.editMessage(this.webhookId, this.webhookToken, { body: rest, @@ -190,7 +194,7 @@ export class WebhookMessage extends BaseMessage { }); } - write(body: WriteMessageWebhook) { + write(body: WriteMessageWebhook): Promise { const { query, ...rest } = body; return this.client.webhooks.writeMessage(this.webhookId, this.webhookToken, { body: rest, diff --git a/src/structures/Poll.ts b/src/structures/Poll.ts index 3ddf151..e59bc4c 100644 --- a/src/structures/Poll.ts +++ b/src/structures/Poll.ts @@ -1,4 +1,5 @@ import type { ValidAnswerId } from '../api/Routes/channels'; +import type { MessageStructure, UserStructure } from '../client/transformers'; import type { UsingClient } from '../commands'; import { type ObjectToLower, toCamelCase } from '../common'; import type { APIPoll } from '../types'; @@ -25,11 +26,11 @@ export class Poll extends Base { return new Date(this.expiry); } - end() { + end(): Promise { return this.client.messages.endPoll(this.channelId, this.messageId); } - getAnswerVoters(id: ValidAnswerId) { + getAnswerVoters(id: ValidAnswerId): Promise { if (!this.answers.find(x => x.answerId === id)) throw new Error('Invalid answer id'); return this.client.messages.getAnswerVoters(this.channelId, this.messageId, id); } diff --git a/src/structures/Sticker.ts b/src/structures/Sticker.ts index 0784a9b..96463c8 100644 --- a/src/structures/Sticker.ts +++ b/src/structures/Sticker.ts @@ -1,4 +1,4 @@ -import type { RawFile, UsingClient } from '..'; +import type { GuildStructure, RawFile, StickerStructure, UsingClient } from '..'; import type { Attachment, AttachmentBuilder } from '../builders'; import { Transformers, type UserStructure } from '../client/transformers'; import type { MethodContext, ObjectToLower } from '../common'; @@ -16,17 +16,17 @@ export class Sticker extends DiscordBase { } } - async guild(force = false) { + async guild(force = false): Promise | undefined> { if (!this.guildId) return; return this.client.guilds.fetch(this.guildId, force); } - async edit(body: RESTPatchAPIGuildStickerJSONBody, reason?: string) { + async edit(body: RESTPatchAPIGuildStickerJSONBody, reason?: string): Promise { if (!this.guildId) return; return this.client.guilds.stickers.edit(this.guildId, this.id, body, reason); } - async fetch(force = false) { + async fetch(force = false): Promise { if (!this.guildId) return; return this.client.guilds.stickers.fetch(this.guildId, this.id, force); } @@ -38,12 +38,13 @@ export class Sticker extends DiscordBase { static methods({ client, guildId }: MethodContext<{ guildId: string }>) { return { - list: () => client.guilds.stickers.list(guildId), - create: (payload: CreateStickerBodyRequest, reason?: string) => + list: (): Promise => client.guilds.stickers.list(guildId), + create: (payload: CreateStickerBodyRequest, reason?: string): Promise => client.guilds.stickers.create(guildId, payload, reason), - edit: (stickerId: string, body: RESTPatchAPIGuildStickerJSONBody, reason?: string) => + edit: (stickerId: string, body: RESTPatchAPIGuildStickerJSONBody, reason?: string): Promise => client.guilds.stickers.edit(guildId, stickerId, body, reason), - fetch: (stickerId: string, force = false) => client.guilds.stickers.fetch(guildId, stickerId, force), + fetch: (stickerId: string, force = false): Promise => + client.guilds.stickers.fetch(guildId, stickerId, force), delete: (stickerId: string, reason?: string) => client.guilds.stickers.delete(guildId, stickerId, reason), }; } diff --git a/src/structures/User.ts b/src/structures/User.ts index aee2801..c0aff05 100644 --- a/src/structures/User.ts +++ b/src/structures/User.ts @@ -1,4 +1,5 @@ import { calculateUserDefaultAvatarIndex } from '../api'; +import type { DMChannelStructure, MessageStructure, UserStructure } from '../client'; import { Formatter, type MessageCreateBodyRequest, type ObjectToLower } from '../common'; import type { ImageOptions } from '../common/types/options'; import type { APIUser } from '../types'; @@ -18,18 +19,18 @@ export class User extends DiscordBase { /** * Fetch user */ - fetch(force = false) { + fetch(force = false): Promise { return this.client.users.fetch(this.id, force); } /** * Open a DM with the user */ - dm(force = false) { + dm(force = false): Promise { return this.client.users.createDM(this.id, force); } - write(body: MessageCreateBodyRequest) { + write(body: MessageCreateBodyRequest): Promise { return this.client.users.write(this.id, body); } diff --git a/src/structures/VoiceState.ts b/src/structures/VoiceState.ts index 62b7dd1..297a4e0 100644 --- a/src/structures/VoiceState.ts +++ b/src/structures/VoiceState.ts @@ -1,4 +1,4 @@ -import type { UsingClient } from '../'; +import type { UserStructure, UsingClient, VoiceStateStructure } from '../'; import type { VoiceStateResource } from '../cache/resources/voice-states'; import { type GuildMemberStructure, Transformers } from '../client/transformers'; import type { ObjectToLower } from '../common'; @@ -22,26 +22,26 @@ export class VoiceState extends Base { return this.mute || this.selfMute; } - async member(force?: boolean) { + async member(force?: boolean): Promise { return (this.withMember = await this.client.members.fetch(this.guildId, this.userId, force)); } - user(force?: boolean) { + user(force?: boolean): Promise { return this.client.users.fetch(this.userId, force); } - async channel(force?: boolean) { + async channel(force?: boolean): Promise { if (!this.channelId) return; return this.client.channels.fetch(this.channelId, force) as Promise; } - async setMute(mute = !this.mute, reason?: string) { + async setMute(mute = !this.mute, reason?: string): Promise { const member = await this.client.members.edit(this.guildId, this.userId, { mute }, reason); this.mute = mute; return member; } - async setDeaf(deaf = !this.deaf, reason?: string) { + async setDeaf(deaf = !this.deaf, reason?: string): Promise { const member = await this.client.members.edit(this.guildId, this.userId, { deaf }, reason); this.deaf = deaf; return member; @@ -60,16 +60,16 @@ export class VoiceState extends Base { this.requestToSpeakTimestamp = date; } - disconnect(reason?: string) { + disconnect(reason?: string): Promise { return this.setChannel(null, reason); } - async fetch(force = false) { + async fetch(force = false): Promise { const member = this.withMember ?? (await this.member(force)); return this.client.members.voice(this.guildId, member.id, force); } - async setChannel(channel_id: null | string, reason?: string) { + async setChannel(channel_id: null | string, reason?: string): Promise { const member = await this.client.members.edit(this.guildId, this.userId, { channel_id }, reason); this.channelId = channel_id; return member; diff --git a/src/structures/Webhook.ts b/src/structures/Webhook.ts index 3df107b..a896446 100644 --- a/src/structures/Webhook.ts +++ b/src/structures/Webhook.ts @@ -1,4 +1,11 @@ -import { type AnonymousGuildStructure, Transformers, type UserStructure } from '../client/transformers'; +import { + type AnonymousGuildStructure, + type GuildStructure, + Transformers, + type UserStructure, + type WebhookMessageStructure, + type WebhookStructure, +} from '../client/transformers'; import type { UsingClient } from '../commands'; import type { ImageOptions, @@ -18,6 +25,7 @@ import type { RESTPatchAPIWebhookWithTokenJSONBody, RESTPostAPIWebhookWithTokenQuery, } from '../types'; +import type { AllChannels } from './channels'; import { DiscordBase } from './extra/DiscordBase'; export interface Webhook extends DiscordBase, ObjectToLower> {} @@ -58,7 +66,7 @@ export class Webhook extends DiscordBase { * @param force Whether to force fetching the guild even if it's already cached. * @returns A promise that resolves to the guild associated with the webhook, or undefined if not applicable. */ - async guild(force = false) { + async guild(force = false): Promise | undefined> { if (!this.sourceGuild?.id) return; return this.client.guilds.fetch(this.sourceGuild.id, force); } @@ -68,7 +76,7 @@ export class Webhook extends DiscordBase { * @param force Whether to force fetching the channel even if it's already cached. * @returns A promise that resolves to the channel associated with the webhook, or undefined if not applicable. */ - async channel(force = false) { + async channel(force = false): Promise { if (!this.sourceChannel?.id) return; return this.client.channels.fetch(this.sourceChannel.id, force); } @@ -90,7 +98,7 @@ export class Webhook extends DiscordBase { * Fetches the webhook data from the Discord API. * @returns A promise that resolves to the fetched webhook data. */ - fetch() { + fetch(): Promise { return this.client.webhooks.fetch(this.id, this.token); } @@ -100,7 +108,10 @@ export class Webhook extends DiscordBase { * @param reason The reason for editing the webhook. * @returns A promise that resolves when the webhook is successfully edited. */ - edit(body: RESTPatchAPIWebhookJSONBody | RESTPatchAPIWebhookWithTokenJSONBody, reason?: string) { + edit( + body: RESTPatchAPIWebhookJSONBody | RESTPatchAPIWebhookWithTokenJSONBody, + reason?: string, + ): Promise { return this.client.webhooks.edit(this.id, body, { reason, token: this.token }); } @@ -119,10 +130,11 @@ export class Webhook extends DiscordBase { static messages({ client, webhookId, webhookToken }: MethodContext<{ webhookId: string; webhookToken: string }>) { return { /** Writes a message through the webhook. */ - write: (payload: MessageWebhookMethodWriteParams) => + write: (payload: MessageWebhookMethodWriteParams): Promise => client.webhooks.writeMessage(webhookId, webhookToken, payload), /** Edits a message sent through the webhook. */ - edit: (payload: MessageWebhookMethodEditParams) => client.webhooks.editMessage(webhookId, webhookToken, payload), + edit: (payload: MessageWebhookMethodEditParams): Promise => + client.webhooks.editMessage(webhookId, webhookToken, payload), /** Deletes a message sent through the webhook. */ delete: (messageId: string, reason?: string) => client.webhooks.deleteMessage(webhookId, webhookToken, messageId, reason), diff --git a/src/structures/channels.ts b/src/structures/channels.ts index db52ab1..523c2df 100644 --- a/src/structures/channels.ts +++ b/src/structures/channels.ts @@ -9,14 +9,18 @@ import { type DirectoryChannelStructure, type ForumChannelStructure, type GuildMemberStructure, + type GuildStructure, type MediaChannelStructure, + type MessageStructure, type NewsChannelStructure, type StageChannelStructure, type TextGuildChannelStructure, type ThreadChannelStructure, Transformers, + type UserStructure, type VoiceChannelStructure, type VoiceStateStructure, + type WebhookStructure, } from '../client'; import type { UsingClient } from '../commands'; import { @@ -80,11 +84,11 @@ export class BaseNoEditableChannel extends DiscordBase { return this.client.channels.fetch(this.id, force); } - delete(reason?: string) { + delete(reason?: string): Promise { return this.client.channels.delete(this.id, { reason }); } @@ -150,11 +154,14 @@ export class BaseNoEditableChannel extends DiscordBase) { return { - list: (force = false) => ctx.client.guilds.channels.list(ctx.guildId, force), - fetch: (id: string, force = false) => ctx.client.guilds.channels.fetch(ctx.guildId, id, force), - create: (body: RESTPostAPIGuildChannelJSONBody) => ctx.client.guilds.channels.create(ctx.guildId, body), - delete: (id: string, reason?: string) => ctx.client.guilds.channels.delete(ctx.guildId, id, reason), - edit: (id: string, body: RESTPatchAPIChannelJSONBody, reason?: string) => + list: (force = false): Promise => ctx.client.guilds.channels.list(ctx.guildId, force), + fetch: (id: string, force = false): Promise => + ctx.client.guilds.channels.fetch(ctx.guildId, id, force), + create: (body: RESTPostAPIGuildChannelJSONBody): Promise => + ctx.client.guilds.channels.create(ctx.guildId, body), + delete: (id: string, reason?: string): Promise => + ctx.client.guilds.channels.delete(ctx.guildId, id, reason), + edit: (id: string, body: RESTPatchAPIChannelJSONBody, reason?: string): Promise => ctx.client.guilds.channels.edit(ctx.guildId, id, body, reason), editPositions: (body: RESTPatchAPIGuildChannelPositionsJSONBody) => ctx.client.guilds.channels.editPositions(ctx.guildId, body), @@ -218,7 +225,7 @@ export class BaseGuildChannel extends BaseChannel { return this.client.channels.overwritesFor(this.id, member); } - guild(force = false) { + guild(force = false): Promise> { return this.client.guilds.fetch(this.guildId!, force); } @@ -265,15 +272,18 @@ export class MessagesMethods extends DiscordBase { static messages(ctx: MethodContext<{ channelId: string }>) { return { - write: (body: MessageCreateBodyRequest) => ctx.client.messages.write(ctx.channelId, body), - edit: (messageId: string, body: MessageUpdateBodyRequest) => + write: (body: MessageCreateBodyRequest): Promise => + ctx.client.messages.write(ctx.channelId, body), + edit: (messageId: string, body: MessageUpdateBodyRequest): Promise => ctx.client.messages.edit(messageId, ctx.channelId, body), - crosspost: (messageId: string, reason?: string) => + crosspost: (messageId: string, reason?: string): Promise => ctx.client.messages.crosspost(messageId, ctx.channelId, reason), delete: (messageId: string, reason?: string) => ctx.client.messages.delete(messageId, ctx.channelId, reason), - fetch: (messageId: string, force = false) => ctx.client.messages.fetch(messageId, ctx.channelId, force), + fetch: (messageId: string, force = false): Promise => + ctx.client.messages.fetch(messageId, ctx.channelId, force), purge: (messages: string[], reason?: string) => ctx.client.messages.purge(messages, ctx.channelId, reason), - list: (fetchOptions: RESTGetAPIChannelMessagesQuery) => ctx.client.messages.list(ctx.channelId, fetchOptions), + list: (fetchOptions: RESTGetAPIChannelMessagesQuery): Promise => + ctx.client.messages.list(ctx.channelId, fetchOptions), }; } @@ -282,8 +292,11 @@ export class MessagesMethods extends DiscordBase { add: (messageId: string, emoji: EmojiResolvable) => ctx.client.reactions.add(messageId, ctx.channelId, emoji), delete: (messageId: string, emoji: EmojiResolvable, userId = '@me') => ctx.client.reactions.delete(messageId, ctx.channelId, emoji, userId), - fetch: (messageId: string, emoji: EmojiResolvable, query?: RESTGetAPIChannelMessageReactionUsersQuery) => - ctx.client.reactions.fetch(messageId, ctx.channelId, emoji, query), + fetch: ( + messageId: string, + emoji: EmojiResolvable, + query?: RESTGetAPIChannelMessageReactionUsersQuery, + ): Promise => ctx.client.reactions.fetch(messageId, ctx.channelId, emoji, query), purge: (messageId: string, emoji?: EmojiResolvable) => ctx.client.reactions.purge(messageId, ctx.channelId, emoji), }; @@ -291,7 +304,7 @@ export class MessagesMethods extends DiscordBase { static pins(ctx: MethodContext<{ channelId: string }>) { return { - fetch: () => ctx.client.channels.pins(ctx.channelId), + fetch: (): Promise => ctx.client.channels.pins(ctx.channelId), set: (messageId: string, reason?: string) => ctx.client.channels.setPin(messageId, ctx.channelId, reason), delete: (messageId: string, reason?: string) => ctx.client.channels.deletePin(messageId, ctx.channelId, reason), }; @@ -396,7 +409,7 @@ export class ThreadOnlyMethods extends DiscordBase { return this.edit({ default_thread_rate_limit_per_user: rate }, reason); } - thread(body: RESTPostAPIGuildForumThreadsJSONBody, reason?: string) { + thread(body: RESTPostAPIGuildForumThreadsJSONBody, reason?: string): Promise { return this.client.channels.thread(this.id, body, reason); } } @@ -421,7 +434,7 @@ export class VoiceChannelMethods extends DiscordBase { return this.edit({ video_quality_mode: VideoQualityMode[quality] }, reason); } - setVoiceState(status: string | null = null) { + setVoiceStatus(status: string | null = null) { return this.client.channels.setVoiceStatus(this.id, status); } @@ -435,7 +448,7 @@ export class VoiceChannelMethods extends DiscordBase { }); } - public async members(force?: boolean) { + public async members(force?: boolean): Promise> { const collection = new Collection(); const states = await this.states(); @@ -457,7 +470,7 @@ export class WebhookGuildMethods extends DiscordBase { static guild(ctx: MethodContext<{ guildId: string }>) { return { - list: () => ctx.client.webhooks.listFromGuild(ctx.guildId), + list: (): Promise => ctx.client.webhooks.listFromGuild(ctx.guildId), }; } } @@ -470,8 +483,9 @@ export class WebhookChannelMethods extends DiscordBase { static channel(ctx: MethodContext<{ channelId: string }>) { return { - list: () => ctx.client.webhooks.listFromChannel(ctx.channelId), - create: (body: RESTPostAPIChannelWebhookJSONBody) => ctx.client.webhooks.create(ctx.channelId, body), + list: (): Promise => ctx.client.webhooks.listFromChannel(ctx.channelId), + create: (body: RESTPostAPIChannelWebhookJSONBody): Promise => + ctx.client.webhooks.create(ctx.channelId, body), }; } }