fix: transformers types

This commit is contained in:
MARCROCK22 2024-12-21 22:47:38 -04:00
parent d8d6ff6b47
commit 7450d5d72f
49 changed files with 784 additions and 458 deletions

View File

@ -22,11 +22,11 @@
"license": "MIT", "license": "MIT",
"devDependencies": { "devDependencies": {
"@biomejs/biome": "1.9.4", "@biomejs/biome": "1.9.4",
"@commitlint/cli": "^19.6.0", "@commitlint/cli": "^19.6.1",
"@commitlint/config-conventional": "^19.6.0", "@commitlint/config-conventional": "^19.6.0",
"@types/node": "^22.10.1", "@types/node": "^22.10.2",
"husky": "^9.1.7", "husky": "^9.1.7",
"lint-staged": "^15.2.10", "lint-staged": "^15.2.11",
"typescript": "^5.7.2", "typescript": "^5.7.2",
"vitest": "^2.1.8" "vitest": "^2.1.8"
}, },

301
pnpm-lock.yaml generated
View File

@ -12,26 +12,26 @@ importers:
specifier: 1.9.4 specifier: 1.9.4
version: 1.9.4 version: 1.9.4
'@commitlint/cli': '@commitlint/cli':
specifier: ^19.6.0 specifier: ^19.6.1
version: 19.6.0(@types/node@22.10.1)(typescript@5.7.2) version: 19.6.1(@types/node@22.10.2)(typescript@5.7.2)
'@commitlint/config-conventional': '@commitlint/config-conventional':
specifier: ^19.6.0 specifier: ^19.6.0
version: 19.6.0 version: 19.6.0
'@types/node': '@types/node':
specifier: ^22.10.1 specifier: ^22.10.2
version: 22.10.1 version: 22.10.2
husky: husky:
specifier: ^9.1.7 specifier: ^9.1.7
version: 9.1.7 version: 9.1.7
lint-staged: lint-staged:
specifier: ^15.2.10 specifier: ^15.2.11
version: 15.2.10 version: 15.2.11
typescript: typescript:
specifier: ^5.7.2 specifier: ^5.7.2
version: 5.7.2 version: 5.7.2
vitest: vitest:
specifier: ^2.1.8 specifier: ^2.1.8
version: 2.1.8(@types/node@22.10.1) version: 2.1.8(@types/node@22.10.2)
packages: packages:
@ -96,8 +96,8 @@ packages:
cpu: [x64] cpu: [x64]
os: [win32] os: [win32]
'@commitlint/cli@19.6.0': '@commitlint/cli@19.6.1':
resolution: {integrity: sha512-v17BgGD9w5KnthaKxXnEg6KLq6DYiAxyiN44TpiRtqyW8NSq+Kx99mkEG8Qo6uu6cI5eMzMojW2muJxjmPnF8w==} resolution: {integrity: sha512-8hcyA6ZoHwWXC76BoC8qVOSr8xHy00LZhZpauiD0iO0VYbVhMnED0da85lTfIULxl7Lj4c6vZgF0Wu/ed1+jlQ==}
engines: {node: '>=v18'} engines: {node: '>=v18'}
hasBin: true hasBin: true
@ -129,8 +129,8 @@ packages:
resolution: {integrity: sha512-LRo7zDkXtcIrpco9RnfhOKeg8PAnE3oDDoalnrVU/EVaKHYBWYL1DlRR7+3AWn0JiBqD8yKOfetVxJGdEtZ0tg==} resolution: {integrity: sha512-LRo7zDkXtcIrpco9RnfhOKeg8PAnE3oDDoalnrVU/EVaKHYBWYL1DlRR7+3AWn0JiBqD8yKOfetVxJGdEtZ0tg==}
engines: {node: '>=v18'} engines: {node: '>=v18'}
'@commitlint/load@19.5.0': '@commitlint/load@19.6.1':
resolution: {integrity: sha512-INOUhkL/qaKqwcTUvCE8iIUf5XHsEPCLY9looJ/ipzi7jtGhgmtH7OOFiNvwYgH7mA8osUWOUDV8t4E2HAi4xA==} resolution: {integrity: sha512-kE4mRKWWNju2QpsCWt428XBvUH55OET2N4QKQ0bF85qS/XbsRGG1MiTByDNlEVpEPceMkDr46LNH95DtRwcsfA==}
engines: {node: '>=v18'} engines: {node: '>=v18'}
'@commitlint/message@19.5.0': '@commitlint/message@19.5.0':
@ -306,93 +306,98 @@ packages:
'@jridgewell/sourcemap-codec@1.5.0': '@jridgewell/sourcemap-codec@1.5.0':
resolution: {integrity: sha512-gv3ZRaISU3fjPAgNsriBRqGWQL6quFx04YMPW/zD8XMLsU32mhCCbfbO6KZFLjvYpCZ8zyDEgqsgf+PwPaM7GQ==} resolution: {integrity: sha512-gv3ZRaISU3fjPAgNsriBRqGWQL6quFx04YMPW/zD8XMLsU32mhCCbfbO6KZFLjvYpCZ8zyDEgqsgf+PwPaM7GQ==}
'@rollup/rollup-android-arm-eabi@4.28.0': '@rollup/rollup-android-arm-eabi@4.29.1':
resolution: {integrity: sha512-wLJuPLT6grGZsy34g4N1yRfYeouklTgPhH1gWXCYspenKYD0s3cR99ZevOGw5BexMNywkbV3UkjADisozBmpPQ==} resolution: {integrity: sha512-ssKhA8RNltTZLpG6/QNkCSge+7mBQGUqJRisZ2MDQcEGaK93QESEgWK2iOpIDZ7k9zPVkG5AS3ksvD5ZWxmItw==}
cpu: [arm] cpu: [arm]
os: [android] os: [android]
'@rollup/rollup-android-arm64@4.28.0': '@rollup/rollup-android-arm64@4.29.1':
resolution: {integrity: sha512-eiNkznlo0dLmVG/6wf+Ifi/v78G4d4QxRhuUl+s8EWZpDewgk7PX3ZyECUXU0Zq/Ca+8nU8cQpNC4Xgn2gFNDA==} resolution: {integrity: sha512-CaRfrV0cd+NIIcVVN/jx+hVLN+VRqnuzLRmfmlzpOzB87ajixsN/+9L5xNmkaUUvEbI5BmIKS+XTwXsHEb65Ew==}
cpu: [arm64] cpu: [arm64]
os: [android] os: [android]
'@rollup/rollup-darwin-arm64@4.28.0': '@rollup/rollup-darwin-arm64@4.29.1':
resolution: {integrity: sha512-lmKx9yHsppblnLQZOGxdO66gT77bvdBtr/0P+TPOseowE7D9AJoBw8ZDULRasXRWf1Z86/gcOdpBrV6VDUY36Q==} resolution: {integrity: sha512-2ORr7T31Y0Mnk6qNuwtyNmy14MunTAMx06VAPI6/Ju52W10zk1i7i5U3vlDRWjhOI5quBcrvhkCHyF76bI7kEw==}
cpu: [arm64] cpu: [arm64]
os: [darwin] os: [darwin]
'@rollup/rollup-darwin-x64@4.28.0': '@rollup/rollup-darwin-x64@4.29.1':
resolution: {integrity: sha512-8hxgfReVs7k9Js1uAIhS6zq3I+wKQETInnWQtgzt8JfGx51R1N6DRVy3F4o0lQwumbErRz52YqwjfvuwRxGv1w==} resolution: {integrity: sha512-j/Ej1oanzPjmN0tirRd5K2/nncAhS9W6ICzgxV+9Y5ZsP0hiGhHJXZ2JQ53iSSjj8m6cRY6oB1GMzNn2EUt6Ng==}
cpu: [x64] cpu: [x64]
os: [darwin] os: [darwin]
'@rollup/rollup-freebsd-arm64@4.28.0': '@rollup/rollup-freebsd-arm64@4.29.1':
resolution: {integrity: sha512-lA1zZB3bFx5oxu9fYud4+g1mt+lYXCoch0M0V/xhqLoGatbzVse0wlSQ1UYOWKpuSu3gyN4qEc0Dxf/DII1bhQ==} resolution: {integrity: sha512-91C//G6Dm/cv724tpt7nTyP+JdN12iqeXGFM1SqnljCmi5yTXriH7B1r8AD9dAZByHpKAumqP1Qy2vVNIdLZqw==}
cpu: [arm64] cpu: [arm64]
os: [freebsd] os: [freebsd]
'@rollup/rollup-freebsd-x64@4.28.0': '@rollup/rollup-freebsd-x64@4.29.1':
resolution: {integrity: sha512-aI2plavbUDjCQB/sRbeUZWX9qp12GfYkYSJOrdYTL/C5D53bsE2/nBPuoiJKoWp5SN78v2Vr8ZPnB+/VbQ2pFA==} resolution: {integrity: sha512-hEioiEQ9Dec2nIRoeHUP6hr1PSkXzQaCUyqBDQ9I9ik4gCXQZjJMIVzoNLBRGet+hIUb3CISMh9KXuCcWVW/8w==}
cpu: [x64] cpu: [x64]
os: [freebsd] os: [freebsd]
'@rollup/rollup-linux-arm-gnueabihf@4.28.0': '@rollup/rollup-linux-arm-gnueabihf@4.29.1':
resolution: {integrity: sha512-WXveUPKtfqtaNvpf0iOb0M6xC64GzUX/OowbqfiCSXTdi/jLlOmH0Ba94/OkiY2yTGTwteo4/dsHRfh5bDCZ+w==} resolution: {integrity: sha512-Py5vFd5HWYN9zxBv3WMrLAXY3yYJ6Q/aVERoeUFwiDGiMOWsMs7FokXihSOaT/PMWUty/Pj60XDQndK3eAfE6A==}
cpu: [arm] cpu: [arm]
os: [linux] os: [linux]
'@rollup/rollup-linux-arm-musleabihf@4.28.0': '@rollup/rollup-linux-arm-musleabihf@4.29.1':
resolution: {integrity: sha512-yLc3O2NtOQR67lI79zsSc7lk31xjwcaocvdD1twL64PK1yNaIqCeWI9L5B4MFPAVGEVjH5k1oWSGuYX1Wutxpg==} resolution: {integrity: sha512-RiWpGgbayf7LUcuSNIbahr0ys2YnEERD4gYdISA06wa0i8RALrnzflh9Wxii7zQJEB2/Eh74dX4y/sHKLWp5uQ==}
cpu: [arm] cpu: [arm]
os: [linux] os: [linux]
'@rollup/rollup-linux-arm64-gnu@4.28.0': '@rollup/rollup-linux-arm64-gnu@4.29.1':
resolution: {integrity: sha512-+P9G9hjEpHucHRXqesY+3X9hD2wh0iNnJXX/QhS/J5vTdG6VhNYMxJ2rJkQOxRUd17u5mbMLHM7yWGZdAASfcg==} resolution: {integrity: sha512-Z80O+taYxTQITWMjm/YqNoe9d10OX6kDh8X5/rFCMuPqsKsSyDilvfg+vd3iXIqtfmp+cnfL1UrYirkaF8SBZA==}
cpu: [arm64] cpu: [arm64]
os: [linux] os: [linux]
'@rollup/rollup-linux-arm64-musl@4.28.0': '@rollup/rollup-linux-arm64-musl@4.29.1':
resolution: {integrity: sha512-1xsm2rCKSTpKzi5/ypT5wfc+4bOGa/9yI/eaOLW0oMs7qpC542APWhl4A37AENGZ6St6GBMWhCCMM6tXgTIplw==} resolution: {integrity: sha512-fOHRtF9gahwJk3QVp01a/GqS4hBEZCV1oKglVVq13kcK3NeVlS4BwIFzOHDbmKzt3i0OuHG4zfRP0YoG5OF/rA==}
cpu: [arm64] cpu: [arm64]
os: [linux] os: [linux]
'@rollup/rollup-linux-powerpc64le-gnu@4.28.0': '@rollup/rollup-linux-loongarch64-gnu@4.29.1':
resolution: {integrity: sha512-zgWxMq8neVQeXL+ouSf6S7DoNeo6EPgi1eeqHXVKQxqPy1B2NvTbaOUWPn/7CfMKL7xvhV0/+fq/Z/J69g1WAQ==} 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] cpu: [ppc64]
os: [linux] os: [linux]
'@rollup/rollup-linux-riscv64-gnu@4.28.0': '@rollup/rollup-linux-riscv64-gnu@4.29.1':
resolution: {integrity: sha512-VEdVYacLniRxbRJLNtzwGt5vwS0ycYshofI7cWAfj7Vg5asqj+pt+Q6x4n+AONSZW/kVm+5nklde0qs2EUwU2g==} resolution: {integrity: sha512-G5pn0NChlbRM8OJWpJFMX4/i8OEU538uiSv0P6roZcbpe/WfhEO+AT8SHVKfp8qhDQzaz7Q+1/ixMy7hBRidnQ==}
cpu: [riscv64] cpu: [riscv64]
os: [linux] os: [linux]
'@rollup/rollup-linux-s390x-gnu@4.28.0': '@rollup/rollup-linux-s390x-gnu@4.29.1':
resolution: {integrity: sha512-LQlP5t2hcDJh8HV8RELD9/xlYtEzJkm/aWGsauvdO2ulfl3QYRjqrKW+mGAIWP5kdNCBheqqqYIGElSRCaXfpw==} resolution: {integrity: sha512-WM9lIkNdkhVwiArmLxFXpWndFGuOka4oJOZh8EP3Vb8q5lzdSCBuhjavJsw68Q9AKDGeOOIHYzYm4ZFvmWez5g==}
cpu: [s390x] cpu: [s390x]
os: [linux] os: [linux]
'@rollup/rollup-linux-x64-gnu@4.28.0': '@rollup/rollup-linux-x64-gnu@4.29.1':
resolution: {integrity: sha512-Nl4KIzteVEKE9BdAvYoTkW19pa7LR/RBrT6F1dJCV/3pbjwDcaOq+edkP0LXuJ9kflW/xOK414X78r+K84+msw==} resolution: {integrity: sha512-87xYCwb0cPGZFoGiErT1eDcssByaLX4fc0z2nRM6eMtV9njAfEE6OW3UniAoDhX4Iq5xQVpE6qO9aJbCFumKYQ==}
cpu: [x64] cpu: [x64]
os: [linux] os: [linux]
'@rollup/rollup-linux-x64-musl@4.28.0': '@rollup/rollup-linux-x64-musl@4.29.1':
resolution: {integrity: sha512-eKpJr4vBDOi4goT75MvW+0dXcNUqisK4jvibY9vDdlgLx+yekxSm55StsHbxUsRxSTt3JEQvlr3cGDkzcSP8bw==} resolution: {integrity: sha512-xufkSNppNOdVRCEC4WKvlR1FBDyqCSCpQeMMgv9ZyXqqtKBfkw1yfGMTUTs9Qsl6WQbJnsGboWCp7pJGkeMhKA==}
cpu: [x64] cpu: [x64]
os: [linux] os: [linux]
'@rollup/rollup-win32-arm64-msvc@4.28.0': '@rollup/rollup-win32-arm64-msvc@4.29.1':
resolution: {integrity: sha512-Vi+WR62xWGsE/Oj+mD0FNAPY2MEox3cfyG0zLpotZdehPFXwz6lypkGs5y38Jd/NVSbOD02aVad6q6QYF7i8Bg==} resolution: {integrity: sha512-F2OiJ42m77lSkizZQLuC+jiZ2cgueWQL5YC9tjo3AgaEw+KJmVxHGSyQfDUoYR9cci0lAywv2Clmckzulcq6ig==}
cpu: [arm64] cpu: [arm64]
os: [win32] os: [win32]
'@rollup/rollup-win32-ia32-msvc@4.28.0': '@rollup/rollup-win32-ia32-msvc@4.29.1':
resolution: {integrity: sha512-kN/Vpip8emMLn/eOza+4JwqDZBL6MPNpkdaEsgUtW1NYN3DZvZqSQrbKzJcTL6hd8YNmFTn7XGWMwccOcJBL0A==} resolution: {integrity: sha512-rYRe5S0FcjlOBZQHgbTKNrqxCBUmgDJem/VQTCcTnA2KCabYSWQDrytOzX7avb79cAAweNmMUb/Zw18RNd4mng==}
cpu: [ia32] cpu: [ia32]
os: [win32] os: [win32]
'@rollup/rollup-win32-x64-msvc@4.28.0': '@rollup/rollup-win32-x64-msvc@4.29.1':
resolution: {integrity: sha512-Bvno2/aZT6usSa7lRDL2+hMjVAGjuqaymF1ApZm31JXzniR/hvr14jpU+/z4X6Gt5BPlzosscyJZGUvguXIqeQ==} resolution: {integrity: sha512-+10CMg9vt1MoHj6x1pxyjPSMjHTIlqs8/tBztXvPAx24SKs9jwVnKqHJumlH/IzhaPUaj3T6T6wfZr8okdXaIg==}
cpu: [x64] cpu: [x64]
os: [win32] os: [win32]
@ -402,8 +407,8 @@ packages:
'@types/estree@1.0.6': '@types/estree@1.0.6':
resolution: {integrity: sha512-AYnb1nQyY49te+VRAVgmzfcgjYS91mY5P0TKUDCLEM+gNnA+3T6rWITXRLYCpahpqSQbN5cE+gHpnPyXjHWxcw==} resolution: {integrity: sha512-AYnb1nQyY49te+VRAVgmzfcgjYS91mY5P0TKUDCLEM+gNnA+3T6rWITXRLYCpahpqSQbN5cE+gHpnPyXjHWxcw==}
'@types/node@22.10.1': '@types/node@22.10.2':
resolution: {integrity: sha512-qKgsUwfHZV2WCWLAnVP1JqnpE6Im6h3Y0+fYgMTasNQ7V++CBX5OT1as0g0f+OyubbFqhf6XVNIsmN4IIhEgGQ==} resolution: {integrity: sha512-Xxr6BBRCAOQixvonOye19wnzyDiUtTeqldOOmj3CkeblonbccA12PFwlufvRdrpjXxqnmUaeiU5EOA+7s5diUQ==}
'@vitest/expect@2.1.8': '@vitest/expect@2.1.8':
resolution: {integrity: sha512-8ytZ/fFHq2g4PJVAtDX57mayemKgDR6X3Oa2Foro+EygiOJHUXhCqBAAKQYYajZpFoIfvBCF1j6R6IYRSIUFuw==} resolution: {integrity: sha512-8ytZ/fFHq2g4PJVAtDX57mayemKgDR6X3Oa2Foro+EygiOJHUXhCqBAAKQYYajZpFoIfvBCF1j6R6IYRSIUFuw==}
@ -491,6 +496,10 @@ packages:
resolution: {integrity: sha512-dLitG79d+GV1Nb/VYcCDFivJeK1hiukt9QjRNVOsUtTy1rR1YJsmpGGTZ3qJos+uw7WmWF4wUwBd9jxjocFC2w==} resolution: {integrity: sha512-dLitG79d+GV1Nb/VYcCDFivJeK1hiukt9QjRNVOsUtTy1rR1YJsmpGGTZ3qJos+uw7WmWF4wUwBd9jxjocFC2w==}
engines: {node: ^12.17.0 || ^14.13 || >=16.0.0} 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: check-error@2.1.1:
resolution: {integrity: sha512-OAlb+T7V4Op9OwdkjmguYRqncdlx5JiofwOAUkmTF+jNdHwzTaTs4sRAGpzLF3oOz5xAyDGrPgeIDFQmDOTiJw==} resolution: {integrity: sha512-OAlb+T7V4Op9OwdkjmguYRqncdlx5JiofwOAUkmTF+jNdHwzTaTs4sRAGpzLF3oOz5xAyDGrPgeIDFQmDOTiJw==}
engines: {node: '>= 16'} engines: {node: '>= 16'}
@ -537,13 +546,13 @@ packages:
engines: {node: '>=16'} engines: {node: '>=16'}
hasBin: true hasBin: true
cosmiconfig-typescript-loader@5.1.0: cosmiconfig-typescript-loader@6.1.0:
resolution: {integrity: sha512-7PtBB+6FdsOvZyJtlF3hEPpACq7RQX6BVGsgC7/lfVXnKMvNCu/XY3ykreqG5w/rBNdu2z8LCIKoF3kpHHdHlA==} resolution: {integrity: sha512-tJ1w35ZRUiM5FeTzT7DtYWAFFv37ZLqSRkGi2oeCK1gPhvaWjkAtfXvLmvE1pRfxxp9aQo6ba/Pvg1dKj05D4g==}
engines: {node: '>=v16'} engines: {node: '>=v18'}
peerDependencies: peerDependencies:
'@types/node': '*' '@types/node': '*'
cosmiconfig: '>=8.2' cosmiconfig: '>=9'
typescript: '>=4' typescript: '>=5'
cosmiconfig@9.0.0: cosmiconfig@9.0.0:
resolution: {integrity: sha512-itvL5h8RETACmOTFc4UfIyB2RfEHi71Ax6E/PivVxq9NseKbOWpeyHEOIbmAw1rs8Ak0VursQNww7lf7YtUwzg==} resolution: {integrity: sha512-itvL5h8RETACmOTFc4UfIyB2RfEHi71Ax6E/PivVxq9NseKbOWpeyHEOIbmAw1rs8Ak0VursQNww7lf7YtUwzg==}
@ -562,8 +571,8 @@ packages:
resolution: {integrity: sha512-wAV9QHOsNbwnWdNW2FYvE1P56wtgSbM+3SZcdGiWQILwVjACCXDCI3Ai8QlCjMDB8YK5zySiXZYBiwGmNY3lnw==} resolution: {integrity: sha512-wAV9QHOsNbwnWdNW2FYvE1P56wtgSbM+3SZcdGiWQILwVjACCXDCI3Ai8QlCjMDB8YK5zySiXZYBiwGmNY3lnw==}
engines: {node: '>=12'} engines: {node: '>=12'}
debug@4.3.7: debug@4.4.0:
resolution: {integrity: sha512-Er2nc/H7RrMXZBFCEim6TCmMk02Z8vLC2Rbi1KEBggpo0fS6l0S1nnapwmIi3yW/+GOJap1Krg4w0Hg80oCqgQ==} resolution: {integrity: sha512-6WTZ/IxCY/T6BALoZHaE4ctp9xm+Z5kY/pzYaCHRFeyVhojxlrm+46y68HA6hr0TcwEssoxNiDEUJQjfPZ/RYA==}
engines: {node: '>=6.0'} engines: {node: '>=6.0'}
peerDependencies: peerDependencies:
supports-color: '*' supports-color: '*'
@ -716,8 +725,8 @@ packages:
isexe@2.0.0: isexe@2.0.0:
resolution: {integrity: sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==} resolution: {integrity: sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==}
jiti@1.21.6: jiti@2.4.2:
resolution: {integrity: sha512-2yTgeWTWzMWkHu6Jp9NKgePDaYHbntiwvYuuJLbbN9vl7DC9DvXKOB2BC3ZZ92D3cvV/aflH0osDfwpHepQ53w==} resolution: {integrity: sha512-rg9zJN+G4n2nfJl5MW3BMygZX56zKPNVEYYqq7adpmMh4Jn2QNEwhvQlFy6jPVdcod7txZtKHWnyZiA3a0zP7A==}
hasBin: true hasBin: true
js-tokens@4.0.0: js-tokens@4.0.0:
@ -737,15 +746,15 @@ packages:
resolution: {integrity: sha512-POQXvpdL69+CluYsillJ7SUhKvytYjW9vG/GKpnf+xP8UWgYEM/RaMzHHofbALDiKbbP1W8UEYmgGl39WkPZsg==} resolution: {integrity: sha512-POQXvpdL69+CluYsillJ7SUhKvytYjW9vG/GKpnf+xP8UWgYEM/RaMzHHofbALDiKbbP1W8UEYmgGl39WkPZsg==}
engines: {'0': node >= 0.2.0} engines: {'0': node >= 0.2.0}
lilconfig@3.1.2: lilconfig@3.1.3:
resolution: {integrity: sha512-eop+wDAvpItUys0FWkHIKeC9ybYrTGbU41U5K7+bttZZeohvnY7M9dZ5kB21GNWiFT2q1OoPTvncPCgSOVO5ow==} resolution: {integrity: sha512-/vlFKAoH5Cgt3Ie+JLhRbwOsCQePABiU3tJ1egGvyQ+33R/vcwM2Zl2QR/LzjsBeItPt3oSVXapn+m4nQDvpzw==}
engines: {node: '>=14'} engines: {node: '>=14'}
lines-and-columns@1.2.4: lines-and-columns@1.2.4:
resolution: {integrity: sha512-7ylylesZQ/PV29jhEDl3Ufjo6ZX7gCqJr5F7PKrqc93v7fzSymt1BpwEU8nAUXs8qzzvqhbjhK5QZg6Mt/HkBg==} resolution: {integrity: sha512-7ylylesZQ/PV29jhEDl3Ufjo6ZX7gCqJr5F7PKrqc93v7fzSymt1BpwEU8nAUXs8qzzvqhbjhK5QZg6Mt/HkBg==}
lint-staged@15.2.10: lint-staged@15.2.11:
resolution: {integrity: sha512-5dY5t743e1byO19P9I4b3x8HJwalIznL5E1FWYnU6OWw33KxNBSLAc6Cy7F2PsFEO8FKnLwjwm5hx7aMF0jzZg==} resolution: {integrity: sha512-Ev6ivCTYRTGs9ychvpVw35m/bcNDuBN+mnTeObCL5h+boS5WzBEC6LHI4I9F/++sZm1m+J2LEiy0gxL/R9TBqQ==}
engines: {node: '>=18.12.0'} engines: {node: '>=18.12.0'}
hasBin: true hasBin: true
@ -791,8 +800,8 @@ packages:
loupe@3.1.2: loupe@3.1.2:
resolution: {integrity: sha512-23I4pFZHmAemUnz8WZXbYRSKYj801VDaNv9ETuMh7IrMc7VuVVSo+Z9iLE3ni30+U48iDWfi30d3twAXBYmnCg==} resolution: {integrity: sha512-23I4pFZHmAemUnz8WZXbYRSKYj801VDaNv9ETuMh7IrMc7VuVVSo+Z9iLE3ni30+U48iDWfi30d3twAXBYmnCg==}
magic-string@0.30.14: magic-string@0.30.17:
resolution: {integrity: sha512-5c99P1WKTed11ZC0HMJOj6CDIue6F8ySu+bJL+85q1zBEIY8IklrJ1eiKC2NDRh3Ct3FcvmJPyQHb9erXMTJNw==} resolution: {integrity: sha512-sNPKHvyjVf7gyjwS4xGTaW/mCnF8wnjtifKBEhxfZ7E/S8tQ0rssrwGNn6q8JH/ohItJfSQp9mBtQYuTlH5QnA==}
meow@12.1.1: meow@12.1.1:
resolution: {integrity: sha512-BhXM0Au22RwUneMPwSCnyhTOizdWoIEPU9sp0Aqa1PnDMR5Wv2FGXYDjuzJEIX+Eo2Rb8xuYe5jrnm5QowQFkw==} resolution: {integrity: sha512-BhXM0Au22RwUneMPwSCnyhTOizdWoIEPU9sp0Aqa1PnDMR5Wv2FGXYDjuzJEIX+Eo2Rb8xuYe5jrnm5QowQFkw==}
@ -910,8 +919,8 @@ packages:
rfdc@1.4.1: rfdc@1.4.1:
resolution: {integrity: sha512-q1b3N5QkRUWUl7iyylaaj3kOpIT0N2i9MqIEQXP73GVsN9cw3fdx8X63cEmWhJGi2PPCF23Ijp7ktmd39rawIA==} resolution: {integrity: sha512-q1b3N5QkRUWUl7iyylaaj3kOpIT0N2i9MqIEQXP73GVsN9cw3fdx8X63cEmWhJGi2PPCF23Ijp7ktmd39rawIA==}
rollup@4.28.0: rollup@4.29.1:
resolution: {integrity: sha512-G9GOrmgWHBma4YfCcX8PjH0qhXSdH8B4HDE2o4/jaxj93S4DPCIDoLcXz99eWMji4hB29UFCEd7B2gwGJDR9cQ==} resolution: {integrity: sha512-RaJ45M/kmJUzSWDs1Nnd5DdV4eerC98idtUOVr6FfKcgxqvjwHmxc5upLF9qZU9EpsVzzhleFahrT3shLuJzIw==}
engines: {node: '>=18.0.0', npm: '>=8.0.0'} engines: {node: '>=18.0.0', npm: '>=8.0.0'}
hasBin: true hasBin: true
@ -1105,8 +1114,8 @@ packages:
resolution: {integrity: sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA==} resolution: {integrity: sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA==}
engines: {node: '>=10'} engines: {node: '>=10'}
yaml@2.5.1: yaml@2.6.1:
resolution: {integrity: sha512-bLQOjaX/ADgQ20isPJRvF0iRUHIxVhYvr53Of7wGcWlO2jvtUlH5m87DsmulFVxRpNLOnI4tB6p/oh8D7kpn9Q==} resolution: {integrity: sha512-7r0XPzioN/Q9kXBro/XPnA6kznR73DHq+GXh5ON7ZozRO6aMjbmiBuKste2wslTFkC5d1dw0GooOCepZXJ2SAg==}
engines: {node: '>= 14'} engines: {node: '>= 14'}
hasBin: true hasBin: true
@ -1167,11 +1176,11 @@ snapshots:
'@biomejs/cli-win32-x64@1.9.4': '@biomejs/cli-win32-x64@1.9.4':
optional: true 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: dependencies:
'@commitlint/format': 19.5.0 '@commitlint/format': 19.5.0
'@commitlint/lint': 19.6.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/read': 19.5.0
'@commitlint/types': 19.5.0 '@commitlint/types': 19.5.0
tinyexec: 0.3.1 tinyexec: 0.3.1
@ -1204,7 +1213,7 @@ snapshots:
'@commitlint/format@19.5.0': '@commitlint/format@19.5.0':
dependencies: dependencies:
'@commitlint/types': 19.5.0 '@commitlint/types': 19.5.0
chalk: 5.3.0 chalk: 5.4.1
'@commitlint/is-ignored@19.6.0': '@commitlint/is-ignored@19.6.0':
dependencies: dependencies:
@ -1218,15 +1227,15 @@ snapshots:
'@commitlint/rules': 19.6.0 '@commitlint/rules': 19.6.0
'@commitlint/types': 19.5.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: dependencies:
'@commitlint/config-validator': 19.5.0 '@commitlint/config-validator': 19.5.0
'@commitlint/execute-rule': 19.5.0 '@commitlint/execute-rule': 19.5.0
'@commitlint/resolve-extends': 19.5.0 '@commitlint/resolve-extends': 19.5.0
'@commitlint/types': 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: 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.isplainobject: 4.0.6
lodash.merge: 4.6.2 lodash.merge: 4.6.2
lodash.uniq: 4.5.0 lodash.uniq: 4.5.0
@ -1275,7 +1284,7 @@ snapshots:
'@commitlint/types@19.5.0': '@commitlint/types@19.5.0':
dependencies: dependencies:
'@types/conventional-commits-parser': 5.0.1 '@types/conventional-commits-parser': 5.0.1
chalk: 5.3.0 chalk: 5.4.1
'@esbuild/aix-ppc64@0.21.5': '@esbuild/aix-ppc64@0.21.5':
optional: true optional: true
@ -1348,67 +1357,70 @@ snapshots:
'@jridgewell/sourcemap-codec@1.5.0': {} '@jridgewell/sourcemap-codec@1.5.0': {}
'@rollup/rollup-android-arm-eabi@4.28.0': '@rollup/rollup-android-arm-eabi@4.29.1':
optional: true optional: true
'@rollup/rollup-android-arm64@4.28.0': '@rollup/rollup-android-arm64@4.29.1':
optional: true optional: true
'@rollup/rollup-darwin-arm64@4.28.0': '@rollup/rollup-darwin-arm64@4.29.1':
optional: true optional: true
'@rollup/rollup-darwin-x64@4.28.0': '@rollup/rollup-darwin-x64@4.29.1':
optional: true optional: true
'@rollup/rollup-freebsd-arm64@4.28.0': '@rollup/rollup-freebsd-arm64@4.29.1':
optional: true optional: true
'@rollup/rollup-freebsd-x64@4.28.0': '@rollup/rollup-freebsd-x64@4.29.1':
optional: true optional: true
'@rollup/rollup-linux-arm-gnueabihf@4.28.0': '@rollup/rollup-linux-arm-gnueabihf@4.29.1':
optional: true optional: true
'@rollup/rollup-linux-arm-musleabihf@4.28.0': '@rollup/rollup-linux-arm-musleabihf@4.29.1':
optional: true optional: true
'@rollup/rollup-linux-arm64-gnu@4.28.0': '@rollup/rollup-linux-arm64-gnu@4.29.1':
optional: true optional: true
'@rollup/rollup-linux-arm64-musl@4.28.0': '@rollup/rollup-linux-arm64-musl@4.29.1':
optional: true optional: true
'@rollup/rollup-linux-powerpc64le-gnu@4.28.0': '@rollup/rollup-linux-loongarch64-gnu@4.29.1':
optional: true optional: true
'@rollup/rollup-linux-riscv64-gnu@4.28.0': '@rollup/rollup-linux-powerpc64le-gnu@4.29.1':
optional: true optional: true
'@rollup/rollup-linux-s390x-gnu@4.28.0': '@rollup/rollup-linux-riscv64-gnu@4.29.1':
optional: true optional: true
'@rollup/rollup-linux-x64-gnu@4.28.0': '@rollup/rollup-linux-s390x-gnu@4.29.1':
optional: true optional: true
'@rollup/rollup-linux-x64-musl@4.28.0': '@rollup/rollup-linux-x64-gnu@4.29.1':
optional: true optional: true
'@rollup/rollup-win32-arm64-msvc@4.28.0': '@rollup/rollup-linux-x64-musl@4.29.1':
optional: true optional: true
'@rollup/rollup-win32-ia32-msvc@4.28.0': '@rollup/rollup-win32-arm64-msvc@4.29.1':
optional: true 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 optional: true
'@types/conventional-commits-parser@5.0.1': '@types/conventional-commits-parser@5.0.1':
dependencies: dependencies:
'@types/node': 22.10.1 '@types/node': 22.10.2
'@types/estree@1.0.6': {} '@types/estree@1.0.6': {}
'@types/node@22.10.1': '@types/node@22.10.2':
dependencies: dependencies:
undici-types: 6.20.0 undici-types: 6.20.0
@ -1419,13 +1431,13 @@ snapshots:
chai: 5.1.2 chai: 5.1.2
tinyrainbow: 1.2.0 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: dependencies:
'@vitest/spy': 2.1.8 '@vitest/spy': 2.1.8
estree-walker: 3.0.3 estree-walker: 3.0.3
magic-string: 0.30.14 magic-string: 0.30.17
optionalDependencies: 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': '@vitest/pretty-format@2.1.8':
dependencies: dependencies:
@ -1439,7 +1451,7 @@ snapshots:
'@vitest/snapshot@2.1.8': '@vitest/snapshot@2.1.8':
dependencies: dependencies:
'@vitest/pretty-format': 2.1.8 '@vitest/pretty-format': 2.1.8
magic-string: 0.30.14 magic-string: 0.30.17
pathe: 1.1.2 pathe: 1.1.2
'@vitest/spy@2.1.8': '@vitest/spy@2.1.8':
@ -1502,6 +1514,8 @@ snapshots:
chalk@5.3.0: {} chalk@5.3.0: {}
chalk@5.4.1: {}
check-error@2.1.1: {} check-error@2.1.1: {}
cli-cursor@5.0.0: cli-cursor@5.0.0:
@ -1549,11 +1563,11 @@ snapshots:
meow: 12.1.1 meow: 12.1.1
split2: 4.2.0 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: dependencies:
'@types/node': 22.10.1 '@types/node': 22.10.2
cosmiconfig: 9.0.0(typescript@5.7.2) cosmiconfig: 9.0.0(typescript@5.7.2)
jiti: 1.21.6 jiti: 2.4.2
typescript: 5.7.2 typescript: 5.7.2
cosmiconfig@9.0.0(typescript@5.7.2): cosmiconfig@9.0.0(typescript@5.7.2):
@ -1573,7 +1587,7 @@ snapshots:
dargs@8.1.0: {} dargs@8.1.0: {}
debug@4.3.7: debug@4.4.0:
dependencies: dependencies:
ms: 2.1.3 ms: 2.1.3
@ -1713,7 +1727,7 @@ snapshots:
isexe@2.0.0: {} isexe@2.0.0: {}
jiti@1.21.6: {} jiti@2.4.2: {}
js-tokens@4.0.0: {} js-tokens@4.0.0: {}
@ -1727,22 +1741,22 @@ snapshots:
jsonparse@1.3.1: {} jsonparse@1.3.1: {}
lilconfig@3.1.2: {} lilconfig@3.1.3: {}
lines-and-columns@1.2.4: {} lines-and-columns@1.2.4: {}
lint-staged@15.2.10: lint-staged@15.2.11:
dependencies: dependencies:
chalk: 5.3.0 chalk: 5.3.0
commander: 12.1.0 commander: 12.1.0
debug: 4.3.7 debug: 4.4.0
execa: 8.0.1 execa: 8.0.1
lilconfig: 3.1.2 lilconfig: 3.1.3
listr2: 8.2.5 listr2: 8.2.5
micromatch: 4.0.8 micromatch: 4.0.8
pidtree: 0.6.0 pidtree: 0.6.0
string-argv: 0.3.2 string-argv: 0.3.2
yaml: 2.5.1 yaml: 2.6.1
transitivePeerDependencies: transitivePeerDependencies:
- supports-color - supports-color
@ -1787,7 +1801,7 @@ snapshots:
loupe@3.1.2: {} loupe@3.1.2: {}
magic-string@0.30.14: magic-string@0.30.17:
dependencies: dependencies:
'@jridgewell/sourcemap-codec': 1.5.0 '@jridgewell/sourcemap-codec': 1.5.0
@ -1878,28 +1892,29 @@ snapshots:
rfdc@1.4.1: {} rfdc@1.4.1: {}
rollup@4.28.0: rollup@4.29.1:
dependencies: dependencies:
'@types/estree': 1.0.6 '@types/estree': 1.0.6
optionalDependencies: optionalDependencies:
'@rollup/rollup-android-arm-eabi': 4.28.0 '@rollup/rollup-android-arm-eabi': 4.29.1
'@rollup/rollup-android-arm64': 4.28.0 '@rollup/rollup-android-arm64': 4.29.1
'@rollup/rollup-darwin-arm64': 4.28.0 '@rollup/rollup-darwin-arm64': 4.29.1
'@rollup/rollup-darwin-x64': 4.28.0 '@rollup/rollup-darwin-x64': 4.29.1
'@rollup/rollup-freebsd-arm64': 4.28.0 '@rollup/rollup-freebsd-arm64': 4.29.1
'@rollup/rollup-freebsd-x64': 4.28.0 '@rollup/rollup-freebsd-x64': 4.29.1
'@rollup/rollup-linux-arm-gnueabihf': 4.28.0 '@rollup/rollup-linux-arm-gnueabihf': 4.29.1
'@rollup/rollup-linux-arm-musleabihf': 4.28.0 '@rollup/rollup-linux-arm-musleabihf': 4.29.1
'@rollup/rollup-linux-arm64-gnu': 4.28.0 '@rollup/rollup-linux-arm64-gnu': 4.29.1
'@rollup/rollup-linux-arm64-musl': 4.28.0 '@rollup/rollup-linux-arm64-musl': 4.29.1
'@rollup/rollup-linux-powerpc64le-gnu': 4.28.0 '@rollup/rollup-linux-loongarch64-gnu': 4.29.1
'@rollup/rollup-linux-riscv64-gnu': 4.28.0 '@rollup/rollup-linux-powerpc64le-gnu': 4.29.1
'@rollup/rollup-linux-s390x-gnu': 4.28.0 '@rollup/rollup-linux-riscv64-gnu': 4.29.1
'@rollup/rollup-linux-x64-gnu': 4.28.0 '@rollup/rollup-linux-s390x-gnu': 4.29.1
'@rollup/rollup-linux-x64-musl': 4.28.0 '@rollup/rollup-linux-x64-gnu': 4.29.1
'@rollup/rollup-win32-arm64-msvc': 4.28.0 '@rollup/rollup-linux-x64-musl': 4.29.1
'@rollup/rollup-win32-ia32-msvc': 4.28.0 '@rollup/rollup-win32-arm64-msvc': 4.29.1
'@rollup/rollup-win32-x64-msvc': 4.28.0 '@rollup/rollup-win32-ia32-msvc': 4.29.1
'@rollup/rollup-win32-x64-msvc': 4.29.1
fsevents: 2.3.3 fsevents: 2.3.3
semver@7.6.3: {} semver@7.6.3: {}
@ -1980,13 +1995,13 @@ snapshots:
unicorn-magic@0.1.0: {} 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: dependencies:
cac: 6.7.14 cac: 6.7.14
debug: 4.3.7 debug: 4.4.0
es-module-lexer: 1.5.4 es-module-lexer: 1.5.4
pathe: 1.1.2 pathe: 1.1.2
vite: 5.4.11(@types/node@22.10.1) vite: 5.4.11(@types/node@22.10.2)
transitivePeerDependencies: transitivePeerDependencies:
- '@types/node' - '@types/node'
- less - less
@ -1998,39 +2013,39 @@ snapshots:
- supports-color - supports-color
- terser - terser
vite@5.4.11(@types/node@22.10.1): vite@5.4.11(@types/node@22.10.2):
dependencies: dependencies:
esbuild: 0.21.5 esbuild: 0.21.5
postcss: 8.4.49 postcss: 8.4.49
rollup: 4.28.0 rollup: 4.29.1
optionalDependencies: optionalDependencies:
'@types/node': 22.10.1 '@types/node': 22.10.2
fsevents: 2.3.3 fsevents: 2.3.3
vitest@2.1.8(@types/node@22.10.1): vitest@2.1.8(@types/node@22.10.2):
dependencies: dependencies:
'@vitest/expect': 2.1.8 '@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/pretty-format': 2.1.8
'@vitest/runner': 2.1.8 '@vitest/runner': 2.1.8
'@vitest/snapshot': 2.1.8 '@vitest/snapshot': 2.1.8
'@vitest/spy': 2.1.8 '@vitest/spy': 2.1.8
'@vitest/utils': 2.1.8 '@vitest/utils': 2.1.8
chai: 5.1.2 chai: 5.1.2
debug: 4.3.7 debug: 4.4.0
expect-type: 1.1.0 expect-type: 1.1.0
magic-string: 0.30.14 magic-string: 0.30.17
pathe: 1.1.2 pathe: 1.1.2
std-env: 3.8.0 std-env: 3.8.0
tinybench: 2.9.0 tinybench: 2.9.0
tinyexec: 0.3.1 tinyexec: 0.3.1
tinypool: 1.0.2 tinypool: 1.0.2
tinyrainbow: 1.2.0 tinyrainbow: 1.2.0
vite: 5.4.11(@types/node@22.10.1) vite: 5.4.11(@types/node@22.10.2)
vite-node: 2.1.8(@types/node@22.10.1) vite-node: 2.1.8(@types/node@22.10.2)
why-is-node-running: 2.3.0 why-is-node-running: 2.3.0
optionalDependencies: optionalDependencies:
'@types/node': 22.10.1 '@types/node': 22.10.2
transitivePeerDependencies: transitivePeerDependencies:
- less - less
- lightningcss - lightningcss
@ -2065,7 +2080,7 @@ snapshots:
y18n@5.0.8: {} y18n@5.0.8: {}
yaml@2.5.1: {} yaml@2.6.1: {}
yargs-parser@21.1.1: {} yargs-parser@21.1.1: {}

View File

@ -1,4 +1,4 @@
import type { AllChannels, InferWithPrefix, Message, ReturnCache } from '../..'; import type { ReturnCache } from '../..';
import type { Client, WorkerClient } from '../../client'; import type { Client, WorkerClient } from '../../client';
import type { import type {
GuildMemberStructure, GuildMemberStructure,
@ -6,16 +6,17 @@ import type {
InteractionGuildMemberStructure, InteractionGuildMemberStructure,
MessageStructure, MessageStructure,
OptionResolverStructure, OptionResolverStructure,
UserStructure,
WebhookMessageStructure, WebhookMessageStructure,
} from '../../client/transformers'; } from '../../client/transformers';
import type { If, MakeRequired, UnionToTuple, When } from '../../common'; import type { If, MakeRequired, UnionToTuple, When } from '../../common';
import type { InteractionCreateBodyRequest, InteractionMessageUpdateBodyRequest } from '../../common/types/write'; 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 { MessageFlags } from '../../types';
import { BaseContext } from '../basecontext'; import { BaseContext } from '../basecontext';
import type { RegisteredMiddlewares } from '../decorators'; import type { RegisteredMiddlewares } from '../decorators';
import type { Command, ContextOptions, OptionsRecord, SubCommand } from './chat'; 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<T extends OptionsRecord = {}, M extends keyof RegisteredMiddlewares = never> export interface CommandContext<T extends OptionsRecord = {}, M extends keyof RegisteredMiddlewares = never>
extends BaseContext, extends BaseContext,
@ -202,7 +203,7 @@ export class CommandContext<
return this.interaction?.channelId || (this.message! as MessageStructure).channelId; return this.interaction?.channelId || (this.message! as MessageStructure).channelId;
} }
get author() { get author(): UserStructure {
return this.interaction?.user || (this.message! as MessageStructure).author; return this.interaction?.user || (this.message! as MessageStructure).author;
} }

View File

@ -1,11 +1,18 @@
import type { ReturnCache } from '../..'; import type { ReturnCache } from '../..';
import type { GuildMemberStructure, GuildStructure } from '../../client/transformers'; import type {
GuildMemberStructure,
GuildStructure,
InteractionGuildMemberStructure,
UserStructure,
WebhookMessageStructure,
} from '../../client/transformers';
import type { import type {
InteractionCreateBodyRequest, InteractionCreateBodyRequest,
InteractionMessageUpdateBodyRequest, InteractionMessageUpdateBodyRequest,
MakeRequired, MakeRequired,
ModalCreateBodyRequest, ModalCreateBodyRequest,
UnionToTuple, UnionToTuple,
When,
} from '../../common'; } from '../../common';
import type { AllChannels, EntryPointInteraction } from '../../structures'; import type { AllChannels, EntryPointInteraction } from '../../structures';
import { MessageFlags } from '../../types'; import { MessageFlags } from '../../types';
@ -37,7 +44,10 @@ export class EntryPointContext<M extends keyof RegisteredMiddlewares = never> ex
return this.command.name; return this.command.name;
} }
write<WR extends boolean = false>(body: InteractionCreateBodyRequest, withResponse?: WR) { write<WR extends boolean = false>(
body: InteractionCreateBodyRequest,
withResponse?: WR,
): Promise<When<WR, WebhookMessageStructure, void>> {
return this.interaction.write<WR>(body, withResponse); return this.interaction.write<WR>(body, withResponse);
} }
@ -45,11 +55,14 @@ export class EntryPointContext<M extends keyof RegisteredMiddlewares = never> ex
return this.interaction.modal(body); return this.interaction.modal(body);
} }
deferReply<WR extends boolean = false>(ephemeral = false, withResponse?: WR) { deferReply<WR extends boolean = false>(
ephemeral = false,
withResponse?: WR,
): Promise<When<WR, WebhookMessageStructure, undefined>> {
return this.interaction.deferReply<WR>(ephemeral ? MessageFlags.Ephemeral : undefined, withResponse); return this.interaction.deferReply<WR>(ephemeral ? MessageFlags.Ephemeral : undefined, withResponse);
} }
editResponse(body: InteractionMessageUpdateBodyRequest) { editResponse(body: InteractionMessageUpdateBodyRequest): Promise<WebhookMessageStructure> {
return this.interaction.editResponse(body); return this.interaction.editResponse(body);
} }
@ -60,7 +73,7 @@ export class EntryPointContext<M extends keyof RegisteredMiddlewares = never> ex
editOrReply<WR extends boolean = false>( editOrReply<WR extends boolean = false>(
body: InteractionCreateBodyRequest | InteractionMessageUpdateBodyRequest, body: InteractionCreateBodyRequest | InteractionMessageUpdateBodyRequest,
withResponse?: WR, withResponse?: WR,
) { ): Promise<When<WR, WebhookMessageStructure, void>> {
return this.interaction.editOrReply<WR>(body as InteractionCreateBodyRequest, withResponse); return this.interaction.editOrReply<WR>(body as InteractionCreateBodyRequest, withResponse);
} }
@ -112,11 +125,11 @@ export class EntryPointContext<M extends keyof RegisteredMiddlewares = never> ex
return this.interaction.channelId!; return this.interaction.channelId!;
} }
get author() { get author(): UserStructure {
return this.interaction.user; return this.interaction.user;
} }
get member() { get member(): InteractionGuildMemberStructure | undefined {
return this.interaction.member; return this.interaction.member;
} }

View File

@ -1,10 +1,11 @@
import type { ContextMenuCommand, ReturnCache } from '../..'; import type { ContextMenuCommand, InteractionGuildMemberStructure, ReturnCache } from '../..';
import { import {
type GuildMemberStructure, type GuildMemberStructure,
type GuildStructure, type GuildStructure,
type MessageStructure, type MessageStructure,
Transformers, Transformers,
type UserStructure, type UserStructure,
type WebhookMessageStructure,
} from '../../client/transformers'; } from '../../client/transformers';
import { import {
type InteractionCreateBodyRequest, type InteractionCreateBodyRequest,
@ -12,6 +13,7 @@ import {
type MakeRequired, type MakeRequired,
type ModalCreateBodyRequest, type ModalCreateBodyRequest,
type UnionToTuple, type UnionToTuple,
type When,
toSnakeCase, toSnakeCase,
} from '../../common'; } from '../../common';
import type { AllChannels, MessageCommandInteraction, UserCommandInteraction } from '../../structures'; import type { AllChannels, MessageCommandInteraction, UserCommandInteraction } from '../../structures';
@ -66,7 +68,10 @@ export class MenuCommandContext<
return this.command.name; return this.command.name;
} }
write<WR extends boolean = false>(body: InteractionCreateBodyRequest, withResponse?: WR) { write<WR extends boolean = false>(
body: InteractionCreateBodyRequest,
withResponse?: WR,
): Promise<When<WR, WebhookMessageStructure, void>> {
return this.interaction.write<WR>(body, withResponse); return this.interaction.write<WR>(body, withResponse);
} }
@ -74,11 +79,14 @@ export class MenuCommandContext<
return this.interaction.modal(body); return this.interaction.modal(body);
} }
deferReply<WR extends boolean = false>(ephemeral = false, withResponse?: WR) { deferReply<WR extends boolean = false>(
ephemeral = false,
withResponse?: WR,
): Promise<When<WR, WebhookMessageStructure, undefined>> {
return this.interaction.deferReply<WR>(ephemeral ? MessageFlags.Ephemeral : undefined, withResponse); return this.interaction.deferReply<WR>(ephemeral ? MessageFlags.Ephemeral : undefined, withResponse);
} }
editResponse(body: InteractionMessageUpdateBodyRequest) { editResponse(body: InteractionMessageUpdateBodyRequest): Promise<WebhookMessageStructure> {
return this.interaction.editResponse(body); return this.interaction.editResponse(body);
} }
@ -89,11 +97,11 @@ export class MenuCommandContext<
editOrReply<WR extends boolean = false>( editOrReply<WR extends boolean = false>(
body: InteractionCreateBodyRequest | InteractionMessageUpdateBodyRequest, body: InteractionCreateBodyRequest | InteractionMessageUpdateBodyRequest,
withResponse?: WR, withResponse?: WR,
) { ): Promise<When<WR, WebhookMessageStructure, void>> {
return this.interaction.editOrReply<WR>(body as InteractionCreateBodyRequest, withResponse); return this.interaction.editOrReply<WR>(body as InteractionCreateBodyRequest, withResponse);
} }
fetchResponse() { fetchResponse(): Promise<WebhookMessageStructure> {
return this.interaction.fetchResponse(); return this.interaction.fetchResponse();
} }
@ -141,11 +149,11 @@ export class MenuCommandContext<
return this.interaction.channelId!; return this.interaction.channelId!;
} }
get author() { get author(): UserStructure {
return this.interaction.user; return this.interaction.user;
} }
get member() { get member(): InteractionGuildMemberStructure | undefined {
return this.interaction.member; return this.interaction.member;
} }

View File

@ -495,7 +495,7 @@ export class HandleCommand {
}; };
} }
makeResolver(...args: Parameters<(typeof Transformers)['OptionResolver']>) { makeResolver(...args: Parameters<(typeof Transformers)['OptionResolver']>): OptionResolverStructure {
return Transformers.OptionResolver(...args); return Transformers.OptionResolver(...args);
} }

View File

@ -99,7 +99,19 @@ export class OptionResolver {
return this.hoistedOptions.find(x => x.name === name); 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); const option = this.getHoisted(name);
if (!option) { if (!option) {
return; return;

View File

@ -1,4 +1,4 @@
import { Transformers } from '../../client'; import { type EntitlementStructure, Transformers } from '../../client';
import type { import type {
APIEntitlement, APIEntitlement,
RESTGetAPIEntitlementsQuery, RESTGetAPIEntitlementsQuery,
@ -42,7 +42,7 @@ export class ApplicationShorter extends BaseShorter {
* @param applicationId The ID of the application. * @param applicationId The ID of the application.
* @param [query] The query parameters. * @param [query] The query parameters.
*/ */
listEntitlements(applicationId: string, query?: RESTGetAPIEntitlementsQuery) { listEntitlements(applicationId: string, query?: RESTGetAPIEntitlementsQuery): Promise<EntitlementStructure[]> {
return this.client.proxy return this.client.proxy
.applications(applicationId) .applications(applicationId)
.entitlements.get({ query }) .entitlements.get({ query })
@ -63,7 +63,7 @@ export class ApplicationShorter extends BaseShorter {
* @param applicationId The ID of the application. * @param applicationId The ID of the application.
* @param body The body of the request. * @param body The body of the request.
*/ */
createTestEntitlement(applicationId: string, body: RESTPostAPIEntitlementBody) { createTestEntitlement(applicationId: string, body: RESTPostAPIEntitlementBody): Promise<EntitlementStructure> {
return this.client.proxy return this.client.proxy
.applications(applicationId) .applications(applicationId)
.entitlements.post({ body }) .entitlements.post({ body })

View File

@ -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. * @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. * @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<GuildBanStructure> {
let ban: APIBan | GuildBanStructure | undefined; let ban: APIBan | GuildBanStructure | undefined;
if (!force) { if (!force) {
ban = await this.client.cache.bans?.get(userId, guildId); 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. * @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. * @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<GuildBanStructure[]> {
let bans: APIBan[] | GuildBanStructure[]; let bans: APIBan[] | GuildBanStructure[];
if (!force) { if (!force) {
bans = (await this.client.cache.bans?.values(guildId)) ?? []; bans = (await this.client.cache.bans?.values(guildId)) ?? [];

View File

@ -1,6 +1,6 @@
import type { Channels } from '../../cache/resources/channels'; import type { Channels } from '../../cache/resources/channels';
import type { Overwrites } from '../../cache/resources/overwrites'; 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 { type AllChannels, BaseChannel, type GuildMember, type GuildRole, channelFrom } from '../../structures';
import { PermissionsBitField } from '../../structures/extra/Permissions'; import { PermissionsBitField } from '../../structures/extra/Permissions';
import type { import type {
@ -133,7 +133,7 @@ export class ChannelShorter extends BaseShorter {
channelId: string, channelId: string,
body: RESTPostAPIChannelThreadsJSONBody | RESTPostAPIGuildForumThreadsJSONBody, body: RESTPostAPIChannelThreadsJSONBody | RESTPostAPIGuildForumThreadsJSONBody,
reason?: string, reason?: string,
) { ): Promise<ThreadChannelStructure> {
return this.client.threads.create(channelId, body, reason); return this.client.threads.create(channelId, body, reason);
} }
@ -197,7 +197,7 @@ export class ChannelShorter extends BaseShorter {
return permissions; return permissions;
} }
async fetchMessages(channelId: string, query?: RESTGetAPIChannelMessagesQuery) { async fetchMessages(channelId: string, query?: RESTGetAPIChannelMessagesQuery): Promise<MessageStructure[]> {
const result = await this.client.proxy.channels(channelId).messages.get({ const result = await this.client.proxy.channels(channelId).messages.get({
query, query,
}); });

View File

@ -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. * @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. * @returns A Promise that resolves to an array of emojis.
*/ */
async list(guildId: string, force = false) { async list(guildId: string, force = false): Promise<GuildEmojiStructure[]> {
let emojis: APIEmoji[] | GuildEmojiStructure[]; let emojis: APIEmoji[] | GuildEmojiStructure[];
if (!force) { if (!force) {
emojis = (await this.client.cache.emojis?.values(guildId)) ?? []; 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. * @param body The data for creating the emoji.
* @returns A Promise that resolves to the created emoji. * @returns A Promise that resolves to the created emoji.
*/ */
async create(guildId: string, body: OmitInsert<RESTPostAPIGuildEmojiJSONBody, 'image', { image: ImageResolvable }>) { async create(
guildId: string,
body: OmitInsert<RESTPostAPIGuildEmojiJSONBody, 'image', { image: ImageResolvable }>,
): Promise<GuildEmojiStructure> {
const bodyResolved = { ...body, image: await resolveImage(body.image) }; const bodyResolved = { ...body, image: await resolveImage(body.image) };
const emoji = await this.client.proxy.guilds(guildId).emojis.post({ const emoji = await this.client.proxy.guilds(guildId).emojis.post({
body: bodyResolved, 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. * @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. * @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<GuildEmojiStructure> {
let emoji: APIEmoji | GuildEmojiStructure | undefined; let emoji: APIEmoji | GuildEmojiStructure | undefined;
if (!force) { if (!force) {
emoji = await this.client.cache.emojis?.get(emojiId); 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. * @param reason The reason for editing the emoji.
* @returns A Promise that resolves to the edited 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<GuildEmojiStructure> {
const emoji = await this.client.proxy.guilds(guildId).emojis(emojiId).patch({ body, reason }); const emoji = await this.client.proxy.guilds(guildId).emojis(emojiId).patch({ body, reason });
await this.client.cache.emojis?.setIfNI('GuildExpressions', emoji.id!, guildId, emoji); await this.client.cache.emojis?.setIfNI('GuildExpressions', emoji.id!, guildId, emoji);
return Transformers.GuildEmoji(this.client, emoji, guildId); return Transformers.GuildEmoji(this.client, emoji, guildId);

View File

@ -1,7 +1,14 @@
import { resolveFiles } from '../../builders'; import { resolveFiles } from '../../builders';
import type { Channels } from '../../cache/resources/channels'; import type { Channels } from '../../cache/resources/channels';
import { type GuildStructure, type StickerStructure, Transformers } from '../../client/transformers'; import {
import { BaseChannel, type CreateStickerBodyRequest, Guild, GuildMember, channelFrom } from '../../structures'; 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 { import type {
APIChannel, APIChannel,
APISticker, 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. * @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. * @returns A Promise that resolves to the fetched guild.
*/ */
async fetch(id: string, force = false) { async fetch(id: string, force = false): Promise<GuildStructure<'api'>> {
return Transformers.Guild<'api'>(this.client, await this.raw(id, force)); 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); return new Guild(this.client, guild);
} }
list(query?: RESTGetAPICurrentUserGuildsQuery) { list(query?: RESTGetAPICurrentUserGuildsQuery): Promise<AnonymousGuildStructure[]> {
return this.client.proxy return this.client.proxy
.users('@me') .users('@me')
.guilds.get({ query }) .guilds.get({ query })
.then(guilds => guilds.map(guild => Transformers.AnonymousGuild(this.client, { ...guild, splash: null }))); .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<GuildMemberStructure> {
if (!force) { if (!force) {
const self = await this.client.cache.members?.raw(this.client.botId, id); 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(); const self = await this.client.proxy.guilds(id).members(this.client.botId).get();
await this.client.cache.members?.patch(self.user.id, id, self); 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) { 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. * @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. * @returns A Promise that resolves to an array of channels.
*/ */
list: async (guildId: string, force = false) => { list: async (guildId: string, force = false): Promise<AllChannels[]> => {
let channels: ReturnType<Channels['values']> | APIChannel[]; let channels: ReturnType<Channels['values']> | APIChannel[];
if (!force) { if (!force) {
channels = (await this.client.cache.channels?.values(guildId)) ?? []; channels = (await this.client.cache.channels?.values(guildId)) ?? [];
@ -207,7 +214,7 @@ export class GuildShorter extends BaseShorter {
* @param guildId The ID of the guild. * @param guildId The ID of the guild.
* @returns A Promise that resolves to an array of auto-moderation rules. * @returns A Promise that resolves to an array of auto-moderation rules.
*/ */
list: (guildId: string) => list: (guildId: string): Promise<AutoModerationRuleStructure[]> =>
this.client.proxy this.client.proxy
.guilds(guildId) .guilds(guildId)
['auto-moderation'].rules.get() ['auto-moderation'].rules.get()
@ -219,7 +226,7 @@ export class GuildShorter extends BaseShorter {
* @param body The data for creating the auto-moderation rule. * @param body The data for creating the auto-moderation rule.
* @returns A Promise that resolves to the created 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<AutoModerationRuleStructure> =>
this.client.proxy this.client.proxy
.guilds(guildId) .guilds(guildId)
['auto-moderation'].rules.post({ body }) ['auto-moderation'].rules.post({ body })
@ -242,7 +249,7 @@ export class GuildShorter extends BaseShorter {
* @param ruleId The ID of the rule to fetch. * @param ruleId The ID of the rule to fetch.
* @returns A Promise that resolves to the fetched auto-moderation rule. * @returns A Promise that resolves to the fetched auto-moderation rule.
*/ */
fetch: (guildId: string, ruleId: string) => { fetch: (guildId: string, ruleId: string): Promise<AutoModerationRuleStructure> => {
return this.client.proxy return this.client.proxy
.guilds(guildId) .guilds(guildId)
['auto-moderation'].rules(ruleId) ['auto-moderation'].rules(ruleId)
@ -258,7 +265,12 @@ export class GuildShorter extends BaseShorter {
* @param reason The reason for editing the rule. * @param reason The reason for editing the rule.
* @returns A Promise that resolves to the edited auto-moderation 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<AutoModerationRuleStructure> => {
return this.client.proxy return this.client.proxy
.guilds(guildId) .guilds(guildId)
['auto-moderation'].rules(ruleId) ['auto-moderation'].rules(ruleId)
@ -278,7 +290,7 @@ export class GuildShorter extends BaseShorter {
* @param guildId The ID of the guild. * @param guildId The ID of the guild.
* @returns A Promise that resolves to an array of stickers. * @returns A Promise that resolves to an array of stickers.
*/ */
list: async (guildId: string) => { list: async (guildId: string): Promise<StickerStructure[]> => {
const stickers = await this.client.proxy.guilds(guildId).stickers.get(); const stickers = await this.client.proxy.guilds(guildId).stickers.get();
await this.client.cache.stickers?.set( await this.client.cache.stickers?.set(
stickers.map(st => [st.id, st] as any), 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. * @param reason The reason for creating the sticker.
* @returns A Promise that resolves to the created 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<StickerStructure> => {
const fileResolve = await resolveFiles([file]); const fileResolve = await resolveFiles([file]);
const sticker = await this.client.proxy const sticker = await this.client.proxy
.guilds(guildId) .guilds(guildId)
@ -311,7 +327,12 @@ export class GuildShorter extends BaseShorter {
* @param reason The reason for editing the sticker. * @param reason The reason for editing the sticker.
* @returns A Promise that resolves to the edited 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<StickerStructure> => {
const sticker = await this.client.proxy.guilds(guildId).stickers(stickerId).patch({ body, reason }); const sticker = await this.client.proxy.guilds(guildId).stickers(stickerId).patch({ body, reason });
await this.client.cache.stickers?.setIfNI('GuildExpressions', stickerId, guildId, sticker); await this.client.cache.stickers?.setIfNI('GuildExpressions', stickerId, guildId, sticker);
return Transformers.Sticker(this.client, 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. * @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. * @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<StickerStructure> => {
let sticker: APISticker | StickerStructure | undefined; let sticker: APISticker | StickerStructure | undefined;
if (!force) { if (!force) {
sticker = await this.client.cache.stickers?.get(stickerId); sticker = await this.client.cache.stickers?.get(stickerId);

View File

@ -1,5 +1,5 @@
import { BaseInteraction, Modal, type ReplyInteractionBody, resolveFiles } from '../..'; 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 type { InteractionMessageUpdateBodyRequest, MessageWebhookCreateBodyRequest } from '../types/write';
import { BaseShorter } from './base'; import { BaseShorter } from './base';
@ -26,15 +26,19 @@ export class InteractionShorter extends BaseShorter {
}); });
} }
fetchResponse(token: string, messageId: string) { fetchResponse(token: string, messageId: string): Promise<WebhookMessageStructure> {
return this.client.webhooks.fetchMessage(this.client.applicationId, token, messageId); return this.client.webhooks.fetchMessage(this.client.applicationId, token, messageId);
} }
fetchOriginal(token: string) { fetchOriginal(token: string): Promise<WebhookMessageStructure> {
return this.fetchResponse(token, '@original'); return this.fetchResponse(token, '@original');
} }
async editMessage(token: string, messageId: string, body: InteractionMessageUpdateBodyRequest) { async editMessage(
token: string,
messageId: string,
body: InteractionMessageUpdateBodyRequest,
): Promise<WebhookMessageStructure> {
const { files, ...data } = body; const { files, ...data } = body;
const parsedFiles = files ? await resolveFiles(files) : undefined; const parsedFiles = files ? await resolveFiles(files) : undefined;
const apiMessage = await this.client.proxy 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); return Transformers.WebhookMessage(this.client, apiMessage, this.client.applicationId, token);
} }
editOriginal(token: string, body: InteractionMessageUpdateBodyRequest) { editOriginal(token: string, body: InteractionMessageUpdateBodyRequest): Promise<WebhookMessageStructure> {
return this.editMessage(token, '@original', body); return this.editMessage(token, '@original', body);
} }
@ -63,7 +67,7 @@ export class InteractionShorter extends BaseShorter {
return this.deleteResponse(token, '@original'); return this.deleteResponse(token, '@original');
} }
async followup(token: string, { files, ...body }: MessageWebhookCreateBodyRequest) { async followup(token: string, { files, ...body }: MessageWebhookCreateBodyRequest): Promise<WebhookMessageStructure> {
const parsedFiles = files ? await resolveFiles(files) : undefined; const parsedFiles = files ? await resolveFiles(files) : undefined;
const apiMessage = await this.client.proxy const apiMessage = await this.client.proxy
.webhooks(this.client.applicationId)(token) .webhooks(this.client.applicationId)(token)

View File

@ -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 { PermissionsBitField } from '../../structures/extra/Permissions';
import { import {
type APIGuildMember, type APIGuildMember,
@ -19,7 +24,7 @@ export class MemberShorter extends BaseShorter {
* @param resolve The GuildMemberResolvable to resolve. * @param resolve The GuildMemberResolvable to resolve.
* @returns A Promise that resolves to the resolved member. * @returns A Promise that resolves to the resolved member.
*/ */
async resolve(guildId: string, resolve: GuildMemberResolvable) { async resolve(guildId: string, resolve: GuildMemberResolvable): Promise<GuildMemberStructure | undefined> {
if (typeof resolve === 'string') { if (typeof resolve === 'string') {
const match: { id?: string } | undefined = resolve.match(FormattingPatterns.User)?.groups; const match: { id?: string } | undefined = resolve.match(FormattingPatterns.User)?.groups;
if (match?.id) { if (match?.id) {
@ -48,7 +53,7 @@ export class MemberShorter extends BaseShorter {
* @param query The query parameters for searching members. * @param query The query parameters for searching members.
* @returns A Promise that resolves to an array of matched 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<GuildMemberStructure[]> {
const members = await this.client.proxy.guilds(guildId).members.search.get({ const members = await this.client.proxy.guilds(guildId).members.search.get({
query, query,
}); });
@ -100,7 +105,12 @@ export class MemberShorter extends BaseShorter {
* @param reason The reason for editing the member. * @param reason The reason for editing the member.
* @returns A Promise that resolves to the edited 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<GuildMemberStructure> {
const member = await this.client.proxy.guilds(guildId).members(memberId).patch({ body, reason }); const member = await this.client.proxy.guilds(guildId).members(memberId).patch({ body, reason });
await this.client.cache.members?.setIfNI('GuildMembers', memberId, guildId, member); await this.client.cache.members?.setIfNI('GuildMembers', memberId, guildId, member);
return Transformers.GuildMember(this.client, member, member.user, guildId); 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. * @param body The request body for adding the member.
* @returns A Promise that resolves to the added 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<GuildMemberStructure | undefined> {
const member = await this.client.proxy.guilds(guildId).members(memberId).put({ const member = await this.client.proxy.guilds(guildId).members(memberId).put({
body, 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. * @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. * @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<GuildMemberStructure> {
const member = await this.raw(guildId, memberId, force); const member = await this.raw(guildId, memberId, force);
return Transformers.GuildMember(this.client, member, member.user, guildId); 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. * @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. * @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<GuildMemberStructure[]> {
let members: APIGuildMember[] | GuildMemberStructure[]; let members: APIGuildMember[] | GuildMemberStructure[];
if (!force) { if (!force) {
members = (await this.client.cache.members?.values(guildId)) ?? []; 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(); 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<GuildRoleStructure[]> {
if (!force) { if (!force) {
const member = await this.client.cache.members?.get(memberId, guildId); const member = await this.client.cache.members?.get(memberId, guildId);
if (member) { if (member) {
@ -206,7 +220,7 @@ export class MemberShorter extends BaseShorter {
return allRoles.filter(role => rolesId.includes(role.id)); 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<GuildRoleStructure[]> {
const roles = await this.listRoles(guildId, memberId, force); const roles = await this.listRoles(guildId, memberId, force);
return roles.sort((a, b) => b.position - a.position); 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 time The time in seconds to timeout the member for.
* @param reason The reason for the timeout. * @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<GuildMemberStructure> {
return this.edit( return this.edit(
guildId, guildId,
memberId, memberId,

View File

@ -8,12 +8,12 @@ import type {
} from '../../types'; } from '../../types';
import type { ValidAnswerId } from '../../api/Routes/channels'; 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 type { MessageCreateBodyRequest, MessageUpdateBodyRequest } from '../types/write';
import { BaseShorter } from './base'; import { BaseShorter } from './base';
export class MessageShorter extends BaseShorter { export class MessageShorter extends BaseShorter {
async write(channelId: string, { files, ...body }: MessageCreateBodyRequest) { async write(channelId: string, { files, ...body }: MessageCreateBodyRequest): Promise<MessageStructure> {
const parsedFiles = files ? await resolveFiles(files) : undefined; const parsedFiles = files ? await resolveFiles(files) : undefined;
const transformedBody = MessagesMethods.transformMessageBody<RESTPostAPIChannelMessageJSONBody>( const transformedBody = MessagesMethods.transformMessageBody<RESTPostAPIChannelMessageJSONBody>(
@ -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<MessageStructure> {
const parsedFiles = files ? await resolveFiles(files) : undefined; const parsedFiles = files ? await resolveFiles(files) : undefined;
return this.client.proxy return this.client.proxy
.channels(channelId) .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<MessageStructure> {
return this.client.proxy return this.client.proxy
.channels(channelId) .channels(channelId)
.messages(messageId) .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<MessageStructure> {
if (!force) { if (!force) {
const message = await this.client.cache.messages?.get(messageId); const message = await this.client.cache.messages?.get(messageId);
if (message) return message; if (message) return message;
@ -97,11 +101,11 @@ export class MessageShorter extends BaseShorter {
channelId: string, channelId: string,
messageId: string, messageId: string,
options: RESTPostAPIChannelMessagesThreadsJSONBody & { reason?: string }, options: RESTPostAPIChannelMessagesThreadsJSONBody & { reason?: string },
) { ): Promise<ThreadChannelStructure> {
return this.client.threads.fromMessage(channelId, messageId, options); return this.client.threads.fromMessage(channelId, messageId, options);
} }
endPoll(channelId: string, messageId: string) { endPoll(channelId: string, messageId: string): Promise<MessageStructure> {
return this.client.proxy return this.client.proxy
.channels(channelId) .channels(channelId)
.polls(messageId) .polls(messageId)
@ -109,7 +113,7 @@ export class MessageShorter extends BaseShorter {
.then(message => Transformers.Message(this.client, message)); .then(message => Transformers.Message(this.client, message));
} }
getAnswerVoters(channelId: string, messageId: string, answerId: ValidAnswerId) { getAnswerVoters(channelId: string, messageId: string, answerId: ValidAnswerId): Promise<UserStructure[]> {
return this.client.proxy return this.client.proxy
.channels(channelId) .channels(channelId)
.polls(messageId) .polls(messageId)
@ -118,7 +122,7 @@ export class MessageShorter extends BaseShorter {
.then(data => data.users.map(user => Transformers.User(this.client, user))); .then(data => data.users.map(user => Transformers.User(this.client, user)));
} }
list(channelId: string, fetchOptions: RESTGetAPIChannelMessagesQuery) { list(channelId: string, fetchOptions: RESTGetAPIChannelMessagesQuery): Promise<MessageStructure[]> {
return this.client.proxy return this.client.proxy
.channels(channelId) .channels(channelId)
.messages.get({ query: fetchOptions }) .messages.get({ query: fetchOptions })

View File

@ -1,4 +1,4 @@
import { Transformers } from '../../client/transformers'; import { type GuildRoleStructure, Transformers } from '../../client/transformers';
import type { import type {
APIRole, APIRole,
RESTPatchAPIGuildRoleJSONBody, RESTPatchAPIGuildRoleJSONBody,
@ -15,13 +15,13 @@ export class RoleShorter extends BaseShorter {
* @param reason The reason for creating the role. * @param reason The reason for creating the role.
* @returns A Promise that resolves when the role is created. * @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<GuildRoleStructure> {
const res = await this.client.proxy.guilds(guildId).roles.post({ body, reason }); const res = await this.client.proxy.guilds(guildId).roles.post({ body, reason });
await this.client.cache.roles?.setIfNI('Guilds', res.id, guildId, res); await this.client.cache.roles?.setIfNI('Guilds', res.id, guildId, res);
return Transformers.GuildRole(this.client, res, guildId); return Transformers.GuildRole(this.client, res, guildId);
} }
async fetch(guildId: string, roleId: string, force = false) { async fetch(guildId: string, roleId: string, force = false): Promise<GuildRoleStructure> {
const role = await this.raw(guildId, roleId, force); const role = await this.raw(guildId, roleId, force);
return Transformers.GuildRole(this.client, role, guildId); 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. * @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. * @returns A Promise that resolves to an array of roles.
*/ */
async list(guildId: string, force = false) { async list(guildId: string, force = false): Promise<GuildRoleStructure[]> {
const roles = await this.listRaw(guildId, force); const roles = await this.listRaw(guildId, force);
return roles.map(r => Transformers.GuildRole(this.client, r, guildId)); 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. * @param reason The reason for editing the role.
* @returns A Promise that resolves when the role is edited. * @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<GuildRoleStructure> {
const res = await this.client.proxy.guilds(guildId).roles(roleId).patch({ body, reason }); const res = await this.client.proxy.guilds(guildId).roles(roleId).patch({ body, reason });
await this.client.cache.roles?.setIfNI('Guilds', roleId, guildId, res); await this.client.cache.roles?.setIfNI('Guilds', roleId, guildId, res);
return Transformers.GuildRole(this.client, res, guildId); return Transformers.GuildRole(this.client, res, guildId);
@ -85,7 +90,7 @@ export class RoleShorter extends BaseShorter {
* @param reason The reason for deleting the role. * @param reason The reason for deleting the role.
* @returns A Promise that resolves when the role is deleted. * @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<GuildRoleStructure> {
const res = await this.client.proxy.guilds(guildId).roles(roleId).delete({ reason }); const res = await this.client.proxy.guilds(guildId).roles(roleId).delete({ reason });
this.client.cache.roles?.removeIfNI('Guilds', roleId, guildId); this.client.cache.roles?.removeIfNI('Guilds', roleId, guildId);
return Transformers.GuildRole(this.client, res, 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. * @param body The data to update the positions of roles with.
* @returns A Promise that resolves to an array of edited roles. * @returns A Promise that resolves to an array of edited roles.
*/ */
async editPositions(guildId: string, body: RESTPatchAPIGuildRolePositionsJSONBody) { async editPositions(guildId: string, body: RESTPatchAPIGuildRolePositionsJSONBody): Promise<GuildRoleStructure[]> {
const roles = await this.client.proxy.guilds(guildId).roles.patch({ const roles = await this.client.proxy.guilds(guildId).roles.patch({
body, body,
}); });

View File

@ -1,30 +1,30 @@
import { Transformers } from '../../client/transformers'; import { type GuildTemplateStructure, Transformers } from '../../client/transformers';
import type { RESTPatchAPIGuildTemplateJSONBody, RESTPostAPIGuildTemplatesJSONBody } from '../../types'; import type { RESTPatchAPIGuildTemplateJSONBody, RESTPostAPIGuildTemplatesJSONBody } from '../../types';
import { BaseShorter } from './base'; import { BaseShorter } from './base';
export class TemplateShorter extends BaseShorter { export class TemplateShorter extends BaseShorter {
fetch(code: string) { fetch(code: string): Promise<GuildTemplateStructure> {
return this.client.proxy.guilds return this.client.proxy.guilds
.templates(code) .templates(code)
.get() .get()
.then(template => Transformers.GuildTemplate(this.client, template)); .then(template => Transformers.GuildTemplate(this.client, template));
} }
list(guildId: string) { list(guildId: string): Promise<GuildTemplateStructure[]> {
return this.client.proxy return this.client.proxy
.guilds(guildId) .guilds(guildId)
.templates.get() .templates.get()
.then(list => list.map(template => Transformers.GuildTemplate(this.client, template))); .then(list => list.map(template => Transformers.GuildTemplate(this.client, template)));
} }
create(guildId: string, body: RESTPostAPIGuildTemplatesJSONBody) { create(guildId: string, body: RESTPostAPIGuildTemplatesJSONBody): Promise<GuildTemplateStructure> {
return this.client.proxy return this.client.proxy
.guilds(guildId) .guilds(guildId)
.templates.post({ body }) .templates.post({ body })
.then(template => Transformers.GuildTemplate(this.client, template)); .then(template => Transformers.GuildTemplate(this.client, template));
} }
sync(guildId: string, code: string) { sync(guildId: string, code: string): Promise<GuildTemplateStructure> {
return this.client.proxy return this.client.proxy
.guilds(guildId) .guilds(guildId)
.templates(code) .templates(code)
@ -32,7 +32,7 @@ export class TemplateShorter extends BaseShorter {
.then(template => Transformers.GuildTemplate(this.client, template)); .then(template => Transformers.GuildTemplate(this.client, template));
} }
edit(guildId: string, code: string, body: RESTPatchAPIGuildTemplateJSONBody) { edit(guildId: string, code: string, body: RESTPatchAPIGuildTemplateJSONBody): Promise<GuildTemplateStructure> {
return this.client.proxy return this.client.proxy
.guilds(guildId) .guilds(guildId)
.templates(code) .templates(code)
@ -40,7 +40,7 @@ export class TemplateShorter extends BaseShorter {
.then(template => Transformers.GuildTemplate(this.client, template)); .then(template => Transformers.GuildTemplate(this.client, template));
} }
delete(guildId: string, code: string) { delete(guildId: string, code: string): Promise<GuildTemplateStructure> {
return this.client.proxy return this.client.proxy
.guilds(guildId) .guilds(guildId)
.templates(code) .templates(code)

View File

@ -24,7 +24,7 @@ export class ThreadShorter extends BaseShorter {
channelId: string, channelId: string,
body: RESTPostAPIChannelThreadsJSONBody | RESTPostAPIGuildForumThreadsJSONBody, body: RESTPostAPIChannelThreadsJSONBody | RESTPostAPIGuildForumThreadsJSONBody,
reason?: string, reason?: string,
) { ): Promise<ThreadChannelStructure> {
return ( return (
this.client.proxy this.client.proxy
.channels(channelId) .channels(channelId)
@ -46,7 +46,7 @@ export class ThreadShorter extends BaseShorter {
channelId: string, channelId: string,
messageId: string, messageId: string,
options: RESTPostAPIChannelMessagesThreadsJSONBody & { reason?: string }, options: RESTPostAPIChannelMessagesThreadsJSONBody & { reason?: string },
) { ): Promise<ThreadChannelStructure> {
const { reason, ...body } = options; const { reason, ...body } = options;
return this.client.proxy return this.client.proxy
@ -67,12 +67,12 @@ export class ThreadShorter extends BaseShorter {
return this.client.proxy.channels(threadId)['thread-members']('@me').delete(); 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<ThreadChannelStructure> {
return this.edit(threadId, { locked }, reason).then(x => channelFrom(x, this.client) as ThreadChannelStructure); return this.edit(threadId, { locked }, reason).then(x => channelFrom(x, this.client) as ThreadChannelStructure);
} }
edit(threadId: string, body: RESTPatchAPIChannelJSONBody, reason?: string) { async edit(threadId: string, body: RESTPatchAPIChannelJSONBody, reason?: string): Promise<ThreadChannelStructure> {
return this.client.channels.edit(threadId, body, { reason }); return (await this.client.channels.edit(threadId, body, { reason })) as ThreadChannelStructure;
} }
removeMember(threadId: string, memberId: string) { removeMember(threadId: string, memberId: string) {
@ -106,7 +106,11 @@ export class ThreadShorter extends BaseShorter {
channelId: string, channelId: string,
type: 'public' | 'private', type: 'public' | 'private',
query?: RESTGetAPIChannelThreadsArchivedQuery, query?: RESTGetAPIChannelThreadsArchivedQuery,
) { ): Promise<{
threads: ThreadChannelStructure[];
members: GetAPIChannelThreadMemberResult[];
hasMore: boolean;
}> {
const data = await this.client.proxy.channels(channelId).threads.archived[type].get({ query }); const data = await this.client.proxy.channels(channelId).threads.archived[type].get({ query });
return { 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 }); const data = await this.client.proxy.channels(channelId).users('@me').threads.archived.private.get({ query });
return { return {
threads: data.threads.map(thread => channelFrom(thread, this.client) as ThreadChannelStructure), threads: data.threads.map(thread => channelFrom(thread, this.client) as ThreadChannelStructure),

View File

@ -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 { BaseChannel } from '../../structures';
import type { MessageCreateBodyRequest } from '../types/write'; import type { MessageCreateBodyRequest } from '../types/write';
import { BaseShorter } from './base'; import { BaseShorter } from './base';
export class UsersShorter extends BaseShorter { export class UsersShorter extends BaseShorter {
async createDM(userId: string, force = false) { async createDM(userId: string, force = false): Promise<DMChannelStructure> {
if (!force) { if (!force) {
const dm = await this.client.cache.channels?.get(userId); const dm = await this.client.cache.channels?.get(userId);
if (dm) return dm as DMChannelStructure; if (dm) return dm as DMChannelStructure;
@ -16,13 +21,13 @@ export class UsersShorter extends BaseShorter {
return Transformers.DMChannel(this.client, data); return Transformers.DMChannel(this.client, data);
} }
async deleteDM(userId: string, reason?: string) { async deleteDM(userId: string, reason?: string): Promise<DMChannelStructure> {
const res = await this.client.proxy.channels(userId).delete({ reason }); const res = await this.client.proxy.channels(userId).delete({ reason });
await this.client.cache.channels?.removeIfNI(BaseChannel.__intent__('@me'), res.id, '@me'); await this.client.cache.channels?.removeIfNI(BaseChannel.__intent__('@me'), res.id, '@me');
return Transformers.DMChannel(this.client, res); return Transformers.DMChannel(this.client, res);
} }
async fetch(userId: string, force = false) { async fetch(userId: string, force = false): Promise<UserStructure> {
return Transformers.User(this.client, await this.raw(userId, force)); return Transformers.User(this.client, await this.raw(userId, force));
} }
@ -37,7 +42,7 @@ export class UsersShorter extends BaseShorter {
return data; return data;
} }
async write(userId: string, body: MessageCreateBodyRequest) { async write(userId: string, body: MessageCreateBodyRequest): Promise<MessageStructure> {
return (await this.client.users.createDM(userId)).messages.write(body); return (await this.client.users.createDM(userId)).messages.write(body);
} }
} }

View File

@ -1,5 +1,5 @@
import { resolveFiles } from '../../builders'; import { resolveFiles } from '../../builders';
import { Transformers } from '../../client/transformers'; import { Transformers, type WebhookMessageStructure, type WebhookStructure } from '../../client/transformers';
import { import {
type MessageWebhookMethodEditParams, type MessageWebhookMethodEditParams,
type MessageWebhookMethodWriteParams, type MessageWebhookMethodWriteParams,
@ -15,7 +15,7 @@ import type {
import { BaseShorter } from './base'; import { BaseShorter } from './base';
export class WebhookShorter extends BaseShorter { export class WebhookShorter extends BaseShorter {
async create(channelId: string, body: RESTPostAPIChannelWebhookJSONBody) { async create(channelId: string, body: RESTPostAPIChannelWebhookJSONBody): Promise<WebhookStructure> {
const webhook = await this.client.proxy.channels(channelId).webhooks.post({ const webhook = await this.client.proxy.channels(channelId).webhooks.post({
body, body,
}); });
@ -45,7 +45,7 @@ export class WebhookShorter extends BaseShorter {
webhookId: string, webhookId: string,
body: RESTPatchAPIWebhookWithTokenJSONBody | RESTPatchAPIWebhookJSONBody, body: RESTPatchAPIWebhookWithTokenJSONBody | RESTPatchAPIWebhookJSONBody,
options: WebhookShorterOptionalParams, options: WebhookShorterOptionalParams,
) { ): Promise<WebhookStructure> {
if (options.token) { if (options.token) {
return this.client.proxy return this.client.proxy
.webhooks(webhookId)(options.token) .webhooks(webhookId)(options.token)
@ -64,7 +64,7 @@ export class WebhookShorter extends BaseShorter {
* @param token The token of the webhook (optional). * @param token The token of the webhook (optional).
* @returns A Promise that resolves to the fetched webhook. * @returns A Promise that resolves to the fetched webhook.
*/ */
async fetch(webhookId: string, token?: string) { async fetch(webhookId: string, token?: string): Promise<WebhookStructure> {
let webhook: APIWebhook; let webhook: APIWebhook;
if (token) { if (token) {
webhook = await this.client.proxy.webhooks(webhookId)(token).get({ auth: false }); 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. * @param data The data for writing the message.
* @returns A Promise that resolves to the written 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<WebhookMessageStructure | null> {
const { files, ...body } = data; const { files, ...body } = data;
const parsedFiles = files ? await resolveFiles(files) : undefined; const parsedFiles = files ? await resolveFiles(files) : undefined;
const transformedBody = MessagesMethods.transformMessageBody<RESTPostAPIWebhookWithTokenJSONBody>( const transformedBody = MessagesMethods.transformMessageBody<RESTPostAPIWebhookWithTokenJSONBody>(
@ -107,7 +111,7 @@ export class WebhookShorter extends BaseShorter {
webhookId: string, webhookId: string,
token: string, token: string,
{ messageId, body: data, ...json }: MessageWebhookMethodEditParams, { messageId, body: data, ...json }: MessageWebhookMethodEditParams,
) { ): Promise<WebhookMessageStructure> {
const { files, ...body } = data; const { files, ...body } = data;
const parsedFiles = files ? await resolveFiles(files) : undefined; const parsedFiles = files ? await resolveFiles(files) : undefined;
const transformedBody = MessagesMethods.transformMessageBody<RESTPostAPIWebhookWithTokenJSONBody>( const transformedBody = MessagesMethods.transformMessageBody<RESTPostAPIWebhookWithTokenJSONBody>(
@ -142,7 +146,12 @@ export class WebhookShorter extends BaseShorter {
* @param threadId The ID of the thread the message belongs to. * @param threadId The ID of the thread the message belongs to.
* @returns A Promise that resolves to the fetched message * @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<WebhookMessageStructure> {
const message = await this.client.proxy const message = await this.client.proxy
.webhooks(webhookId)(token) .webhooks(webhookId)(token)
.messages(messageId) .messages(messageId)
@ -150,12 +159,12 @@ export class WebhookShorter extends BaseShorter {
return Transformers.WebhookMessage(this.client, message, webhookId, token); return Transformers.WebhookMessage(this.client, message, webhookId, token);
} }
async listFromGuild(guildId: string) { async listFromGuild(guildId: string): Promise<WebhookStructure[]> {
const webhooks = await this.client.proxy.guilds(guildId).webhooks.get(); const webhooks = await this.client.proxy.guilds(guildId).webhooks.get();
return webhooks.map(webhook => Transformers.Webhook(this.client, webhook)); return webhooks.map(webhook => Transformers.Webhook(this.client, webhook));
} }
async listFromChannel(channelId: string) { async listFromChannel(channelId: string): Promise<WebhookStructure[]> {
const webhooks = await this.client.proxy.channels(channelId).webhooks.get(); const webhooks = await this.client.proxy.channels(channelId).webhooks.get();
return webhooks.map(webhook => Transformers.Webhook(this.client, webhook)); return webhooks.map(webhook => Transformers.Webhook(this.client, webhook));
} }

View File

@ -9,7 +9,13 @@ import type {
StringSelectMenuInteraction, StringSelectMenuInteraction,
UserSelectMenuInteraction, UserSelectMenuInteraction,
} from '..'; } 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 type { CommandMetadata, ExtendContext, GlobalMetadata, RegisteredMiddlewares, UsingClient } from '../commands';
import { BaseContext } from '../commands/basecontext'; import { BaseContext } from '../commands/basecontext';
import type { import type {
@ -19,6 +25,7 @@ import type {
MakeRequired, MakeRequired,
ModalCreateBodyRequest, ModalCreateBodyRequest,
UnionToTuple, UnionToTuple,
When,
} from '../common'; } from '../common';
import { ComponentType, MessageFlags } from '../types'; import { ComponentType, MessageFlags } from '../types';
@ -70,7 +77,10 @@ export class ComponentContext<
* @param body - The body of the response. * @param body - The body of the response.
* @param fetchReply - Whether to fetch the reply or not. * @param fetchReply - Whether to fetch the reply or not.
*/ */
write<FR extends boolean = false>(body: InteractionCreateBodyRequest, fetchReply?: FR) { write<FR extends boolean = false>(
body: InteractionCreateBodyRequest,
fetchReply?: FR,
): Promise<When<FR, WebhookMessageStructure, void>> {
return this.interaction.write<FR>(body, fetchReply); return this.interaction.write<FR>(body, fetchReply);
} }
@ -78,7 +88,10 @@ export class ComponentContext<
* Defers the reply to the interaction. * Defers the reply to the interaction.
* @param ephemeral - Whether the reply should be ephemeral or not. * @param ephemeral - Whether the reply should be ephemeral or not.
*/ */
deferReply<FR extends boolean = false>(ephemeral = false, fetchReply?: FR) { deferReply<FR extends boolean = false>(
ephemeral = false,
fetchReply?: FR,
): Promise<When<FR, WebhookMessageStructure, undefined>> {
return this.interaction.deferReply<FR>(ephemeral ? MessageFlags.Ephemeral : undefined, fetchReply); return this.interaction.deferReply<FR>(ephemeral ? MessageFlags.Ephemeral : undefined, fetchReply);
} }
@ -93,7 +106,7 @@ export class ComponentContext<
* Edits the response of the interaction. * Edits the response of the interaction.
* @param body - The updated body of the response. * @param body - The updated body of the response.
*/ */
editResponse(body: InteractionMessageUpdateBodyRequest) { editResponse(body: InteractionMessageUpdateBodyRequest): Promise<WebhookMessageStructure> {
return this.interaction.editResponse(body); return this.interaction.editResponse(body);
} }
@ -113,14 +126,14 @@ export class ComponentContext<
editOrReply<FR extends boolean = false>( editOrReply<FR extends boolean = false>(
body: InteractionCreateBodyRequest | InteractionMessageUpdateBodyRequest, body: InteractionCreateBodyRequest | InteractionMessageUpdateBodyRequest,
fetchReply?: FR, fetchReply?: FR,
) { ): Promise<When<FR, WebhookMessageStructure, void>> {
return this.interaction.editOrReply<FR>(body as InteractionCreateBodyRequest, fetchReply); return this.interaction.editOrReply<FR>(body as InteractionCreateBodyRequest, fetchReply);
} }
/** /**
* @returns A Promise that resolves to the fetched message * @returns A Promise that resolves to the fetched message
*/ */
fetchResponse() { fetchResponse(): Promise<WebhookMessageStructure> {
return this.interaction.fetchResponse(); return this.interaction.fetchResponse();
} }
@ -204,14 +217,14 @@ export class ComponentContext<
/** /**
* Gets the author of the interaction. * Gets the author of the interaction.
*/ */
get author() { get author(): UserStructure {
return this.interaction.user; return this.interaction.user;
} }
/** /**
* Gets the member of the interaction. * Gets the member of the interaction.
*/ */
get member() { get member(): InteractionGuildMemberStructure | undefined {
return this.interaction.member; return this.interaction.member;
} }

View File

@ -1,5 +1,11 @@
import type { AllChannels, Interaction, ModalCommand, ModalSubmitInteraction, ReturnCache } from '..'; 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 type { CommandMetadata, ExtendContext, GlobalMetadata, RegisteredMiddlewares, UsingClient } from '../commands';
import { BaseContext } from '../commands/basecontext'; import { BaseContext } from '../commands/basecontext';
import type { import type {
@ -8,6 +14,7 @@ import type {
MakeRequired, MakeRequired,
ModalCreateBodyRequest, ModalCreateBodyRequest,
UnionToTuple, UnionToTuple,
When,
} from '../common'; } from '../common';
import { MessageFlags } from '../types'; import { MessageFlags } from '../types';
@ -54,7 +61,10 @@ export class ModalContext<M extends keyof RegisteredMiddlewares = never> extends
* @param body - The body of the response. * @param body - The body of the response.
* @param fetchReply - Whether to fetch the reply or not. * @param fetchReply - Whether to fetch the reply or not.
*/ */
write<FR extends boolean = false>(body: InteractionCreateBodyRequest, fetchReply?: FR) { write<FR extends boolean = false>(
body: InteractionCreateBodyRequest,
fetchReply?: FR,
): Promise<When<FR, WebhookMessageStructure, void>> {
return this.interaction.write<FR>(body, fetchReply); return this.interaction.write<FR>(body, fetchReply);
} }
@ -62,7 +72,10 @@ export class ModalContext<M extends keyof RegisteredMiddlewares = never> extends
* Defers the reply to the interaction. * Defers the reply to the interaction.
* @param ephemeral - Whether the reply should be ephemeral or not. * @param ephemeral - Whether the reply should be ephemeral or not.
*/ */
deferReply<FR extends boolean = false>(ephemeral = false, fetchReply?: FR) { deferReply<FR extends boolean = false>(
ephemeral = false,
fetchReply?: FR,
): Promise<When<FR, WebhookMessageStructure, undefined>> {
return this.interaction.deferReply<FR>(ephemeral ? MessageFlags.Ephemeral : undefined, fetchReply); return this.interaction.deferReply<FR>(ephemeral ? MessageFlags.Ephemeral : undefined, fetchReply);
} }
@ -70,7 +83,7 @@ export class ModalContext<M extends keyof RegisteredMiddlewares = never> extends
* Edits the response of the interaction. * Edits the response of the interaction.
* @param body - The updated body of the response. * @param body - The updated body of the response.
*/ */
editResponse(body: InteractionMessageUpdateBodyRequest) { editResponse(body: InteractionMessageUpdateBodyRequest): Promise<WebhookMessageStructure> {
return this.interaction.editResponse(body); return this.interaction.editResponse(body);
} }
@ -82,14 +95,14 @@ export class ModalContext<M extends keyof RegisteredMiddlewares = never> extends
editOrReply<FR extends boolean = false>( editOrReply<FR extends boolean = false>(
body: InteractionCreateBodyRequest | InteractionMessageUpdateBodyRequest, body: InteractionCreateBodyRequest | InteractionMessageUpdateBodyRequest,
fetchReply?: FR, fetchReply?: FR,
) { ): Promise<When<FR, WebhookMessageStructure, void>> {
return this.interaction.editOrReply<FR>(body as InteractionCreateBodyRequest, fetchReply); return this.interaction.editOrReply<FR>(body as InteractionCreateBodyRequest, fetchReply);
} }
/** /**
* @returns A Promise that resolves to the fetched message * @returns A Promise that resolves to the fetched message
*/ */
fetchResponse() { fetchResponse(): Promise<WebhookMessageStructure> {
return this.interaction.fetchResponse(); return this.interaction.fetchResponse();
} }
@ -174,14 +187,14 @@ export class ModalContext<M extends keyof RegisteredMiddlewares = never> extends
/** /**
* Gets the author of the interaction. * Gets the author of the interaction.
*/ */
get author() { get author(): UserStructure {
return this.interaction.user; return this.interaction.user;
} }
/** /**
* Gets the member of the interaction. * Gets the member of the interaction.
*/ */
get member() { get member(): InteractionGuildMemberStructure | undefined {
return this.interaction.member; return this.interaction.member;
} }

View File

@ -1,4 +1,4 @@
import { Transformers } from '../../client/transformers'; import { type AutoModerationRuleStructure, Transformers } from '../../client/transformers';
import type { UsingClient } from '../../commands'; import type { UsingClient } from '../../commands';
import { toCamelCase } from '../../common'; import { toCamelCase } from '../../common';
import type { import type {
@ -15,14 +15,23 @@ export const AUTO_MODERATION_ACTION_EXECUTION = (
return toCamelCase(data); 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); 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); 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); return Transformers.AutoModerationRule(self, data);
}; };

View File

@ -9,11 +9,11 @@ import type { UsingClient } from '../../commands';
import { toCamelCase } from '../../common'; import { toCamelCase } from '../../common';
import { type AllChannels, channelFrom } from '../../structures'; 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); 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); return channelFrom(data, self);
}; };

View File

@ -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 { 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; return me;
}; };
export const WORKER_READY = (_self: UsingClient, me: ClientUserStructure) => { export const WORKER_READY = (_self: UsingClient, me: ClientUserStructure): ClientUserStructure => {
return me; return me;
}; };
export const WORKER_SHARDS_CONNECTED = (_self: UsingClient, me: ClientUserStructure) => { export const WORKER_SHARDS_CONNECTED = (_self: UsingClient, me: ClientUserStructure): ClientUserStructure => {
return me; 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); 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<GuildStructure<'cached'> | APIUnavailableGuild> => {
return (await self.cache.guilds?.get(data.id)) ?? data; return (await self.cache.guilds?.get(data.id)) ?? data;
}; };

View File

@ -1,8 +1,8 @@
import { Transformers } from '../../client/transformers'; import { type ClientUserStructure, Transformers } from '../../client/transformers';
import type { UsingClient } from '../../commands'; import type { UsingClient } from '../../commands';
import type { GatewayDispatchPayload, GatewayReadyDispatchData, GatewayResumedDispatch } from '../../types'; 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); return Transformers.ClientUser(self, data.user, data.application);
}; };

View File

@ -1,15 +1,15 @@
import { Transformers } from '../../client'; import { type EntitlementStructure, Transformers } from '../../client';
import type { UsingClient } from '../../commands'; import type { UsingClient } from '../../commands';
import type { APIEntitlement } from '../../types'; 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); 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); 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); return Transformers.Entitlement(client, data);
}; };

View File

@ -1,12 +1,16 @@
import { import {
type GuildEmojiStructure,
type GuildMemberStructure, type GuildMemberStructure,
type GuildRoleStructure, type GuildRoleStructure,
type GuildStructure, type GuildStructure,
type StickerStructure,
Transformers, Transformers,
type UserStructure,
} from '../../client/transformers'; } from '../../client/transformers';
import type { UsingClient } from '../../commands'; import type { UsingClient } from '../../commands';
import { toCamelCase } from '../../common'; import { type ObjectToLower, toCamelCase } from '../../common';
import type { import type {
APIUnavailableGuild,
GatewayGuildAuditLogEntryCreateDispatchData, GatewayGuildAuditLogEntryCreateDispatchData,
GatewayGuildBanAddDispatchData, GatewayGuildBanAddDispatchData,
GatewayGuildBanRemoveDispatchData, GatewayGuildBanRemoveDispatchData,
@ -34,23 +38,41 @@ export const GUILD_AUDIT_LOG_ENTRY_CREATE = (_self: UsingClient, data: GatewayGu
return toCamelCase(data); return toCamelCase(data);
}; };
export const GUILD_BAN_ADD = (self: UsingClient, data: GatewayGuildBanAddDispatchData) => { export const GUILD_BAN_ADD = (
self: UsingClient,
data: GatewayGuildBanAddDispatchData,
): ObjectToLower<Omit<GatewayGuildBanAddDispatchData, 'user'>> & {
user: UserStructure;
} => {
return { ...toCamelCase(data), user: Transformers.User(self, data.user) }; 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<Omit<GatewayGuildBanRemoveDispatchData, 'user'>> & {
user: UserStructure;
} => {
return { ...toCamelCase(data), user: Transformers.User(self, data.user) }; 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); 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<GuildStructure<'cached'> | APIUnavailableGuild> => {
return (await self.cache.guilds?.get(data.id)) ?? data; 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<Omit<GatewayGuildEmojisUpdateDispatchData, 'emojis'>> & {
emojis: GuildEmojiStructure[];
} => {
return { return {
...toCamelCase(data), ...toCamelCase(data),
emojis: data.emojis.map(x => Transformers.GuildEmoji(self, x, data.guild_id)), 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); 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); 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 ( return (
(await self.cache.members?.get(data.user.id, data.guild_id)) ?? { (await self.cache.members?.get(data.user.id, data.guild_id)) ?? {
...toCamelCase(data), ...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<Omit<GatewayGuildMembersChunkDispatchData, 'members'>> & {
members: GuildMemberStructure[];
} => {
return { return {
...toCamelCase(data), ...toCamelCase(data),
members: data.members.map(x => Transformers.GuildMember(self, x, x.user, data.guild_id)), 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); 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); 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<GuildRoleStructure | ObjectToLower<GatewayGuildRoleDeleteDispatchData>> => {
return (await self.cache.roles?.get(data.role_id)) || toCamelCase(data); 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)]; 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<Omit<GatewayGuildStickersUpdateDispatchData, 'stickers'>> & {
stickers: StickerStructure[];
} => {
return { return {
...toCamelCase(data), ...toCamelCase(data),
stickers: data.stickers.map(x => Transformers.Sticker(self, x)), stickers: data.stickers.map(x => Transformers.Sticker(self, x)),

View File

@ -1,13 +1,20 @@
import { Transformers } from '../../client/transformers'; import { Transformers, type UserStructure } from '../../client/transformers';
import type { UsingClient } from '../../commands'; import type { UsingClient } from '../../commands';
import { toCamelCase } from '../../common'; import { type ObjectToLower, toCamelCase } from '../../common';
import type { import type {
GatewayIntegrationCreateDispatchData, GatewayIntegrationCreateDispatchData,
GatewayIntegrationDeleteDispatchData, GatewayIntegrationDeleteDispatchData,
GatewayIntegrationUpdateDispatchData, GatewayIntegrationUpdateDispatchData,
} from '../../types'; } from '../../types';
export const INTEGRATION_CREATE = (self: UsingClient, data: GatewayIntegrationCreateDispatchData) => { export const INTEGRATION_CREATE = (
self: UsingClient,
data: GatewayIntegrationCreateDispatchData,
):
| (ObjectToLower<Omit<GatewayIntegrationCreateDispatchData, 'user'>> & {
user: UserStructure;
})
| ObjectToLower<Omit<GatewayIntegrationCreateDispatchData, 'user'>> => {
return data.user return data.user
? { ? {
...toCamelCase(data), ...toCamelCase(data),
@ -16,7 +23,14 @@ export const INTEGRATION_CREATE = (self: UsingClient, data: GatewayIntegrationCr
: toCamelCase(data); : toCamelCase(data);
}; };
export const INTEGRATION_UPDATE = (self: UsingClient, data: GatewayIntegrationUpdateDispatchData) => { export const INTEGRATION_UPDATE = (
self: UsingClient,
data: GatewayIntegrationUpdateDispatchData,
):
| (ObjectToLower<Omit<GatewayIntegrationUpdateDispatchData, 'user'>> & {
user: UserStructure;
})
| ObjectToLower<Omit<GatewayIntegrationUpdateDispatchData, 'user'>> => {
return data.user return data.user
? { ? {
...toCamelCase(data), ...toCamelCase(data),
@ -25,10 +39,6 @@ export const INTEGRATION_UPDATE = (self: UsingClient, data: GatewayIntegrationUp
: toCamelCase(data); : toCamelCase(data);
}; };
export const INTEGRATION_DELETE = ( export const INTEGRATION_DELETE = (_self: UsingClient, data: GatewayIntegrationDeleteDispatchData) => {
_self: UsingClient,
data: GatewayIntegrationDeleteDispatchData,
) => {
return toCamelCase(data); return toCamelCase(data);
}; };

View File

@ -13,7 +13,7 @@ import type {
GatewayMessageUpdateDispatchData, GatewayMessageUpdateDispatchData,
} from '../../types'; } from '../../types';
export const MESSAGE_CREATE = (self: UsingClient, data: GatewayMessageCreateDispatchData) => { export const MESSAGE_CREATE = (self: UsingClient, data: GatewayMessageCreateDispatchData): MessageStructure => {
return Transformers.Message(self, data); return Transformers.Message(self, data);
}; };
@ -24,7 +24,10 @@ export const MESSAGE_DELETE = async (
return (await self.cache.messages?.get(data.id)) ?? toCamelCase(data); 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<GatewayMessageDeleteBulkDispatchData & { messages: (MessageStructure | string)[] }> => {
return { return {
...data, ...data,
messages: await Promise.all(data.ids.map(id => fakePromise(self.cache.messages?.get(id)).then(x => x ?? id))), messages: await Promise.all(data.ids.map(id => fakePromise(self.cache.messages?.get(id)).then(x => x ?? id))),

View File

@ -1,7 +1,8 @@
import { Transformers } from '../../client'; import { Transformers, type UserStructure } from '../../client';
import type { UsingClient } from '../../commands'; import type { UsingClient } from '../../commands';
import { toCamelCase } from '../../common'; import { type ObjectToLower, toCamelCase } from '../../common';
import type { import type {
APISoundBoard,
GatewayGuildSoundboardSoundCreateDispatchData, GatewayGuildSoundboardSoundCreateDispatchData,
GatewayGuildSoundboardSoundDeleteDispatchData, GatewayGuildSoundboardSoundDeleteDispatchData,
GatewayGuildSoundboardSoundUpdateDispatchData, GatewayGuildSoundboardSoundUpdateDispatchData,
@ -12,21 +13,37 @@ import type {
export const GUILD_SOUNDBOARD_SOUND_CREATE = ( export const GUILD_SOUNDBOARD_SOUND_CREATE = (
self: UsingClient, self: UsingClient,
data: GatewayGuildSoundboardSoundCreateDispatchData, data: GatewayGuildSoundboardSoundCreateDispatchData,
) => { ):
| (ObjectToLower<Omit<GatewayGuildSoundboardSoundCreateDispatchData, 'user'>> & {
user: UserStructure;
})
| ObjectToLower<Omit<GatewayGuildSoundboardSoundCreateDispatchData, 'user'>> => {
return data.user ? { ...toCamelCase(data), user: Transformers.User(self, data.user) } : toCamelCase(data); return data.user ? { ...toCamelCase(data), user: Transformers.User(self, data.user) } : toCamelCase(data);
}; };
export const GUILD_SOUNDBOARD_SOUND_UPDATE = ( export const GUILD_SOUNDBOARD_SOUND_UPDATE = (
self: UsingClient, self: UsingClient,
data: GatewayGuildSoundboardSoundUpdateDispatchData, data: GatewayGuildSoundboardSoundUpdateDispatchData,
) => { ):
| (ObjectToLower<Omit<GatewayGuildSoundboardSoundUpdateDispatchData, 'user'>> & {
user: UserStructure;
})
| ObjectToLower<Omit<GatewayGuildSoundboardSoundUpdateDispatchData, 'user'>> => {
return data.user ? { ...toCamelCase(data), user: Transformers.User(self, data.user) } : toCamelCase(data); return data.user ? { ...toCamelCase(data), user: Transformers.User(self, data.user) } : toCamelCase(data);
}; };
export const GUILD_SOUNDBOARD_SOUNDS_UPDATE = ( export const GUILD_SOUNDBOARD_SOUNDS_UPDATE = (
self: UsingClient, self: UsingClient,
data: GatewayGuildSoundboardSoundsUpdateDispatchData, data: GatewayGuildSoundboardSoundsUpdateDispatchData,
) => { ): {
guildId: string;
sounds: (
| (ObjectToLower<Omit<APISoundBoard, 'user'>> & {
user: UserStructure;
})
| ObjectToLower<Omit<APISoundBoard, 'user'>>
)[];
} => {
return { return {
guildId: data.guild_id, guildId: data.guild_id,
sounds: data.soundboard_sounds.map(d => sounds: data.soundboard_sounds.map(d =>

View File

@ -1,6 +1,6 @@
import { type ThreadChannelStructure, Transformers } from '../../client/transformers'; import { type ThreadChannelStructure, Transformers } from '../../client/transformers';
import type { UsingClient } from '../../commands'; import type { UsingClient } from '../../commands';
import { toCamelCase } from '../../common'; import { type ObjectToLower, toCamelCase } from '../../common';
import type { import type {
GatewayThreadCreateDispatchData, GatewayThreadCreateDispatchData,
GatewayThreadDeleteDispatchData, GatewayThreadDeleteDispatchData,
@ -10,12 +10,15 @@ import type {
GatewayThreadUpdateDispatchData, GatewayThreadUpdateDispatchData,
} from '../../types'; } from '../../types';
export const THREAD_CREATE = (self: UsingClient, data: GatewayThreadCreateDispatchData) => { export const THREAD_CREATE = (self: UsingClient, data: GatewayThreadCreateDispatchData): ThreadChannelStructure => {
return Transformers.ThreadChannel(self, data); return Transformers.ThreadChannel(self, data);
}; };
export const THREAD_DELETE = async (self: UsingClient, data: GatewayThreadDeleteDispatchData) => { export const THREAD_DELETE = async (
return (await self.cache.channels?.get(data.id)) ?? toCamelCase(data); self: UsingClient,
data: GatewayThreadDeleteDispatchData,
): Promise<ThreadChannelStructure | ObjectToLower<GatewayThreadDeleteDispatchData>> => {
return ((await self.cache.channels?.get(data.id)) as ThreadChannelStructure | undefined) ?? toCamelCase(data);
}; };
export const THREAD_LIST_SYNC = (_self: UsingClient, data: GatewayThreadListSyncDispatchData) => { export const THREAD_LIST_SYNC = (_self: UsingClient, data: GatewayThreadListSyncDispatchData) => {

View File

@ -1,9 +1,16 @@
import { Transformers } from '../../client/transformers'; import { type GuildMemberStructure, Transformers } from '../../client/transformers';
import type { UsingClient } from '../../commands'; import type { UsingClient } from '../../commands';
import { toCamelCase } from '../../common'; import { type ObjectToLower, toCamelCase } from '../../common';
import type { GatewayTypingStartDispatchData } from '../../types'; import type { GatewayTypingStartDispatchData } from '../../types';
export const TYPING_START = (self: UsingClient, data: GatewayTypingStartDispatchData) => { export const TYPING_START = (
self: UsingClient,
data: GatewayTypingStartDispatchData,
):
| (ObjectToLower<Omit<GatewayTypingStartDispatchData, 'member'>> & {
member: GuildMemberStructure;
})
| ObjectToLower<Omit<GatewayTypingStartDispatchData, 'member'>> => {
return data.member return data.member
? { ? {
...toCamelCase(data), ...toCamelCase(data),

View File

@ -1,3 +1,4 @@
import type { AutoModerationRuleStructure, GuildMemberStructure, GuildStructure } from '../client';
import type { UsingClient } from '../commands'; import type { UsingClient } from '../commands';
import type { MethodContext, ObjectToLower } from '../common'; import type { MethodContext, ObjectToLower } from '../common';
import type { import type {
@ -14,19 +15,19 @@ export class AutoModerationRule extends DiscordBase<APIAutoModerationRule> {
super(client, data); super(client, data);
} }
fetchCreator(force = false) { fetchCreator(force = false): Promise<GuildMemberStructure> {
return this.client.members.fetch(this.guildId, this.creatorId, force); return this.client.members.fetch(this.guildId, this.creatorId, force);
} }
guild(force = false) { guild(force = false): Promise<GuildStructure<'api'>> {
return this.client.guilds.fetch(this.guildId, force); return this.client.guilds.fetch(this.guildId, force);
} }
fetch() { fetch(): Promise<AutoModerationRuleStructure> {
return this.client.guilds.moderation.fetch(this.guildId, this.id); return this.client.guilds.moderation.fetch(this.guildId, this.id);
} }
edit(body: RESTPatchAPIAutoModerationRuleJSONBody, reason?: string) { edit(body: RESTPatchAPIAutoModerationRuleJSONBody, reason?: string): Promise<AutoModerationRuleStructure> {
return this.client.guilds.moderation.edit(this.guildId, this.id, body, reason); return this.client.guilds.moderation.edit(this.guildId, this.id, body, reason);
} }
@ -36,12 +37,16 @@ export class AutoModerationRule extends DiscordBase<APIAutoModerationRule> {
static methods({ client, guildId }: MethodContext<{ guildId: string }>) { static methods({ client, guildId }: MethodContext<{ guildId: string }>) {
return { return {
list: () => client.guilds.moderation.list(guildId), list: (): Promise<AutoModerationRuleStructure[]> => client.guilds.moderation.list(guildId),
create: (body: RESTPostAPIAutoModerationRuleJSONBody) => client.guilds.moderation.create(guildId, body), create: (body: RESTPostAPIAutoModerationRuleJSONBody): Promise<AutoModerationRuleStructure> =>
client.guilds.moderation.create(guildId, body),
delete: (ruleId: string, reason?: string) => client.guilds.moderation.delete(guildId, ruleId, reason), delete: (ruleId: string, reason?: string) => client.guilds.moderation.delete(guildId, ruleId, reason),
fetch: (ruleId: string) => client.guilds.moderation.fetch(guildId, ruleId), fetch: (ruleId: string): Promise<AutoModerationRuleStructure> => client.guilds.moderation.fetch(guildId, ruleId),
edit: (ruleId: string, body: RESTPatchAPIAutoModerationRuleJSONBody, reason?: string) => edit: (
client.guilds.moderation.edit(guildId, ruleId, body, reason), ruleId: string,
body: RESTPatchAPIAutoModerationRuleJSONBody,
reason?: string,
): Promise<AutoModerationRuleStructure> => client.guilds.moderation.edit(guildId, ruleId, body, reason),
}; };
} }
} }

View File

@ -1,3 +1,4 @@
import type { ClientUserStructure } from '../client';
import type { UsingClient } from '../commands'; import type { UsingClient } from '../commands';
import type { GatewayReadyDispatchData, RESTPatchAPICurrentUserJSONBody } from '../types'; import type { GatewayReadyDispatchData, RESTPatchAPICurrentUserJSONBody } from '../types';
import { User } from './User'; import { User } from './User';
@ -12,12 +13,12 @@ export class ClientUser extends User {
super(client, data); super(client, data);
} }
async fetch() { async fetch(): Promise<ClientUserStructure> {
const data = await this.api.users('@me').get(); const data = await this.api.users('@me').get();
return new ClientUser(this.client, data, this.application); return new ClientUser(this.client, data, this.application);
} }
async edit(body: RESTPatchAPICurrentUserJSONBody) { async edit(body: RESTPatchAPICurrentUserJSONBody): Promise<ClientUserStructure> {
const data = await this.api.users('@me').patch({ body }); const data = await this.api.users('@me').patch({ body });
return new ClientUser(this.client, data, this.application); return new ClientUser(this.client, data, this.application);
} }

View File

@ -1,3 +1,4 @@
import type { GuildMemberStructure } from '../client';
import type { UsingClient } from '../commands'; import type { UsingClient } from '../commands';
import type { ObjectToLower, StructPropState, StructStates, ToClass } from '../common/types/util'; import type { ObjectToLower, StructPropState, StructStates, ToClass } from '../common/types/util';
import type { APIGuild, APIPartialGuild, GatewayGuildCreateDispatchData, RESTPatchAPIGuildJSONBody } from '../types'; import type { APIGuild, APIPartialGuild, GatewayGuildCreateDispatchData, RESTPatchAPIGuildJSONBody } from '../types';
@ -61,7 +62,7 @@ export class Guild<State extends StructStates = 'api'> extends (BaseGuild as unk
} }
} }
async fetchOwner(force = false) { async fetchOwner(force = false): Promise<GuildMemberStructure | null> {
// For no reason, discord has some guilds without owner... 🤓 // For no reason, discord has some guilds without owner... 🤓
if (!this.ownerId) { if (!this.ownerId) {
return null; return null;

View File

@ -1,3 +1,4 @@
import type { GuildBanStructure, GuildStructure } from '../client';
import type { UsingClient } from '../commands'; import type { UsingClient } from '../commands';
import { Formatter, type MethodContext, type ObjectToLower } from '../common'; import { Formatter, type MethodContext, type ObjectToLower } from '../common';
import type { BanShorter } from '../common/shorters/bans'; 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); return this.client.bans.remove(this.guildId, this.id, reason);
} }
guild(force = false) { guild(force = false): Promise<GuildStructure<'api'>> {
return this.client.guilds.fetch(this.guildId, force); return this.client.guilds.fetch(this.guildId, force);
} }
fetch(force = false) { fetch(force = false): Promise<GuildBanStructure> {
return this.client.bans.fetch(this.guildId, this.id, force); 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 }>) { static methods({ client, guildId }: MethodContext<{ guildId: string }>) {
return { return {
fetch: (userId: string, force = false) => client.bans.fetch(guildId, userId, force), fetch: (userId: string, force = false): Promise<GuildBanStructure> => client.bans.fetch(guildId, userId, force),
list: (query?: RESTGetAPIGuildBansQuery, force = false) => client.bans.list(guildId, query, force), list: (query?: RESTGetAPIGuildBansQuery, force = false): Promise<GuildBanStructure[]> =>
client.bans.list(guildId, query, force),
create: (memberId: string, body?: Parameters<BanShorter['create']>[2], reason?: string) => create: (memberId: string, body?: Parameters<BanShorter['create']>[2], reason?: string) =>
client.bans.create(guildId, memberId, body, reason), client.bans.create(guildId, memberId, body, reason),
remove: (memberId: string, reason?: string) => client.bans.remove(guildId, memberId, reason), remove: (memberId: string, reason?: string) => client.bans.remove(guildId, memberId, reason),

View File

@ -1,4 +1,5 @@
import type { BaseCDNUrlOptions } from '../api'; import type { BaseCDNUrlOptions } from '../api';
import type { GuildEmojiStructure, GuildStructure } from '../client';
import type { UsingClient } from '../commands'; import type { UsingClient } from '../commands';
import { type EmojiShorter, Formatter, type MethodContext, type ObjectToLower } from '../common'; import { type EmojiShorter, Formatter, type MethodContext, type ObjectToLower } from '../common';
import type { APIEmoji, RESTPatchAPIChannelJSONBody, RESTPatchAPIGuildEmojiJSONBody } from '../types'; import type { APIEmoji, RESTPatchAPIChannelJSONBody, RESTPatchAPIGuildEmojiJSONBody } from '../types';
@ -15,12 +16,12 @@ export class GuildEmoji extends DiscordBase {
super(client, { ...data, id: data.id! }); super(client, { ...data, id: data.id! });
} }
async guild(force = false) { async guild(force = false): Promise<GuildStructure<'api'> | undefined> {
if (!this.guildId) return; if (!this.guildId) return;
return this.client.guilds.fetch(this.guildId, force); return this.client.guilds.fetch(this.guildId, force);
} }
edit(body: RESTPatchAPIChannelJSONBody, reason?: string) { edit(body: RESTPatchAPIChannelJSONBody, reason?: string): Promise<GuildEmojiStructure> {
return this.client.emojis.edit(this.guildId, this.id, body, reason); 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); return this.client.emojis.delete(this.guildId, this.id, reason);
} }
fetch(force = false) { fetch(force = false): Promise<GuildEmojiStructure> {
return this.client.emojis.fetch(this.guildId, this.id, force); 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 }>) { static methods({ client, guildId }: MethodContext<{ guildId: string }>) {
return { return {
edit: (emojiId: string, body: RESTPatchAPIGuildEmojiJSONBody, reason?: string) => edit: (emojiId: string, body: RESTPatchAPIGuildEmojiJSONBody, reason?: string): Promise<GuildEmojiStructure> =>
client.emojis.edit(guildId, emojiId, body, reason), client.emojis.edit(guildId, emojiId, body, reason),
create: (body: Parameters<EmojiShorter['create']>[1]) => client.emojis.create(guildId, body), create: (body: Parameters<EmojiShorter['create']>[1]): Promise<GuildEmojiStructure> =>
fetch: (emojiId: string, force = false) => client.emojis.fetch(guildId, emojiId, force), client.emojis.create(guildId, body),
list: (force = false) => client.emojis.list(guildId, force), fetch: (emojiId: string, force = false): Promise<GuildEmojiStructure> =>
client.emojis.fetch(guildId, emojiId, force),
list: (force = false): Promise<GuildEmojiStructure[]> => client.emojis.list(guildId, force),
}; };
} }
} }

View File

@ -7,7 +7,15 @@ export type GuildMemberData =
| GatewayGuildMemberAddDispatchData | GatewayGuildMemberAddDispatchData
| APIInteractionDataResolvedGuildMember; | 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 type { UsingClient } from '../commands';
import { import {
Formatter, Formatter,
@ -30,6 +38,7 @@ import type {
RESTPutAPIGuildBanJSONBody, RESTPutAPIGuildBanJSONBody,
RESTPutAPIGuildMemberJSONBody, RESTPutAPIGuildMemberJSONBody,
} from '../types'; } from '../types';
import type { GuildRole } from './GuildRole';
import { PermissionsBitField } from './extra/Permissions'; import { PermissionsBitField } from './extra/Permissions';
export interface BaseGuildMember extends DiscordBase, ObjectToLower<Omit<APIGuildMember, 'user' | 'roles'>> {} export interface BaseGuildMember extends DiscordBase, ObjectToLower<Omit<APIGuildMember, 'user' | 'roles'>> {}
@ -50,11 +59,11 @@ export class BaseGuildMember extends DiscordBase {
this.patch(data); this.patch(data);
} }
guild(force = false) { guild(force = false): Promise<GuildStructure<'api'>> {
return this.client.guilds.fetch(this.guildId, force); return this.client.guilds.fetch(this.guildId, force);
} }
fetch(force = false) { fetch(force = false): Promise<GuildMemberStructure> {
return this.client.members.fetch(this.guildId, this.id, force); 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); return this.client.members.kick(this.guildId, this.id, reason);
} }
edit(body: RESTPatchAPIGuildMemberJSONBody, reason?: string) { edit(body: RESTPatchAPIGuildMemberJSONBody, reason?: string): Promise<GuildMemberStructure> {
return this.client.members.edit(this.guildId, this.id, body, reason); 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); return this.client.members.presence(this.id);
} }
voice(force = false) { voice(force = false): Promise<VoiceStateStructure> {
return this.client.members.voice(this.guildId, this.id, force); return this.client.members.voice(this.guildId, this.id, force);
} }
@ -82,7 +91,7 @@ export class BaseGuildMember extends DiscordBase {
return Formatter.userMention(this.id); return Formatter.userMention(this.id);
} }
timeout(time: null | number, reason?: string) { timeout(time: null | number, reason?: string): Promise<GuildMemberStructure> {
return this.client.members.timeout(this.guildId, this.id, time, reason); return this.client.members.timeout(this.guildId, this.id, time, reason);
} }
@ -104,7 +113,7 @@ export class BaseGuildMember extends DiscordBase {
get roles() { get roles() {
return { return {
keys: Object.freeze(this._roles.concat(this.guildId)) as string[], keys: Object.freeze(this._roles.concat(this.guildId)) as string[],
list: (force = false) => list: (force = false): Promise<GuildRole[]> =>
this.client.roles this.client.roles
.list(this.guildId, force) .list(this.guildId, force)
.then(roles => roles.filter(role => this.roles.keys.includes(role.id))), .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), remove: (id: string) => this.client.members.removeRole(this.guildId, this.id, id),
permissions: (force = false) => permissions: (force = false) =>
this.roles.list(force).then(roles => new PermissionsBitField(roles.map(x => BigInt(x.permissions.bits)))), 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)), sorted: (force = false): Promise<GuildRole[]> =>
highest: (force = false) => this.roles.sorted(force).then(roles => roles[0]), this.roles.list(force).then(roles => roles.sort((a, b) => b.position - a.position)),
highest: (force = false): Promise<GuildRole> => this.roles.sorted(force).then(roles => roles[0]),
}; };
} }
static methods({ client, guildId }: MethodContext<{ guildId: string }>) { static methods({ client, guildId }: MethodContext<{ guildId: string }>) {
return { return {
resolve: (resolve: GuildMemberResolvable) => client.members.resolve(guildId, resolve), resolve: (resolve: GuildMemberResolvable): Promise<GuildMemberStructure | undefined> =>
search: (query?: RESTGetAPIGuildMembersSearchQuery) => client.members.search(guildId, query), client.members.resolve(guildId, resolve),
search: (query?: RESTGetAPIGuildMembersSearchQuery): Promise<GuildMemberStructure[]> =>
client.members.search(guildId, query),
unban: (id: string, reason?: string) => client.members.unban(guildId, id, reason), unban: (id: string, reason?: string) => client.members.unban(guildId, id, reason),
ban: (id: string, body?: RESTPutAPIGuildBanJSONBody, reason?: string) => ban: (id: string, body?: RESTPutAPIGuildBanJSONBody, reason?: string) =>
client.members.ban(guildId, id, body, reason), client.members.ban(guildId, id, body, reason),
kick: (id: string, reason?: string) => client.members.kick(guildId, id, reason), kick: (id: string, reason?: string) => client.members.kick(guildId, id, reason),
edit: (id: string, body: RESTPatchAPIGuildMemberJSONBody, reason?: string) => edit: (id: string, body: RESTPatchAPIGuildMemberJSONBody, reason?: string) =>
client.members.edit(guildId, id, body, reason), client.members.edit(guildId, id, body, reason),
add: (id: string, body: RESTPutAPIGuildMemberJSONBody) => client.members.add(guildId, id, body), add: (id: string, body: RESTPutAPIGuildMemberJSONBody): Promise<GuildMemberStructure | undefined> =>
client.members.add(guildId, id, body),
addRole: (memberId: string, id: string) => client.members.addRole(guildId, memberId, id), addRole: (memberId: string, id: string) => client.members.addRole(guildId, memberId, id),
removeRole: (memberId: string, id: string) => client.members.removeRole(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), fetch: (memberId: string, force = false): Promise<GuildMemberStructure> =>
list: (query?: RESTGetAPIGuildMembersQuery, force = false) => client.members.list(guildId, query, force), client.members.fetch(guildId, memberId, force),
list: (query?: RESTGetAPIGuildMembersQuery, force = false): Promise<GuildMemberStructure[]> =>
client.members.list(guildId, query, force),
}; };
} }
} }
@ -180,11 +195,11 @@ export class GuildMember extends BaseGuildMember {
return this.nick ?? this.globalName ?? this.username; return this.nick ?? this.globalName ?? this.username;
} }
dm(force = false) { dm(force = false): Promise<DMChannelStructure> {
return this.user.dm(force); return this.user.dm(force);
} }
write(body: MessageCreateBodyRequest) { write(body: MessageCreateBodyRequest): Promise<MessageStructure> {
return this.user.write(body); return this.user.write(body);
} }

View File

@ -1,3 +1,4 @@
import type { GuildRoleStructure, GuildStructure } from '../client';
import type { UsingClient } from '../commands'; import type { UsingClient } from '../commands';
import { Formatter, type MethodContext, type ObjectToLower } from '../common'; import { Formatter, type MethodContext, type ObjectToLower } from '../common';
import type { import type {
@ -22,20 +23,20 @@ export class GuildRole extends DiscordBase {
this.permissions = new PermissionsBitField(BigInt(data.permissions)); this.permissions = new PermissionsBitField(BigInt(data.permissions));
} }
async guild(force = false) { async guild(force = false): Promise<GuildStructure<'api'> | undefined> {
if (!this.guildId) return; if (!this.guildId) return;
return this.client.guilds.fetch(this.guildId, force); return this.client.guilds.fetch(this.guildId, force);
} }
fetch(force = false) { fetch(force = false): Promise<GuildRoleStructure> {
return this.client.roles.fetch(this.guildId, this.id, force); return this.client.roles.fetch(this.guildId, this.id, force);
} }
edit(body: RESTPatchAPIGuildRoleJSONBody) { edit(body: RESTPatchAPIGuildRoleJSONBody): Promise<GuildRoleStructure> {
return this.client.roles.edit(this.guildId, this.id, body); return this.client.roles.edit(this.guildId, this.id, body);
} }
delete(reason?: string) { delete(reason?: string): Promise<GuildRoleStructure> {
return this.client.roles.delete(this.guildId, this.id, reason); 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 }>) { static methods(ctx: MethodContext<{ guildId: string }>) {
return { return {
create: (body: RESTPostAPIGuildRoleJSONBody) => ctx.client.roles.create(ctx.guildId, body), create: (body: RESTPostAPIGuildRoleJSONBody): Promise<GuildRoleStructure> =>
list: (force = false) => ctx.client.roles.list(ctx.guildId, force), ctx.client.roles.create(ctx.guildId, body),
edit: (roleId: string, body: RESTPatchAPIGuildRoleJSONBody, reason?: string) => list: (force = false): Promise<GuildRoleStructure[]> => ctx.client.roles.list(ctx.guildId, force),
edit: (roleId: string, body: RESTPatchAPIGuildRoleJSONBody, reason?: string): Promise<GuildRoleStructure> =>
ctx.client.roles.edit(ctx.guildId, roleId, body, reason), ctx.client.roles.edit(ctx.guildId, roleId, body, reason),
delete: (roleId: string, reason?: string) => ctx.client.roles.delete(ctx.guildId, roleId, reason), delete: (roleId: string, reason?: string): Promise<GuildRoleStructure> =>
editPositions: (body: RESTPatchAPIGuildRolePositionsJSONBody) => ctx.client.roles.delete(ctx.guildId, roleId, reason),
editPositions: (body: RESTPatchAPIGuildRolePositionsJSONBody): Promise<GuildRoleStructure[]> =>
ctx.client.roles.editPositions(ctx.guildId, body), ctx.client.roles.editPositions(ctx.guildId, body),
}; };
} }

View File

@ -1,3 +1,4 @@
import type { GuildStructure, GuildTemplateStructure } from '../client';
import type { UsingClient } from '../commands'; import type { UsingClient } from '../commands';
import type { MethodContext, ObjectToLower } from '../common'; import type { MethodContext, ObjectToLower } from '../common';
import type { APITemplate, RESTPatchAPIGuildTemplateJSONBody, RESTPostAPIGuildTemplatesJSONBody } from '../types'; import type { APITemplate, RESTPatchAPIGuildTemplateJSONBody, RESTPostAPIGuildTemplatesJSONBody } from '../types';
@ -11,35 +12,36 @@ export class GuildTemplate extends Base {
this.__patchThis(data); this.__patchThis(data);
} }
guild(force = false) { guild(force = false): Promise<GuildStructure<'api'>> {
return this.client.guilds.fetch(this.sourceGuildId, force); return this.client.guilds.fetch(this.sourceGuildId, force);
} }
fetch() { fetch(): Promise<GuildTemplateStructure> {
return this.client.templates.fetch(this.sourceGuildId); return this.client.templates.fetch(this.sourceGuildId);
} }
sync() { sync(): Promise<GuildTemplateStructure> {
return this.client.templates.sync(this.sourceGuildId, this.code); return this.client.templates.sync(this.sourceGuildId, this.code);
} }
edit(body: RESTPatchAPIGuildTemplateJSONBody) { edit(body: RESTPatchAPIGuildTemplateJSONBody): Promise<GuildTemplateStructure> {
return this.client.templates.edit(this.sourceGuildId, this.code, body); return this.client.templates.edit(this.sourceGuildId, this.code, body);
} }
delete() { delete(): Promise<GuildTemplateStructure> {
return this.client.templates.delete(this.sourceGuildId, this.code); return this.client.templates.delete(this.sourceGuildId, this.code);
} }
static methods(ctx: MethodContext<{ guildId: string }>) { static methods(ctx: MethodContext<{ guildId: string }>) {
return { return {
fetch: (code: string) => ctx.client.templates.fetch(code), fetch: (code: string): Promise<GuildTemplateStructure> => ctx.client.templates.fetch(code),
list: () => ctx.client.templates.list(ctx.guildId), list: (): Promise<GuildTemplateStructure[]> => ctx.client.templates.list(ctx.guildId),
create: (body: RESTPostAPIGuildTemplatesJSONBody) => ctx.client.templates.create(ctx.guildId, body), create: (body: RESTPostAPIGuildTemplatesJSONBody): Promise<GuildTemplateStructure> =>
sync: (code: string) => ctx.client.templates.sync(ctx.guildId, code), ctx.client.templates.create(ctx.guildId, body),
edit: (code: string, body: RESTPatchAPIGuildTemplateJSONBody) => sync: (code: string): Promise<GuildTemplateStructure> => ctx.client.templates.sync(ctx.guildId, code),
edit: (code: string, body: RESTPatchAPIGuildTemplateJSONBody): Promise<GuildTemplateStructure> =>
ctx.client.templates.edit(ctx.guildId, code, body), ctx.client.templates.edit(ctx.guildId, code, body),
delete: (code: string) => ctx.client.templates.delete(ctx.guildId, code), delete: (code: string): Promise<GuildTemplateStructure> => ctx.client.templates.delete(ctx.guildId, code),
}; };
} }
} }

View File

@ -435,15 +435,15 @@ export class Interaction<
FromGuild extends boolean = boolean, FromGuild extends boolean = boolean,
Type extends APIInteraction = APIInteraction, Type extends APIInteraction = APIInteraction,
> extends BaseInteraction<FromGuild, Type> { > extends BaseInteraction<FromGuild, Type> {
fetchMessage(messageId: string) { fetchMessage(messageId: string): Promise<WebhookMessageStructure> {
return this.client.interactions.fetchResponse(this.token, messageId); return this.client.interactions.fetchResponse(this.token, messageId);
} }
fetchResponse() { fetchResponse(): Promise<WebhookMessageStructure> {
return this.fetchMessage('@original'); return this.fetchMessage('@original');
} }
async write<FR extends boolean = false>( write<FR extends boolean = false>(
body: InteractionCreateBodyRequest, body: InteractionCreateBodyRequest,
withResponse?: FR, withResponse?: FR,
): Promise<When<FR, WebhookMessageStructure, void>> { ): Promise<When<FR, WebhookMessageStructure, void>> {
@ -467,7 +467,10 @@ export class Interaction<
body: InteractionCreateBodyRequest, body: InteractionCreateBodyRequest,
fetchReply?: FR, fetchReply?: FR,
): Promise<When<FR, WebhookMessageStructure, void>>; ): Promise<When<FR, WebhookMessageStructure, void>>;
async editOrReply<FR extends true = true>(body: InteractionMessageUpdateBodyRequest, fetchReply?: FR) { async editOrReply<FR extends true = true>(
body: InteractionMessageUpdateBodyRequest,
fetchReply?: FR,
): Promise<WebhookMessageStructure> {
if (await this.replied) { if (await this.replied) {
const { content, embeds, allowed_mentions, components, files, attachments, poll } = body; const { content, embeds, allowed_mentions, components, files, attachments, poll } = body;
return this.editResponse({ content, embeds, allowed_mentions, components, files, attachments, poll }); 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); return this.write(body as InteractionCreateBodyRequest, fetchReply);
} }
editMessage(messageId: string, body: InteractionMessageUpdateBodyRequest) { editMessage(messageId: string, body: InteractionMessageUpdateBodyRequest): Promise<WebhookMessageStructure> {
return this.client.interactions.editMessage(this.token, messageId, body); return this.client.interactions.editMessage(this.token, messageId, body);
} }
editResponse(body: InteractionMessageUpdateBodyRequest) { editResponse(body: InteractionMessageUpdateBodyRequest): Promise<WebhookMessageStructure> {
return this.editMessage('@original', body); return this.editMessage('@original', body);
} }
@ -491,7 +494,7 @@ export class Interaction<
return this.client.interactions.deleteResponse(this.token, messageId); return this.client.interactions.deleteResponse(this.token, messageId);
} }
followup(body: MessageWebhookCreateBodyRequest) { followup(body: MessageWebhookCreateBodyRequest): Promise<WebhookMessageStructure> {
return this.client.interactions.followup(this.token, body); return this.client.interactions.followup(this.token, body);
} }
} }
@ -784,8 +787,11 @@ export interface ModalSubmitInteraction<FromGuild extends boolean = boolean>
export class ModalSubmitInteraction<FromGuild extends boolean = boolean> extends BaseInteraction<FromGuild> { export class ModalSubmitInteraction<FromGuild extends boolean = boolean> extends BaseInteraction<FromGuild> {
declare data: ObjectToLower<APIModalSubmission>; declare data: ObjectToLower<APIModalSubmission>;
update<WR extends boolean = false>(data: ComponentInteractionMessageUpdate, withResponse?: WR) { update<WR extends boolean = false>(
return this.reply( data: ComponentInteractionMessageUpdate,
withResponse?: WR,
): Promise<When<WR, WebhookMessageStructure, undefined>> {
return this.reply<WR>(
{ {
type: InteractionResponseType.UpdateMessage, type: InteractionResponseType.UpdateMessage,
data, data,
@ -794,7 +800,7 @@ export class ModalSubmitInteraction<FromGuild extends boolean = boolean> extends
); );
} }
deferUpdate<WR extends boolean = false>(withResponse?: WR) { deferUpdate<WR extends boolean = false>(withResponse?: WR): Promise<When<WR, WebhookMessageStructure, undefined>> {
return this.reply<WR>( return this.reply<WR>(
{ {
type: InteractionResponseType.DeferredMessageUpdate, type: InteractionResponseType.DeferredMessageUpdate,

View File

@ -1,10 +1,14 @@
import { Embed } from '..'; import { type AllChannels, Embed } from '..';
import type { ListenerOptions } from '../builders'; import type { ListenerOptions } from '../builders';
import { import {
type GuildMemberStructure, type GuildMemberStructure,
type GuildStructure,
type MessageStructure,
type PollStructure, type PollStructure,
Transformers, Transformers,
type UserStructure, type UserStructure,
type WebhookMessageStructure,
type WebhookStructure,
} from '../client/transformers'; } from '../client/transformers';
import type { UsingClient } from '../commands'; import type { UsingClient } from '../commands';
import { type ObjectToLower, toCamelCase } from '../common'; import { type ObjectToLower, toCamelCase } from '../common';
@ -56,7 +60,7 @@ export class BaseMessage extends DiscordBase {
this.patch(data); this.patch(data);
} }
get user() { get user(): UserStructure {
return this.author; return this.author;
} }
@ -68,12 +72,12 @@ export class BaseMessage extends DiscordBase {
return Formatter.messageLink(this.guildId!, this.channelId, this.id); return Formatter.messageLink(this.guildId!, this.channelId, this.id);
} }
async guild(force = false) { async guild(force = false): Promise<GuildStructure<'api'> | undefined> {
if (!this.guildId) return; if (!this.guildId) return;
return this.client.guilds.fetch(this.guildId, force); return this.client.guilds.fetch(this.guildId, force);
} }
channel(force = false) { channel(force = false): Promise<AllChannels> {
return this.client.channels.fetch(this.channelId, force); return this.client.channels.fetch(this.channelId, force);
} }
@ -125,11 +129,11 @@ export class Message extends BaseMessage {
super(client, data); super(client, data);
} }
fetch(force = false) { fetch(force = false): Promise<MessageStructure> {
return this.client.messages.fetch(this.id, this.channelId, force); return this.client.messages.fetch(this.id, this.channelId, force);
} }
reply(body: Omit<MessageCreateBodyRequest, 'message_reference'>, fail = true) { reply(body: Omit<MessageCreateBodyRequest, 'message_reference'>, fail = true): Promise<MessageStructure> {
return this.write({ return this.write({
...body, ...body,
message_reference: { message_reference: {
@ -141,11 +145,11 @@ export class Message extends BaseMessage {
}); });
} }
edit(body: MessageUpdateBodyRequest) { edit(body: MessageUpdateBodyRequest): Promise<MessageStructure> {
return this.client.messages.edit(this.id, this.channelId, body); return this.client.messages.edit(this.id, this.channelId, body);
} }
write(body: MessageCreateBodyRequest) { write(body: MessageCreateBodyRequest): Promise<MessageStructure> {
return this.client.messages.write(this.channelId, body); 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); return this.client.messages.delete(this.id, this.channelId, reason);
} }
crosspost(reason?: string) { crosspost(reason?: string): Promise<MessageStructure> {
return this.client.messages.crosspost(this.id, this.channelId, reason); return this.client.messages.crosspost(this.id, this.channelId, reason);
} }
} }
@ -173,15 +177,15 @@ export class WebhookMessage extends BaseMessage {
super(client, data); super(client, data);
} }
fetchWebhook() { fetchWebhook(): Promise<WebhookStructure> {
return this.client.webhooks.fetch(this.webhookId, this.webhookToken); return this.client.webhooks.fetch(this.webhookId, this.webhookToken);
} }
fetch() { fetch(): Promise<WebhookMessageStructure> {
return this.client.webhooks.fetchMessage(this.webhookId, this.webhookToken, this.id, this.thread?.id); return this.client.webhooks.fetchMessage(this.webhookId, this.webhookToken, this.id, this.thread?.id);
} }
edit(body: EditMessageWebhook) { edit(body: EditMessageWebhook): Promise<WebhookMessageStructure> {
const { query, ...rest } = body; const { query, ...rest } = body;
return this.client.webhooks.editMessage(this.webhookId, this.webhookToken, { return this.client.webhooks.editMessage(this.webhookId, this.webhookToken, {
body: rest, body: rest,
@ -190,7 +194,7 @@ export class WebhookMessage extends BaseMessage {
}); });
} }
write(body: WriteMessageWebhook) { write(body: WriteMessageWebhook): Promise<WebhookMessageStructure | null> {
const { query, ...rest } = body; const { query, ...rest } = body;
return this.client.webhooks.writeMessage(this.webhookId, this.webhookToken, { return this.client.webhooks.writeMessage(this.webhookId, this.webhookToken, {
body: rest, body: rest,

View File

@ -1,4 +1,5 @@
import type { ValidAnswerId } from '../api/Routes/channels'; import type { ValidAnswerId } from '../api/Routes/channels';
import type { MessageStructure, UserStructure } from '../client/transformers';
import type { UsingClient } from '../commands'; import type { UsingClient } from '../commands';
import { type ObjectToLower, toCamelCase } from '../common'; import { type ObjectToLower, toCamelCase } from '../common';
import type { APIPoll } from '../types'; import type { APIPoll } from '../types';
@ -25,11 +26,11 @@ export class Poll extends Base {
return new Date(this.expiry); return new Date(this.expiry);
} }
end() { end(): Promise<MessageStructure> {
return this.client.messages.endPoll(this.channelId, this.messageId); return this.client.messages.endPoll(this.channelId, this.messageId);
} }
getAnswerVoters(id: ValidAnswerId) { getAnswerVoters(id: ValidAnswerId): Promise<UserStructure[]> {
if (!this.answers.find(x => x.answerId === id)) throw new Error('Invalid answer id'); if (!this.answers.find(x => x.answerId === id)) throw new Error('Invalid answer id');
return this.client.messages.getAnswerVoters(this.channelId, this.messageId, id); return this.client.messages.getAnswerVoters(this.channelId, this.messageId, id);
} }

View File

@ -1,4 +1,4 @@
import type { RawFile, UsingClient } from '..'; import type { GuildStructure, RawFile, StickerStructure, UsingClient } from '..';
import type { Attachment, AttachmentBuilder } from '../builders'; import type { Attachment, AttachmentBuilder } from '../builders';
import { Transformers, type UserStructure } from '../client/transformers'; import { Transformers, type UserStructure } from '../client/transformers';
import type { MethodContext, ObjectToLower } from '../common'; import type { MethodContext, ObjectToLower } from '../common';
@ -16,17 +16,17 @@ export class Sticker extends DiscordBase {
} }
} }
async guild(force = false) { async guild(force = false): Promise<GuildStructure<'api'> | undefined> {
if (!this.guildId) return; if (!this.guildId) return;
return this.client.guilds.fetch(this.guildId, force); return this.client.guilds.fetch(this.guildId, force);
} }
async edit(body: RESTPatchAPIGuildStickerJSONBody, reason?: string) { async edit(body: RESTPatchAPIGuildStickerJSONBody, reason?: string): Promise<StickerStructure | undefined> {
if (!this.guildId) return; if (!this.guildId) return;
return this.client.guilds.stickers.edit(this.guildId, this.id, body, reason); return this.client.guilds.stickers.edit(this.guildId, this.id, body, reason);
} }
async fetch(force = false) { async fetch(force = false): Promise<StickerStructure | undefined> {
if (!this.guildId) return; if (!this.guildId) return;
return this.client.guilds.stickers.fetch(this.guildId, this.id, force); 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 }>) { static methods({ client, guildId }: MethodContext<{ guildId: string }>) {
return { return {
list: () => client.guilds.stickers.list(guildId), list: (): Promise<StickerStructure[]> => client.guilds.stickers.list(guildId),
create: (payload: CreateStickerBodyRequest, reason?: string) => create: (payload: CreateStickerBodyRequest, reason?: string): Promise<StickerStructure> =>
client.guilds.stickers.create(guildId, payload, reason), client.guilds.stickers.create(guildId, payload, reason),
edit: (stickerId: string, body: RESTPatchAPIGuildStickerJSONBody, reason?: string) => edit: (stickerId: string, body: RESTPatchAPIGuildStickerJSONBody, reason?: string): Promise<StickerStructure> =>
client.guilds.stickers.edit(guildId, stickerId, body, reason), 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<StickerStructure> =>
client.guilds.stickers.fetch(guildId, stickerId, force),
delete: (stickerId: string, reason?: string) => client.guilds.stickers.delete(guildId, stickerId, reason), delete: (stickerId: string, reason?: string) => client.guilds.stickers.delete(guildId, stickerId, reason),
}; };
} }

View File

@ -1,4 +1,5 @@
import { calculateUserDefaultAvatarIndex } from '../api'; import { calculateUserDefaultAvatarIndex } from '../api';
import type { DMChannelStructure, MessageStructure, UserStructure } from '../client';
import { Formatter, type MessageCreateBodyRequest, type ObjectToLower } from '../common'; import { Formatter, type MessageCreateBodyRequest, type ObjectToLower } from '../common';
import type { ImageOptions } from '../common/types/options'; import type { ImageOptions } from '../common/types/options';
import type { APIUser } from '../types'; import type { APIUser } from '../types';
@ -18,18 +19,18 @@ export class User extends DiscordBase<APIUser> {
/** /**
* Fetch user * Fetch user
*/ */
fetch(force = false) { fetch(force = false): Promise<UserStructure> {
return this.client.users.fetch(this.id, force); return this.client.users.fetch(this.id, force);
} }
/** /**
* Open a DM with the user * Open a DM with the user
*/ */
dm(force = false) { dm(force = false): Promise<DMChannelStructure> {
return this.client.users.createDM(this.id, force); return this.client.users.createDM(this.id, force);
} }
write(body: MessageCreateBodyRequest) { write(body: MessageCreateBodyRequest): Promise<MessageStructure> {
return this.client.users.write(this.id, body); return this.client.users.write(this.id, body);
} }

View File

@ -1,4 +1,4 @@
import type { UsingClient } from '../'; import type { UserStructure, UsingClient, VoiceStateStructure } from '../';
import type { VoiceStateResource } from '../cache/resources/voice-states'; import type { VoiceStateResource } from '../cache/resources/voice-states';
import { type GuildMemberStructure, Transformers } from '../client/transformers'; import { type GuildMemberStructure, Transformers } from '../client/transformers';
import type { ObjectToLower } from '../common'; import type { ObjectToLower } from '../common';
@ -22,26 +22,26 @@ export class VoiceState extends Base {
return this.mute || this.selfMute; return this.mute || this.selfMute;
} }
async member(force?: boolean) { async member(force?: boolean): Promise<GuildMemberStructure> {
return (this.withMember = await this.client.members.fetch(this.guildId, this.userId, force)); return (this.withMember = await this.client.members.fetch(this.guildId, this.userId, force));
} }
user(force?: boolean) { user(force?: boolean): Promise<UserStructure> {
return this.client.users.fetch(this.userId, force); return this.client.users.fetch(this.userId, force);
} }
async channel(force?: boolean) { async channel(force?: boolean): Promise<AllGuildVoiceChannels | undefined> {
if (!this.channelId) return; if (!this.channelId) return;
return this.client.channels.fetch(this.channelId, force) as Promise<AllGuildVoiceChannels>; return this.client.channels.fetch(this.channelId, force) as Promise<AllGuildVoiceChannels>;
} }
async setMute(mute = !this.mute, reason?: string) { async setMute(mute = !this.mute, reason?: string): Promise<GuildMemberStructure> {
const member = await this.client.members.edit(this.guildId, this.userId, { mute }, reason); const member = await this.client.members.edit(this.guildId, this.userId, { mute }, reason);
this.mute = mute; this.mute = mute;
return member; return member;
} }
async setDeaf(deaf = !this.deaf, reason?: string) { async setDeaf(deaf = !this.deaf, reason?: string): Promise<GuildMemberStructure> {
const member = await this.client.members.edit(this.guildId, this.userId, { deaf }, reason); const member = await this.client.members.edit(this.guildId, this.userId, { deaf }, reason);
this.deaf = deaf; this.deaf = deaf;
return member; return member;
@ -60,16 +60,16 @@ export class VoiceState extends Base {
this.requestToSpeakTimestamp = date; this.requestToSpeakTimestamp = date;
} }
disconnect(reason?: string) { disconnect(reason?: string): Promise<GuildMemberStructure> {
return this.setChannel(null, reason); return this.setChannel(null, reason);
} }
async fetch(force = false) { async fetch(force = false): Promise<VoiceStateStructure> {
const member = this.withMember ?? (await this.member(force)); const member = this.withMember ?? (await this.member(force));
return this.client.members.voice(this.guildId, member.id, 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<GuildMemberStructure> {
const member = await this.client.members.edit(this.guildId, this.userId, { channel_id }, reason); const member = await this.client.members.edit(this.guildId, this.userId, { channel_id }, reason);
this.channelId = channel_id; this.channelId = channel_id;
return member; return member;

View File

@ -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 { UsingClient } from '../commands';
import type { import type {
ImageOptions, ImageOptions,
@ -18,6 +25,7 @@ import type {
RESTPatchAPIWebhookWithTokenJSONBody, RESTPatchAPIWebhookWithTokenJSONBody,
RESTPostAPIWebhookWithTokenQuery, RESTPostAPIWebhookWithTokenQuery,
} from '../types'; } from '../types';
import type { AllChannels } from './channels';
import { DiscordBase } from './extra/DiscordBase'; import { DiscordBase } from './extra/DiscordBase';
export interface Webhook extends DiscordBase, ObjectToLower<Omit<APIWebhook, 'user' | 'source_guild'>> {} export interface Webhook extends DiscordBase, ObjectToLower<Omit<APIWebhook, 'user' | 'source_guild'>> {}
@ -58,7 +66,7 @@ export class Webhook extends DiscordBase {
* @param force Whether to force fetching the guild even if it's already cached. * @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. * @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<GuildStructure<'api'> | undefined> {
if (!this.sourceGuild?.id) return; if (!this.sourceGuild?.id) return;
return this.client.guilds.fetch(this.sourceGuild.id, force); 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. * @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. * @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<AllChannels | undefined> {
if (!this.sourceChannel?.id) return; if (!this.sourceChannel?.id) return;
return this.client.channels.fetch(this.sourceChannel.id, force); 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. * Fetches the webhook data from the Discord API.
* @returns A promise that resolves to the fetched webhook data. * @returns A promise that resolves to the fetched webhook data.
*/ */
fetch() { fetch(): Promise<WebhookStructure> {
return this.client.webhooks.fetch(this.id, this.token); 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. * @param reason The reason for editing the webhook.
* @returns A promise that resolves when the webhook is successfully edited. * @returns A promise that resolves when the webhook is successfully edited.
*/ */
edit(body: RESTPatchAPIWebhookJSONBody | RESTPatchAPIWebhookWithTokenJSONBody, reason?: string) { edit(
body: RESTPatchAPIWebhookJSONBody | RESTPatchAPIWebhookWithTokenJSONBody,
reason?: string,
): Promise<WebhookStructure> {
return this.client.webhooks.edit(this.id, body, { reason, token: this.token }); 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 }>) { static messages({ client, webhookId, webhookToken }: MethodContext<{ webhookId: string; webhookToken: string }>) {
return { return {
/** Writes a message through the webhook. */ /** Writes a message through the webhook. */
write: (payload: MessageWebhookMethodWriteParams) => write: (payload: MessageWebhookMethodWriteParams): Promise<WebhookMessageStructure | null> =>
client.webhooks.writeMessage(webhookId, webhookToken, payload), client.webhooks.writeMessage(webhookId, webhookToken, payload),
/** Edits a message sent through the webhook. */ /** Edits a message sent through the webhook. */
edit: (payload: MessageWebhookMethodEditParams) => client.webhooks.editMessage(webhookId, webhookToken, payload), edit: (payload: MessageWebhookMethodEditParams): Promise<WebhookMessageStructure> =>
client.webhooks.editMessage(webhookId, webhookToken, payload),
/** Deletes a message sent through the webhook. */ /** Deletes a message sent through the webhook. */
delete: (messageId: string, reason?: string) => delete: (messageId: string, reason?: string) =>
client.webhooks.deleteMessage(webhookId, webhookToken, messageId, reason), client.webhooks.deleteMessage(webhookId, webhookToken, messageId, reason),

View File

@ -9,14 +9,18 @@ import {
type DirectoryChannelStructure, type DirectoryChannelStructure,
type ForumChannelStructure, type ForumChannelStructure,
type GuildMemberStructure, type GuildMemberStructure,
type GuildStructure,
type MediaChannelStructure, type MediaChannelStructure,
type MessageStructure,
type NewsChannelStructure, type NewsChannelStructure,
type StageChannelStructure, type StageChannelStructure,
type TextGuildChannelStructure, type TextGuildChannelStructure,
type ThreadChannelStructure, type ThreadChannelStructure,
Transformers, Transformers,
type UserStructure,
type VoiceChannelStructure, type VoiceChannelStructure,
type VoiceStateStructure, type VoiceStateStructure,
type WebhookStructure,
} from '../client'; } from '../client';
import type { UsingClient } from '../commands'; import type { UsingClient } from '../commands';
import { import {
@ -80,11 +84,11 @@ export class BaseNoEditableChannel<T extends ChannelType> extends DiscordBase<AP
return Formatter.channelLink(this.id); return Formatter.channelLink(this.id);
} }
fetch(force = false) { fetch(force = false): Promise<AllChannels> {
return this.client.channels.fetch(this.id, force); return this.client.channels.fetch(this.id, force);
} }
delete(reason?: string) { delete(reason?: string): Promise<AllChannels> {
return this.client.channels.delete(this.id, { reason }); return this.client.channels.delete(this.id, { reason });
} }
@ -150,11 +154,14 @@ export class BaseNoEditableChannel<T extends ChannelType> extends DiscordBase<AP
static allMethods(ctx: MethodContext<{ guildId: string }>) { static allMethods(ctx: MethodContext<{ guildId: string }>) {
return { return {
list: (force = false) => ctx.client.guilds.channels.list(ctx.guildId, force), list: (force = false): Promise<AllChannels[]> => ctx.client.guilds.channels.list(ctx.guildId, force),
fetch: (id: string, force = false) => ctx.client.guilds.channels.fetch(ctx.guildId, id, force), fetch: (id: string, force = false): Promise<AllChannels> =>
create: (body: RESTPostAPIGuildChannelJSONBody) => ctx.client.guilds.channels.create(ctx.guildId, body), ctx.client.guilds.channels.fetch(ctx.guildId, id, force),
delete: (id: string, reason?: string) => ctx.client.guilds.channels.delete(ctx.guildId, id, reason), create: (body: RESTPostAPIGuildChannelJSONBody): Promise<AllChannels> =>
edit: (id: string, body: RESTPatchAPIChannelJSONBody, reason?: string) => ctx.client.guilds.channels.create(ctx.guildId, body),
delete: (id: string, reason?: string): Promise<AllChannels> =>
ctx.client.guilds.channels.delete(ctx.guildId, id, reason),
edit: (id: string, body: RESTPatchAPIChannelJSONBody, reason?: string): Promise<AllChannels> =>
ctx.client.guilds.channels.edit(ctx.guildId, id, body, reason), ctx.client.guilds.channels.edit(ctx.guildId, id, body, reason),
editPositions: (body: RESTPatchAPIGuildChannelPositionsJSONBody) => editPositions: (body: RESTPatchAPIGuildChannelPositionsJSONBody) =>
ctx.client.guilds.channels.editPositions(ctx.guildId, body), ctx.client.guilds.channels.editPositions(ctx.guildId, body),
@ -218,7 +225,7 @@ export class BaseGuildChannel extends BaseChannel<ChannelType> {
return this.client.channels.overwritesFor(this.id, member); return this.client.channels.overwritesFor(this.id, member);
} }
guild(force = false) { guild(force = false): Promise<GuildStructure<'api'>> {
return this.client.guilds.fetch(this.guildId!, force); return this.client.guilds.fetch(this.guildId!, force);
} }
@ -265,15 +272,18 @@ export class MessagesMethods extends DiscordBase {
static messages(ctx: MethodContext<{ channelId: string }>) { static messages(ctx: MethodContext<{ channelId: string }>) {
return { return {
write: (body: MessageCreateBodyRequest) => ctx.client.messages.write(ctx.channelId, body), write: (body: MessageCreateBodyRequest): Promise<MessageStructure> =>
edit: (messageId: string, body: MessageUpdateBodyRequest) => ctx.client.messages.write(ctx.channelId, body),
edit: (messageId: string, body: MessageUpdateBodyRequest): Promise<MessageStructure> =>
ctx.client.messages.edit(messageId, ctx.channelId, body), ctx.client.messages.edit(messageId, ctx.channelId, body),
crosspost: (messageId: string, reason?: string) => crosspost: (messageId: string, reason?: string): Promise<MessageStructure> =>
ctx.client.messages.crosspost(messageId, ctx.channelId, reason), ctx.client.messages.crosspost(messageId, ctx.channelId, reason),
delete: (messageId: string, reason?: string) => ctx.client.messages.delete(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<MessageStructure> =>
ctx.client.messages.fetch(messageId, ctx.channelId, force),
purge: (messages: string[], reason?: string) => ctx.client.messages.purge(messages, ctx.channelId, reason), 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<MessageStructure[]> =>
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), add: (messageId: string, emoji: EmojiResolvable) => ctx.client.reactions.add(messageId, ctx.channelId, emoji),
delete: (messageId: string, emoji: EmojiResolvable, userId = '@me') => delete: (messageId: string, emoji: EmojiResolvable, userId = '@me') =>
ctx.client.reactions.delete(messageId, ctx.channelId, emoji, userId), ctx.client.reactions.delete(messageId, ctx.channelId, emoji, userId),
fetch: (messageId: string, emoji: EmojiResolvable, query?: RESTGetAPIChannelMessageReactionUsersQuery) => fetch: (
ctx.client.reactions.fetch(messageId, ctx.channelId, emoji, query), messageId: string,
emoji: EmojiResolvable,
query?: RESTGetAPIChannelMessageReactionUsersQuery,
): Promise<UserStructure[]> => ctx.client.reactions.fetch(messageId, ctx.channelId, emoji, query),
purge: (messageId: string, emoji?: EmojiResolvable) => purge: (messageId: string, emoji?: EmojiResolvable) =>
ctx.client.reactions.purge(messageId, ctx.channelId, emoji), ctx.client.reactions.purge(messageId, ctx.channelId, emoji),
}; };
@ -291,7 +304,7 @@ export class MessagesMethods extends DiscordBase {
static pins(ctx: MethodContext<{ channelId: string }>) { static pins(ctx: MethodContext<{ channelId: string }>) {
return { return {
fetch: () => ctx.client.channels.pins(ctx.channelId), fetch: (): Promise<MessageStructure[]> => ctx.client.channels.pins(ctx.channelId),
set: (messageId: string, reason?: string) => ctx.client.channels.setPin(messageId, ctx.channelId, reason), 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), 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); return this.edit({ default_thread_rate_limit_per_user: rate }, reason);
} }
thread(body: RESTPostAPIGuildForumThreadsJSONBody, reason?: string) { thread(body: RESTPostAPIGuildForumThreadsJSONBody, reason?: string): Promise<ThreadChannelStructure> {
return this.client.channels.thread(this.id, body, reason); 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); 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); 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<Collection<string, GuildMemberStructure>> {
const collection = new Collection<string, GuildMemberStructure>(); const collection = new Collection<string, GuildMemberStructure>();
const states = await this.states(); const states = await this.states();
@ -457,7 +470,7 @@ export class WebhookGuildMethods extends DiscordBase {
static guild(ctx: MethodContext<{ guildId: string }>) { static guild(ctx: MethodContext<{ guildId: string }>) {
return { return {
list: () => ctx.client.webhooks.listFromGuild(ctx.guildId), list: (): Promise<WebhookStructure[]> => ctx.client.webhooks.listFromGuild(ctx.guildId),
}; };
} }
} }
@ -470,8 +483,9 @@ export class WebhookChannelMethods extends DiscordBase {
static channel(ctx: MethodContext<{ channelId: string }>) { static channel(ctx: MethodContext<{ channelId: string }>) {
return { return {
list: () => ctx.client.webhooks.listFromChannel(ctx.channelId), list: (): Promise<WebhookStructure[]> => ctx.client.webhooks.listFromChannel(ctx.channelId),
create: (body: RESTPostAPIChannelWebhookJSONBody) => ctx.client.webhooks.create(ctx.channelId, body), create: (body: RESTPostAPIChannelWebhookJSONBody): Promise<WebhookStructure> =>
ctx.client.webhooks.create(ctx.channelId, body),
}; };
} }
} }