├── .gitignore ├── .prettierrc ├── .vscode ├── extensions.json └── settings.json ├── .yarn ├── plugins │ └── @yarnpkg │ │ └── plugin-interactive-tools.cjs ├── releases │ └── yarn-3.6.1.cjs └── sdks │ ├── integrations.yml │ └── typescript │ ├── bin │ ├── tsc │ └── tsserver │ ├── lib │ ├── tsc.js │ ├── tsserver.js │ ├── tsserverlibrary.js │ └── typescript.js │ └── package.json ├── .yarnrc.yml ├── 128x128.png ├── Dockerfile ├── LICENSE ├── README.md ├── deploy-commands.js ├── environment.d.ts ├── nodemon.json ├── package.json ├── pnpm-lock.yaml ├── src ├── cider.d.ts ├── commands │ ├── cider │ │ └── branchbuilds.ts │ ├── general │ │ ├── invite.ts │ │ ├── ping.ts │ │ ├── serverinfo.ts │ │ ├── settimezone.ts │ │ └── time.ts │ ├── musickit │ │ ├── artwork.ts │ │ └── info.ts │ └── support │ │ ├── help.ts │ │ ├── restrictions.ts │ │ ├── support.ts │ │ └── verify.ts ├── data │ └── headers.js ├── events │ ├── debug.ts │ ├── guildCreate.ts │ ├── interaction.ts │ └── ready.ts ├── index.ts ├── integrations │ ├── firebase.ts │ ├── musickitAPI.ts │ └── serviceStatus.ts └── interactions │ └── branch.ts └── tsconfig.json /.gitignore: -------------------------------------------------------------------------------- 1 | package-lock.json 2 | node_modules/ 3 | yarn.lock 4 | .history 5 | *.env* 6 | *.env 7 | serviceAccountKey.json 8 | headers.ts 9 | build/ 10 | update.lock 11 | *.sh 12 | .pnp.* 13 | .yarn/* 14 | !.yarn/patches 15 | !.yarn/plugins 16 | !.yarn/releases 17 | !.yarn/sdks 18 | !.yarn/versions -------------------------------------------------------------------------------- /.prettierrc: -------------------------------------------------------------------------------- 1 | { 2 | "tabWidth": 4, 3 | "useTabs": false, 4 | "semi": true, 5 | "singleQuote": true, 6 | "trailingComma": "none", 7 | "bracketSpacing": true, 8 | "arrowParens": "always", 9 | "printWidth": 240, 10 | "endOfLine": "auto" 11 | } 12 | -------------------------------------------------------------------------------- /.vscode/extensions.json: -------------------------------------------------------------------------------- 1 | { 2 | "recommendations": [ 3 | "arcanis.vscode-zipfs" 4 | ] 5 | } 6 | -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "search.exclude": { 3 | "**/.yarn": true, 4 | "**/.pnp.*": true 5 | }, 6 | "typescript.tsdk": ".yarn/sdks/typescript/lib", 7 | "typescript.enablePromptUseWorkspaceTsdk": true 8 | } 9 | -------------------------------------------------------------------------------- /.yarn/sdks/integrations.yml: -------------------------------------------------------------------------------- 1 | # This file is automatically generated by @yarnpkg/sdks. 2 | # Manual changes might be lost! 3 | 4 | integrations: 5 | - vscode 6 | -------------------------------------------------------------------------------- /.yarn/sdks/typescript/bin/tsc: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | 3 | const {existsSync} = require(`fs`); 4 | const {createRequire} = require(`module`); 5 | const {resolve} = require(`path`); 6 | 7 | const relPnpApiPath = "../../../../.pnp.cjs"; 8 | 9 | const absPnpApiPath = resolve(__dirname, relPnpApiPath); 10 | const absRequire = createRequire(absPnpApiPath); 11 | 12 | if (existsSync(absPnpApiPath)) { 13 | if (!process.versions.pnp) { 14 | // Setup the environment to be able to require typescript/bin/tsc 15 | require(absPnpApiPath).setup(); 16 | } 17 | } 18 | 19 | // Defer to the real typescript/bin/tsc your application uses 20 | module.exports = absRequire(`typescript/bin/tsc`); 21 | -------------------------------------------------------------------------------- /.yarn/sdks/typescript/bin/tsserver: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | 3 | const {existsSync} = require(`fs`); 4 | const {createRequire} = require(`module`); 5 | const {resolve} = require(`path`); 6 | 7 | const relPnpApiPath = "../../../../.pnp.cjs"; 8 | 9 | const absPnpApiPath = resolve(__dirname, relPnpApiPath); 10 | const absRequire = createRequire(absPnpApiPath); 11 | 12 | if (existsSync(absPnpApiPath)) { 13 | if (!process.versions.pnp) { 14 | // Setup the environment to be able to require typescript/bin/tsserver 15 | require(absPnpApiPath).setup(); 16 | } 17 | } 18 | 19 | // Defer to the real typescript/bin/tsserver your application uses 20 | module.exports = absRequire(`typescript/bin/tsserver`); 21 | -------------------------------------------------------------------------------- /.yarn/sdks/typescript/lib/tsc.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | 3 | const {existsSync} = require(`fs`); 4 | const {createRequire} = require(`module`); 5 | const {resolve} = require(`path`); 6 | 7 | const relPnpApiPath = "../../../../.pnp.cjs"; 8 | 9 | const absPnpApiPath = resolve(__dirname, relPnpApiPath); 10 | const absRequire = createRequire(absPnpApiPath); 11 | 12 | if (existsSync(absPnpApiPath)) { 13 | if (!process.versions.pnp) { 14 | // Setup the environment to be able to require typescript/lib/tsc.js 15 | require(absPnpApiPath).setup(); 16 | } 17 | } 18 | 19 | // Defer to the real typescript/lib/tsc.js your application uses 20 | module.exports = absRequire(`typescript/lib/tsc.js`); 21 | -------------------------------------------------------------------------------- /.yarn/sdks/typescript/lib/tsserver.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | 3 | const {existsSync} = require(`fs`); 4 | const {createRequire} = require(`module`); 5 | const {resolve} = require(`path`); 6 | 7 | const relPnpApiPath = "../../../../.pnp.cjs"; 8 | 9 | const absPnpApiPath = resolve(__dirname, relPnpApiPath); 10 | const absRequire = createRequire(absPnpApiPath); 11 | 12 | const moduleWrapper = tsserver => { 13 | if (!process.versions.pnp) { 14 | return tsserver; 15 | } 16 | 17 | const {isAbsolute} = require(`path`); 18 | const pnpApi = require(`pnpapi`); 19 | 20 | const isVirtual = str => str.match(/\/(\$\$virtual|__virtual__)\//); 21 | const isPortal = str => str.startsWith("portal:/"); 22 | const normalize = str => str.replace(/\\/g, `/`).replace(/^\/?/, `/`); 23 | 24 | const dependencyTreeRoots = new Set(pnpApi.getDependencyTreeRoots().map(locator => { 25 | return `${locator.name}@${locator.reference}`; 26 | })); 27 | 28 | // VSCode sends the zip paths to TS using the "zip://" prefix, that TS 29 | // doesn't understand. This layer makes sure to remove the protocol 30 | // before forwarding it to TS, and to add it back on all returned paths. 31 | 32 | function toEditorPath(str) { 33 | // We add the `zip:` prefix to both `.zip/` paths and virtual paths 34 | if (isAbsolute(str) && !str.match(/^\^?(zip:|\/zip\/)/) && (str.match(/\.zip\//) || isVirtual(str))) { 35 | // We also take the opportunity to turn virtual paths into physical ones; 36 | // this makes it much easier to work with workspaces that list peer 37 | // dependencies, since otherwise Ctrl+Click would bring us to the virtual 38 | // file instances instead of the real ones. 39 | // 40 | // We only do this to modules owned by the the dependency tree roots. 41 | // This avoids breaking the resolution when jumping inside a vendor 42 | // with peer dep (otherwise jumping into react-dom would show resolution 43 | // errors on react). 44 | // 45 | const resolved = isVirtual(str) ? pnpApi.resolveVirtual(str) : str; 46 | if (resolved) { 47 | const locator = pnpApi.findPackageLocator(resolved); 48 | if (locator && (dependencyTreeRoots.has(`${locator.name}@${locator.reference}`) || isPortal(locator.reference))) { 49 | str = resolved; 50 | } 51 | } 52 | 53 | str = normalize(str); 54 | 55 | if (str.match(/\.zip\//)) { 56 | switch (hostInfo) { 57 | // Absolute VSCode `Uri.fsPath`s need to start with a slash. 58 | // VSCode only adds it automatically for supported schemes, 59 | // so we have to do it manually for the `zip` scheme. 60 | // The path needs to start with a caret otherwise VSCode doesn't handle the protocol 61 | // 62 | // Ref: https://github.com/microsoft/vscode/issues/105014#issuecomment-686760910 63 | // 64 | // 2021-10-08: VSCode changed the format in 1.61. 65 | // Before | ^zip:/c:/foo/bar.zip/package.json 66 | // After | ^/zip//c:/foo/bar.zip/package.json 67 | // 68 | // 2022-04-06: VSCode changed the format in 1.66. 69 | // Before | ^/zip//c:/foo/bar.zip/package.json 70 | // After | ^/zip/c:/foo/bar.zip/package.json 71 | // 72 | // 2022-05-06: VSCode changed the format in 1.68 73 | // Before | ^/zip/c:/foo/bar.zip/package.json 74 | // After | ^/zip//c:/foo/bar.zip/package.json 75 | // 76 | case `vscode <1.61`: { 77 | str = `^zip:${str}`; 78 | } break; 79 | 80 | case `vscode <1.66`: { 81 | str = `^/zip/${str}`; 82 | } break; 83 | 84 | case `vscode <1.68`: { 85 | str = `^/zip${str}`; 86 | } break; 87 | 88 | case `vscode`: { 89 | str = `^/zip/${str}`; 90 | } break; 91 | 92 | // To make "go to definition" work, 93 | // We have to resolve the actual file system path from virtual path 94 | // and convert scheme to supported by [vim-rzip](https://github.com/lbrayner/vim-rzip) 95 | case `coc-nvim`: { 96 | str = normalize(resolved).replace(/\.zip\//, `.zip::`); 97 | str = resolve(`zipfile:${str}`); 98 | } break; 99 | 100 | // Support neovim native LSP and [typescript-language-server](https://github.com/theia-ide/typescript-language-server) 101 | // We have to resolve the actual file system path from virtual path, 102 | // everything else is up to neovim 103 | case `neovim`: { 104 | str = normalize(resolved).replace(/\.zip\//, `.zip::`); 105 | str = `zipfile://${str}`; 106 | } break; 107 | 108 | default: { 109 | str = `zip:${str}`; 110 | } break; 111 | } 112 | } else { 113 | str = str.replace(/^\/?/, process.platform === `win32` ? `` : `/`); 114 | } 115 | } 116 | 117 | return str; 118 | } 119 | 120 | function fromEditorPath(str) { 121 | switch (hostInfo) { 122 | case `coc-nvim`: { 123 | str = str.replace(/\.zip::/, `.zip/`); 124 | // The path for coc-nvim is in format of //zipfile://.yarn/... 125 | // So in order to convert it back, we use .* to match all the thing 126 | // before `zipfile:` 127 | return process.platform === `win32` 128 | ? str.replace(/^.*zipfile:\//, ``) 129 | : str.replace(/^.*zipfile:/, ``); 130 | } break; 131 | 132 | case `neovim`: { 133 | str = str.replace(/\.zip::/, `.zip/`); 134 | // The path for neovim is in format of zipfile:////.yarn/... 135 | return str.replace(/^zipfile:\/\//, ``); 136 | } break; 137 | 138 | case `vscode`: 139 | default: { 140 | return str.replace(/^\^?(zip:|\/zip(\/ts-nul-authority)?)\/+/, process.platform === `win32` ? `` : `/`) 141 | } break; 142 | } 143 | } 144 | 145 | // Force enable 'allowLocalPluginLoads' 146 | // TypeScript tries to resolve plugins using a path relative to itself 147 | // which doesn't work when using the global cache 148 | // https://github.com/microsoft/TypeScript/blob/1b57a0395e0bff191581c9606aab92832001de62/src/server/project.ts#L2238 149 | // VSCode doesn't want to enable 'allowLocalPluginLoads' due to security concerns but 150 | // TypeScript already does local loads and if this code is running the user trusts the workspace 151 | // https://github.com/microsoft/vscode/issues/45856 152 | const ConfiguredProject = tsserver.server.ConfiguredProject; 153 | const {enablePluginsWithOptions: originalEnablePluginsWithOptions} = ConfiguredProject.prototype; 154 | ConfiguredProject.prototype.enablePluginsWithOptions = function() { 155 | this.projectService.allowLocalPluginLoads = true; 156 | return originalEnablePluginsWithOptions.apply(this, arguments); 157 | }; 158 | 159 | // And here is the point where we hijack the VSCode <-> TS communications 160 | // by adding ourselves in the middle. We locate everything that looks 161 | // like an absolute path of ours and normalize it. 162 | 163 | const Session = tsserver.server.Session; 164 | const {onMessage: originalOnMessage, send: originalSend} = Session.prototype; 165 | let hostInfo = `unknown`; 166 | 167 | Object.assign(Session.prototype, { 168 | onMessage(/** @type {string | object} */ message) { 169 | const isStringMessage = typeof message === 'string'; 170 | const parsedMessage = isStringMessage ? JSON.parse(message) : message; 171 | 172 | if ( 173 | parsedMessage != null && 174 | typeof parsedMessage === `object` && 175 | parsedMessage.arguments && 176 | typeof parsedMessage.arguments.hostInfo === `string` 177 | ) { 178 | hostInfo = parsedMessage.arguments.hostInfo; 179 | if (hostInfo === `vscode` && process.env.VSCODE_IPC_HOOK) { 180 | const [, major, minor] = (process.env.VSCODE_IPC_HOOK.match( 181 | // The RegExp from https://semver.org/ but without the caret at the start 182 | /(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$/ 183 | ) ?? []).map(Number) 184 | 185 | if (major === 1) { 186 | if (minor < 61) { 187 | hostInfo += ` <1.61`; 188 | } else if (minor < 66) { 189 | hostInfo += ` <1.66`; 190 | } else if (minor < 68) { 191 | hostInfo += ` <1.68`; 192 | } 193 | } 194 | } 195 | } 196 | 197 | const processedMessageJSON = JSON.stringify(parsedMessage, (key, value) => { 198 | return typeof value === 'string' ? fromEditorPath(value) : value; 199 | }); 200 | 201 | return originalOnMessage.call( 202 | this, 203 | isStringMessage ? processedMessageJSON : JSON.parse(processedMessageJSON) 204 | ); 205 | }, 206 | 207 | send(/** @type {any} */ msg) { 208 | return originalSend.call(this, JSON.parse(JSON.stringify(msg, (key, value) => { 209 | return typeof value === `string` ? toEditorPath(value) : value; 210 | }))); 211 | } 212 | }); 213 | 214 | return tsserver; 215 | }; 216 | 217 | if (existsSync(absPnpApiPath)) { 218 | if (!process.versions.pnp) { 219 | // Setup the environment to be able to require typescript/lib/tsserver.js 220 | require(absPnpApiPath).setup(); 221 | } 222 | } 223 | 224 | // Defer to the real typescript/lib/tsserver.js your application uses 225 | module.exports = moduleWrapper(absRequire(`typescript/lib/tsserver.js`)); 226 | -------------------------------------------------------------------------------- /.yarn/sdks/typescript/lib/tsserverlibrary.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | 3 | const {existsSync} = require(`fs`); 4 | const {createRequire} = require(`module`); 5 | const {resolve} = require(`path`); 6 | 7 | const relPnpApiPath = "../../../../.pnp.cjs"; 8 | 9 | const absPnpApiPath = resolve(__dirname, relPnpApiPath); 10 | const absRequire = createRequire(absPnpApiPath); 11 | 12 | const moduleWrapper = tsserver => { 13 | if (!process.versions.pnp) { 14 | return tsserver; 15 | } 16 | 17 | const {isAbsolute} = require(`path`); 18 | const pnpApi = require(`pnpapi`); 19 | 20 | const isVirtual = str => str.match(/\/(\$\$virtual|__virtual__)\//); 21 | const isPortal = str => str.startsWith("portal:/"); 22 | const normalize = str => str.replace(/\\/g, `/`).replace(/^\/?/, `/`); 23 | 24 | const dependencyTreeRoots = new Set(pnpApi.getDependencyTreeRoots().map(locator => { 25 | return `${locator.name}@${locator.reference}`; 26 | })); 27 | 28 | // VSCode sends the zip paths to TS using the "zip://" prefix, that TS 29 | // doesn't understand. This layer makes sure to remove the protocol 30 | // before forwarding it to TS, and to add it back on all returned paths. 31 | 32 | function toEditorPath(str) { 33 | // We add the `zip:` prefix to both `.zip/` paths and virtual paths 34 | if (isAbsolute(str) && !str.match(/^\^?(zip:|\/zip\/)/) && (str.match(/\.zip\//) || isVirtual(str))) { 35 | // We also take the opportunity to turn virtual paths into physical ones; 36 | // this makes it much easier to work with workspaces that list peer 37 | // dependencies, since otherwise Ctrl+Click would bring us to the virtual 38 | // file instances instead of the real ones. 39 | // 40 | // We only do this to modules owned by the the dependency tree roots. 41 | // This avoids breaking the resolution when jumping inside a vendor 42 | // with peer dep (otherwise jumping into react-dom would show resolution 43 | // errors on react). 44 | // 45 | const resolved = isVirtual(str) ? pnpApi.resolveVirtual(str) : str; 46 | if (resolved) { 47 | const locator = pnpApi.findPackageLocator(resolved); 48 | if (locator && (dependencyTreeRoots.has(`${locator.name}@${locator.reference}`) || isPortal(locator.reference))) { 49 | str = resolved; 50 | } 51 | } 52 | 53 | str = normalize(str); 54 | 55 | if (str.match(/\.zip\//)) { 56 | switch (hostInfo) { 57 | // Absolute VSCode `Uri.fsPath`s need to start with a slash. 58 | // VSCode only adds it automatically for supported schemes, 59 | // so we have to do it manually for the `zip` scheme. 60 | // The path needs to start with a caret otherwise VSCode doesn't handle the protocol 61 | // 62 | // Ref: https://github.com/microsoft/vscode/issues/105014#issuecomment-686760910 63 | // 64 | // 2021-10-08: VSCode changed the format in 1.61. 65 | // Before | ^zip:/c:/foo/bar.zip/package.json 66 | // After | ^/zip//c:/foo/bar.zip/package.json 67 | // 68 | // 2022-04-06: VSCode changed the format in 1.66. 69 | // Before | ^/zip//c:/foo/bar.zip/package.json 70 | // After | ^/zip/c:/foo/bar.zip/package.json 71 | // 72 | // 2022-05-06: VSCode changed the format in 1.68 73 | // Before | ^/zip/c:/foo/bar.zip/package.json 74 | // After | ^/zip//c:/foo/bar.zip/package.json 75 | // 76 | case `vscode <1.61`: { 77 | str = `^zip:${str}`; 78 | } break; 79 | 80 | case `vscode <1.66`: { 81 | str = `^/zip/${str}`; 82 | } break; 83 | 84 | case `vscode <1.68`: { 85 | str = `^/zip${str}`; 86 | } break; 87 | 88 | case `vscode`: { 89 | str = `^/zip/${str}`; 90 | } break; 91 | 92 | // To make "go to definition" work, 93 | // We have to resolve the actual file system path from virtual path 94 | // and convert scheme to supported by [vim-rzip](https://github.com/lbrayner/vim-rzip) 95 | case `coc-nvim`: { 96 | str = normalize(resolved).replace(/\.zip\//, `.zip::`); 97 | str = resolve(`zipfile:${str}`); 98 | } break; 99 | 100 | // Support neovim native LSP and [typescript-language-server](https://github.com/theia-ide/typescript-language-server) 101 | // We have to resolve the actual file system path from virtual path, 102 | // everything else is up to neovim 103 | case `neovim`: { 104 | str = normalize(resolved).replace(/\.zip\//, `.zip::`); 105 | str = `zipfile://${str}`; 106 | } break; 107 | 108 | default: { 109 | str = `zip:${str}`; 110 | } break; 111 | } 112 | } else { 113 | str = str.replace(/^\/?/, process.platform === `win32` ? `` : `/`); 114 | } 115 | } 116 | 117 | return str; 118 | } 119 | 120 | function fromEditorPath(str) { 121 | switch (hostInfo) { 122 | case `coc-nvim`: { 123 | str = str.replace(/\.zip::/, `.zip/`); 124 | // The path for coc-nvim is in format of //zipfile://.yarn/... 125 | // So in order to convert it back, we use .* to match all the thing 126 | // before `zipfile:` 127 | return process.platform === `win32` 128 | ? str.replace(/^.*zipfile:\//, ``) 129 | : str.replace(/^.*zipfile:/, ``); 130 | } break; 131 | 132 | case `neovim`: { 133 | str = str.replace(/\.zip::/, `.zip/`); 134 | // The path for neovim is in format of zipfile:////.yarn/... 135 | return str.replace(/^zipfile:\/\//, ``); 136 | } break; 137 | 138 | case `vscode`: 139 | default: { 140 | return str.replace(/^\^?(zip:|\/zip(\/ts-nul-authority)?)\/+/, process.platform === `win32` ? `` : `/`) 141 | } break; 142 | } 143 | } 144 | 145 | // Force enable 'allowLocalPluginLoads' 146 | // TypeScript tries to resolve plugins using a path relative to itself 147 | // which doesn't work when using the global cache 148 | // https://github.com/microsoft/TypeScript/blob/1b57a0395e0bff191581c9606aab92832001de62/src/server/project.ts#L2238 149 | // VSCode doesn't want to enable 'allowLocalPluginLoads' due to security concerns but 150 | // TypeScript already does local loads and if this code is running the user trusts the workspace 151 | // https://github.com/microsoft/vscode/issues/45856 152 | const ConfiguredProject = tsserver.server.ConfiguredProject; 153 | const {enablePluginsWithOptions: originalEnablePluginsWithOptions} = ConfiguredProject.prototype; 154 | ConfiguredProject.prototype.enablePluginsWithOptions = function() { 155 | this.projectService.allowLocalPluginLoads = true; 156 | return originalEnablePluginsWithOptions.apply(this, arguments); 157 | }; 158 | 159 | // And here is the point where we hijack the VSCode <-> TS communications 160 | // by adding ourselves in the middle. We locate everything that looks 161 | // like an absolute path of ours and normalize it. 162 | 163 | const Session = tsserver.server.Session; 164 | const {onMessage: originalOnMessage, send: originalSend} = Session.prototype; 165 | let hostInfo = `unknown`; 166 | 167 | Object.assign(Session.prototype, { 168 | onMessage(/** @type {string | object} */ message) { 169 | const isStringMessage = typeof message === 'string'; 170 | const parsedMessage = isStringMessage ? JSON.parse(message) : message; 171 | 172 | if ( 173 | parsedMessage != null && 174 | typeof parsedMessage === `object` && 175 | parsedMessage.arguments && 176 | typeof parsedMessage.arguments.hostInfo === `string` 177 | ) { 178 | hostInfo = parsedMessage.arguments.hostInfo; 179 | if (hostInfo === `vscode` && process.env.VSCODE_IPC_HOOK) { 180 | const [, major, minor] = (process.env.VSCODE_IPC_HOOK.match( 181 | // The RegExp from https://semver.org/ but without the caret at the start 182 | /(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$/ 183 | ) ?? []).map(Number) 184 | 185 | if (major === 1) { 186 | if (minor < 61) { 187 | hostInfo += ` <1.61`; 188 | } else if (minor < 66) { 189 | hostInfo += ` <1.66`; 190 | } else if (minor < 68) { 191 | hostInfo += ` <1.68`; 192 | } 193 | } 194 | } 195 | } 196 | 197 | const processedMessageJSON = JSON.stringify(parsedMessage, (key, value) => { 198 | return typeof value === 'string' ? fromEditorPath(value) : value; 199 | }); 200 | 201 | return originalOnMessage.call( 202 | this, 203 | isStringMessage ? processedMessageJSON : JSON.parse(processedMessageJSON) 204 | ); 205 | }, 206 | 207 | send(/** @type {any} */ msg) { 208 | return originalSend.call(this, JSON.parse(JSON.stringify(msg, (key, value) => { 209 | return typeof value === `string` ? toEditorPath(value) : value; 210 | }))); 211 | } 212 | }); 213 | 214 | return tsserver; 215 | }; 216 | 217 | if (existsSync(absPnpApiPath)) { 218 | if (!process.versions.pnp) { 219 | // Setup the environment to be able to require typescript/lib/tsserverlibrary.js 220 | require(absPnpApiPath).setup(); 221 | } 222 | } 223 | 224 | // Defer to the real typescript/lib/tsserverlibrary.js your application uses 225 | module.exports = moduleWrapper(absRequire(`typescript/lib/tsserverlibrary.js`)); 226 | -------------------------------------------------------------------------------- /.yarn/sdks/typescript/lib/typescript.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | 3 | const {existsSync} = require(`fs`); 4 | const {createRequire} = require(`module`); 5 | const {resolve} = require(`path`); 6 | 7 | const relPnpApiPath = "../../../../.pnp.cjs"; 8 | 9 | const absPnpApiPath = resolve(__dirname, relPnpApiPath); 10 | const absRequire = createRequire(absPnpApiPath); 11 | 12 | if (existsSync(absPnpApiPath)) { 13 | if (!process.versions.pnp) { 14 | // Setup the environment to be able to require typescript/lib/typescript.js 15 | require(absPnpApiPath).setup(); 16 | } 17 | } 18 | 19 | // Defer to the real typescript/lib/typescript.js your application uses 20 | module.exports = absRequire(`typescript/lib/typescript.js`); 21 | -------------------------------------------------------------------------------- /.yarn/sdks/typescript/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "typescript", 3 | "version": "5.1.6-sdk", 4 | "main": "./lib/typescript.js", 5 | "type": "commonjs" 6 | } 7 | -------------------------------------------------------------------------------- /.yarnrc.yml: -------------------------------------------------------------------------------- 1 | plugins: 2 | - path: .yarn/plugins/@yarnpkg/plugin-interactive-tools.cjs 3 | spec: "@yarnpkg/plugin-interactive-tools" 4 | 5 | yarnPath: .yarn/releases/yarn-3.6.1.cjs 6 | -------------------------------------------------------------------------------- /128x128.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ciderapp/Cider-Bot/2f7d2c3e3cbe1624c29ab13edeac1349fb5b6a5c/128x128.png -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | # Specify base image 2 | FROM node:18 3 | 4 | # Install yarn 5 | RUN corepack prepare yarn@stable --activate 6 | 7 | # Install Python, git and ffmpeg 8 | RUN apt-get update && apt-get install -y git python3 python3-pip ffmpeg 9 | 10 | # Set working directory 11 | WORKDIR /app 12 | 13 | RUN git config --global --add safe.directory /app 14 | 15 | # Pull for updates every time the container is started 16 | ENTRYPOINT sh -c "if [ -d .git ]; then git reset --hard && git pull; else git clone https://github.com/ciderapp/Cider-Bot.git .; fi && yarn install && yarn run build && yarn run start || true" 17 | 18 | # Don't dodge me next time. 19 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | 635 | Copyright (C) 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | Copyright (C) 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . 675 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## Cider Bot 2 | Cider Bot is a Discord bot that enhances your music listening experience with Cider, a cross-platform Apple Music client built on Vue.js and Electron. 3 | ### Features 4 | - Control your music playback from Discord using slash commands 5 | - Get download links for Cider and Cider 2 releases 6 | - Get recommendations and lyrics for songs from Apple Music 7 | - Join the Cider community and get support, feedback, and updates 8 | ### License 9 | This project is licensed under the GNU General Public License v3.0 - see the [LICENSE](https://github.com/ciderapp/Cider-Bot/blob/main/LICENSE) file for details. 10 | 11 | ### Support 12 | If you need help with using or setting up Cider Bot, please join our [Discord server](https://discord.gg/applemusic) and ask in the [#support channel](https://canary.discord.com/channels/843954443845238864/996168362826674246). -------------------------------------------------------------------------------- /deploy-commands.js: -------------------------------------------------------------------------------- 1 | import 'dotenv/config'; 2 | import { readdirSync } from 'fs'; 3 | import { REST, Routes } from 'discord.js'; 4 | 5 | const commands = []; 6 | 7 | const commandFolders = readdirSync('./src/commands/'); 8 | for (const folder of commandFolders) { 9 | const commandFiles = readdirSync(`./build/commands/${folder}`).filter((file) => file.endsWith('.js')); 10 | for (const file of commandFiles) { 11 | const { command } = await import(`./build/commands/${folder}/${file}`); 12 | commands.push(command.data); 13 | } 14 | } 15 | 16 | const rest = new REST({ version: '10' }).setToken(process.env.DISCORD_TOKEN); 17 | try { 18 | console.log('Started refreshing application (/) commands.'); 19 | await rest.put(Routes.applicationCommands(process.env.DISCORD_ID), { body: commands }); 20 | console.log('Successfully reloaded application (/) commands.\n' + commands.map((c) => c.name).join(', ')); 21 | } catch (error) { 22 | console.error(error); 23 | } 24 | -------------------------------------------------------------------------------- /environment.d.ts: -------------------------------------------------------------------------------- 1 | declare global { 2 | namespace NodeJS { 3 | interface ProcessEnv { 4 | NODE_ENV: "development" | "production"; 5 | DISCORD_TOKEN: string; 6 | DISCORD_ID: string; 7 | DP_FORCE_YTDL_MODE: "play-dl" | "ytdl-core"; 8 | } 9 | } 10 | } 11 | 12 | export {}; 13 | -------------------------------------------------------------------------------- /nodemon.json: -------------------------------------------------------------------------------- 1 | { 2 | "restartable": "rs", 3 | "ignore": ["node_modules/"], 4 | "watch": ["src/"], 5 | "execMap": { 6 | "ts": "ts-node-esm --files" 7 | }, 8 | "env": { 9 | "NODE_ENV": "development", 10 | "CONSOLA_LEVEL": 5 11 | }, 12 | "ext": "js,json,ts" 13 | } -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "cider-bot", 3 | "version": "2.5.4", 4 | "description": "Official Discord Bot for Cider", 5 | "main": "build/index.js", 6 | "type": "module", 7 | "scripts": { 8 | "build": "tsc && node deploy-commands.js", 9 | "start": "node .", 10 | "dev": "nodemon --config nodemon.json src/index.ts" 11 | }, 12 | "keywords": [], 13 | "author": "", 14 | "license": "ISC", 15 | "dependencies": { 16 | "@sentry/node": "^7.73.0", 17 | "consola": "^3.2.3", 18 | "discord.js": "^14.13.0", 19 | "firebase-admin": "^11.11.0", 20 | "m3u8-stream-list": "^1.1.0" 21 | }, 22 | "devDependencies": { 23 | "@types/node": "^20.8.3", 24 | "dotenv": "^16.3.1", 25 | "nodemon": "^3.0.1", 26 | "ts-node": "^10.9.1", 27 | "typescript": "^5.2.2" 28 | }, 29 | "packageManager": "yarn@3.6.1" 30 | } 31 | -------------------------------------------------------------------------------- /src/cider.d.ts: -------------------------------------------------------------------------------- 1 | declare global { 2 | const enum CiderGuildRoles { 3 | donator = "932811694751768656", 4 | kofi = "905457688211783690", 5 | oc = "923351772532199445", 6 | github = "990362567241236490", 7 | alpha = "1050089837648162886", 8 | leadDev = "928845681517535323", 9 | dev = "848363050205446165", 10 | collective = "1039673169373569025", 11 | listening = "932784788115427348", 12 | ciderUser = "932816700305469510", 13 | moderator = "875082121427955802", 14 | } 15 | const enum CiderGuildChannels { 16 | botLog = "972138457893851176", 17 | openAI = "1049063562024333383", 18 | starBoard = "985447153331740682", 19 | prereleases = "905459703092490340", 20 | marinChain = "952324765807439883", 21 | appleServices = "1051166161611538462", 22 | donatorChat = "905459873079259196", 23 | alphaPrereleases = "1050090981808156672", 24 | hypesquadGeneral = "1050090945942671520", 25 | saki = "1068226779283722282", 26 | } 27 | const enum CiderServers { 28 | main = "843954443845238864", 29 | afterDark = "940857077604167701", 30 | testServer = "585180490202349578" 31 | } 32 | } 33 | export {}; -------------------------------------------------------------------------------- /src/commands/cider/branchbuilds.ts: -------------------------------------------------------------------------------- 1 | import { ActionRowBuilder, ChatInputCommandInteraction, GuildMemberRoleManager, SlashCommandBuilder, StringSelectMenuBuilder } from 'discord.js'; 2 | 3 | export const command = { 4 | data: new SlashCommandBuilder() 5 | .setName('branchbuilds') 6 | .setDescription('Gives you download links for the latest builds of a specified branch') 7 | .addBooleanOption(option => option.setName('show') 8 | .setDescription('Show to everyone!') 9 | .setRequired(false) 10 | ) 11 | .addUserOption(option => option.setName('ping') 12 | .setDescription('User to respond to (for use by Dev Team and Moderators only)') 13 | .setRequired(false) 14 | ), 15 | category: 'General', 16 | async execute(interaction: ChatInputCommandInteraction) { 17 | let ping = interaction.options.getUser('ping') || ""; 18 | let show = interaction.options.getBoolean('show') || false 19 | if (ping != "") { ping = ping.toString() } 20 | let memberRoles = (interaction.member!.roles as GuildMemberRoleManager).cache 21 | let components = new StringSelectMenuBuilder() 22 | .setCustomId('branch') 23 | .setPlaceholder('Select a branch') 24 | .addOptions([ 25 | { 26 | label: 'Cider Classic (main)', 27 | description: 'Cider 1.x compiled from main branch', 28 | value: `main|${show}|${ping}`, 29 | }, 30 | { 31 | label: 'Cider Classic (stable)', 32 | description: 'Cider 1.x compiled from stable branch (synced w/ MSFT store)', 33 | value: `stable|${show}|${ping}`, 34 | } 35 | ]) 36 | if(process.env.NODE_ENV == "development" || memberRoles.has(CiderGuildRoles.donator)) components.addOptions([{ label: 'Cider 2 (Beta) - Electron' , description: 'Cider 2.x compiled with Electron', value: `cider2electron|${show}|${ping}`}]) 37 | if(process.env.NODE_ENV == "development" || memberRoles.has(CiderGuildRoles.alpha)) components.addOptions([{ label: 'Cider 2 (Beta) - UWP' , description: 'Cider 2.x compiled with UWP', value: `cider2uwp|${show}|${ping}`}]) 38 | let branchMenu = new ActionRowBuilder().addComponents(components) 39 | if (ping != "" && memberRoles.has(CiderGuildRoles.dev) || memberRoles.has(CiderGuildRoles.moderator)) { //@ts-ignore 40 | await interaction.reply({ content: `${ping} Choose your branch:`, components: [branchMenu] }); 41 | } 42 | else { //@ts-ignore 43 | await interaction.reply({ content: `Choose your branch:`, ephemeral: !show, components: [branchMenu] }); 44 | if (ping != "") { 45 | await interaction.followUp({ content: `You do not have the permission to ping users.`, ephemeral: true, components: [] }) 46 | } 47 | } 48 | } 49 | } -------------------------------------------------------------------------------- /src/commands/general/invite.ts: -------------------------------------------------------------------------------- 1 | import { ActionRowBuilder, ButtonBuilder, ButtonStyle, ChatInputCommandInteraction, SlashCommandBuilder } from 'discord.js'; 2 | 3 | export const command = { 4 | data: new SlashCommandBuilder() 5 | .setName("invite") 6 | .setDescription("Invite Cider to your server!"), 7 | category: 'General', 8 | async execute(interaction: ChatInputCommandInteraction) { 9 | await interaction.reply({ components: [ //@ts-ignore 10 | new ActionRowBuilder() 11 | .addComponents( 12 | new ButtonBuilder() 13 | .setLabel('Invite Me') 14 | .setStyle(ButtonStyle.Link) 15 | .setURL('https://canary.discord.com/api/oauth2/authorize?client_id=921475709694771252&permissions=1359660576246&scope=applications.commands%20bot') 16 | ) 17 | ]}) 18 | } 19 | } -------------------------------------------------------------------------------- /src/commands/general/ping.ts: -------------------------------------------------------------------------------- 1 | import { ChatInputCommandInteraction, SlashCommandBuilder } from 'discord.js'; 2 | export const command = { 3 | data: new SlashCommandBuilder().setName('ping').setDescription('Get the bots ping'), 4 | category: 'General', 5 | async execute(interaction: ChatInputCommandInteraction) { 6 | let show = interaction.options.getBoolean('show') || false; 7 | await interaction.reply({ 8 | content: `:heartbeat: | Heartbeat - ${interaction.client.ws.ping}ms\n:ping_pong: | Latency - ${Date.now() - interaction.createdTimestamp}ms`, 9 | ephemeral: true 10 | }); 11 | } 12 | }; 13 | -------------------------------------------------------------------------------- /src/commands/general/serverinfo.ts: -------------------------------------------------------------------------------- 1 | import { ActionRowBuilder, ActionRowComponentData, ActionRowData, ButtonBuilder, ButtonStyle, ChatInputCommandInteraction, EmbedBuilder, SlashCommandBuilder } from 'discord.js'; 2 | import consola from 'consola'; 3 | export const command = { 4 | data: new SlashCommandBuilder().setName("serverinfo").setDescription("Get info on the current server") 5 | .addSubcommand(subcommand => subcommand 6 | .setName('bans') 7 | .setDescription('Bans a user from the server')), 8 | category: 'General', 9 | async execute(interaction: ChatInputCommandInteraction) { 10 | if (interaction.options.getSubcommand() === 'bans') { 11 | let components : ActionRowData[] = []; 12 | let bans = await interaction.guild!.bans.fetch(); 13 | let bansArray = [...bans.values()] 14 | let bansEmbed = new EmbedBuilder() 15 | .setColor('Red') 16 | .setTitle(`Bans on **${interaction.guild!.name}**`) 17 | .setThumbnail(interaction.guild!.iconURL()) 18 | .setDescription(`${bansArray.length > 0 ? bansArray.slice(0, 20).map((ban, i) => `${i + 1}.) **${ban.user.tag}**(||${ban.user.id}||) - ${ban.reason || 'no reason provided'}`).join('\n\n') : 'No bans'}`) 19 | .setFooter({ text: `Total Ban Count: ${bans.size}` }) 20 | if(bansArray.length > 20) { //@ts-ignore 21 | components = [new ActionRowBuilder().addComponents( 22 | new ButtonBuilder().setEmoji('⏪').setStyle(ButtonStyle.Secondary).setCustomId(`bansPages|${Math.floor(bansArray.length / 20 + 1)}`), 23 | new ButtonBuilder().setEmoji('⏩').setStyle(ButtonStyle.Secondary).setCustomId(`bansPages|2`) 24 | )] 25 | } 26 | consola.info(bansArray) 27 | // consola.info("Bans:", bans); 28 | await interaction.reply({ 29 | embeds: [bansEmbed], //@ts-ignore 30 | components 31 | }); 32 | } 33 | } 34 | } -------------------------------------------------------------------------------- /src/commands/general/settimezone.ts: -------------------------------------------------------------------------------- 1 | import { ActionRowBuilder, AutocompleteInteraction, ButtonBuilder, ButtonStyle, ChatInputCommandInteraction, SlashCommandBuilder } from 'discord.js'; 2 | import { firebase } from '../../integrations/firebase.js'; 3 | export const command = { 4 | data: new SlashCommandBuilder() 5 | .setName('settimezone') 6 | .setDescription('Set your local timezone') 7 | .addStringOption((option) => option.setName('timezone').setDescription('Provide your local timezone').setAutocomplete(true).setRequired(true)), 8 | category: 'General', 9 | async autocomplete(interaction: AutocompleteInteraction) { 10 | let query = interaction.options.getFocused(); 11 | return interaction.respond( 12 | // @ts-ignore 13 | Intl.supportedValuesOf('timeZone') 14 | .filter((timezone : string) => timezone.toLowerCase().includes(query.toLowerCase())) 15 | .slice(0, 20) 16 | .map((timezone : string) => { 17 | return { 18 | name: timezone, 19 | value: timezone 20 | }; 21 | }) 22 | ); 23 | }, 24 | async execute(interaction: ChatInputCommandInteraction) { 25 | const timezone = interaction.options.getString('timezone'); 26 | 27 | function isValidTimeZone(tz: string | null) { 28 | try { 29 | if (!Intl || !Intl.DateTimeFormat().resolvedOptions().timeZone) { 30 | return false; 31 | } 32 | 33 | if (typeof tz !== 'string') { 34 | return false; 35 | } 36 | 37 | Intl.DateTimeFormat(undefined, { timeZone: tz }); 38 | return true; 39 | } catch (error) { 40 | return false; 41 | } 42 | } 43 | 44 | if (isValidTimeZone(timezone) == false) { 45 | interaction.reply({ 46 | content: 'Invalid timezone provided. Refer to the supported timezones.', 47 | components: [ 48 | //@ts-ignore 49 | new ActionRowBuilder().addComponents(new ButtonBuilder().setStyle(ButtonStyle.Link).setURL('https://gist.github.com/diogocapela/12c6617fc87607d11fd62d2a4f42b02a').setLabel('Supported Timezones')) 50 | ], 51 | ephemeral: true 52 | }); 53 | return; 54 | } else { 55 | await firebase.getUserTimezone(interaction.user.id).then(async (returnTimezone) => { 56 | if (!returnTimezone) { 57 | firebase.setUserTimezone(interaction.user.id, timezone as string); 58 | interaction.reply({ content: `Timezone set to ${timezone}`, ephemeral: true }); 59 | } else { 60 | firebase.setUserTimezone(interaction.user.id, timezone as string); 61 | interaction.reply({ content: `Timezone updated to ${timezone}`, ephemeral: true }); 62 | } 63 | }); 64 | } 65 | } 66 | }; 67 | -------------------------------------------------------------------------------- /src/commands/general/time.ts: -------------------------------------------------------------------------------- 1 | import { ActionRowBuilder, AutocompleteInteraction, ButtonBuilder, ButtonStyle, ChatInputCommandInteraction, SlashCommandBuilder } from 'discord.js'; 2 | //@ts-ignore 3 | import { firebase } from '../../integrations/firebase.js'; 4 | export const command = { 5 | data: new SlashCommandBuilder() 6 | .setName('time') 7 | .setDescription("Displays user's local time") 8 | .addUserOption((option) => option.setName('user').setDescription('Mention user')), 9 | category: 'General', 10 | async execute(interaction: ChatInputCommandInteraction) { 11 | let user = interaction.options.getUser('user') || interaction.user; 12 | 13 | let timezone = await firebase.getUserTimezone(user.id); 14 | if (!timezone) 15 | return user.id == interaction.user.id 16 | ? await interaction.reply({ content: 'You have not set your timezone yet. Use to set your timezone.', ephemeral: true }) 17 | : await interaction.reply({ content: `${user.tag} has not set their timezone yet.`, ephemeral: true }); 18 | let formatter = new Intl.DateTimeFormat([], { timeZone: timezone, year: 'numeric', month: 'numeric', day: 'numeric', hour: 'numeric', minute: 'numeric', second: 'numeric' }); 19 | await interaction.reply({ content: `The current time for **${user.tag}**'s is: ${formatter.format(new Date())}` }); 20 | } 21 | }; 22 | -------------------------------------------------------------------------------- /src/commands/musickit/artwork.ts: -------------------------------------------------------------------------------- 1 | import { SlashCommandBuilder, resolveColor, ChatInputCommandInteraction } from 'discord.js'; 2 | import { getArtwork } from '../../integrations/musickitAPI.js'; 3 | // @ts-ignore 4 | import m3u8 from 'm3u8-stream-list'; 5 | import consola from 'consola'; 6 | 7 | export const command = { 8 | data: new SlashCommandBuilder() 9 | .setName('artwork') 10 | .setDescription('gives you artwork from apple music, provided the query') 11 | .addStringOption((o) => o.setName('query').setDescription('The song/artist to get the artwork of (works with apple music links and normal queries only)').setRequired(true)) 12 | .addStringOption((o) => o.setName('storefront').setDescription("Override the storefront to search in (defaults to 'us')").setRequired(false)) 13 | .addBooleanOption((o) => o.setName('include-info').setDescription('Include the song/abum/artist info in the embed').setRequired(false)) 14 | .addBooleanOption((o) => o.setName('animated-artwork').setDescription('Include the animated artwork in the embed (if available)').setRequired(false)), 15 | category: 'MusicKit', 16 | execute: async (interaction: ChatInputCommandInteraction) => { 17 | let client = interaction.client; 18 | let amAPIToken = client.amAPIToken; 19 | let query: string | URL = interaction.options.getString('query') || ''; 20 | let storefront = interaction.options.getString('storefront') || 'us'; 21 | let includeInfo = interaction.options.getBoolean('include-info') || false; 22 | let animatedArtwork = interaction.options.getBoolean('animated-artwork') || false; 23 | let failed = false; 24 | if (query && !query.startsWith('https://')) { 25 | let href = new URL(`v1/catalog/${storefront}/search/`, 'https://api.music.apple.com/'); 26 | href.searchParams.set('term', query); 27 | href.searchParams.set('platform', 'web'); 28 | href.searchParams.set('types', 'activities,albums,apple-curators,artists,curators,editorial-items,music-movies,music-videos,playlists,songs,stations,tv-episodes,uploaded-videos,record-labels'); 29 | href.searchParams.set('limit', '1'); 30 | href.searchParams.set('with', 'serverBubbles,lyricHighlights'); 31 | href.searchParams.set('omit[resource]', 'autos'); 32 | query = href.pathname + href.search; 33 | } else if (!query.startsWith('https://music.apple.com/') && !query.startsWith('https://beta.music.apple.com/')) return await interaction.reply({ content: ' We only support apple music links and normal queries', ephemeral: true }); 34 | await interaction.reply({ content: 'Getting artwork from Apple Music' }); 35 | 36 | let res = await getArtwork(amAPIToken, query, animatedArtwork).catch((err) => { 37 | consola.error(err); 38 | failed = true; 39 | if (err.name === 'TypeError') 40 | return interaction.editReply({ 41 | content: '', 42 | embeds: [ 43 | { 44 | color: resolveColor('Red'), 45 | author: { name: `${client.user.username} | Search Error`, icon_url: 'https://cdn.discordapp.com/attachments/912441248298696775/935348933213970442/Cider-Logo.png?width=671&height=671' }, 46 | description: `We cannot find an artwork that matches your query:\n\`${interaction.options.getString('query')}\``, 47 | footer: { text: `requested by ${interaction.user.tag}`, icon_url: interaction.user.displayAvatarURL() } 48 | } 49 | ] 50 | }); 51 | return interaction.editReply({ content: `An error occured while getting the artwork: \`${err}\`` }); 52 | }); 53 | if (animatedArtwork && res.attributes?.editorialVideo) { 54 | await interaction.editReply({ content: 'Converting animated artwork...' }); 55 | if (includeInfo) { 56 | await interaction.editReply({ 57 | content: '', 58 | embeds: [ 59 | { 60 | color: resolveColor(`#${res.attributes.artwork.bgColor}`), 61 | title: res.attributes.name, 62 | description: `${res.attributes.artistName ? `by **${res.attributes.artistName}**` : ''} ${res.attributes.albumName ? `on **${res.attributes.albumName}**` : ''}\nKind: **${res.type.slice(0, -1)}**`, 63 | url: res.attributes.url 64 | } 65 | ] 66 | }); 67 | } 68 | if (res.type === 'artists') res.attributes.editorialVideo.motionDetailSquare = res.attributes.editorialVideo.motionArtistFullscreen16x9; 69 | let playlist: any = await fetch(res.attributes.editorialVideo.motionDetailSquare.video); 70 | playlist = Buffer.from(await playlist.arrayBuffer()); 71 | let videos = m3u8(playlist).filter((v: any) => v.CODECS.includes('avc1')); 72 | if (!includeInfo) await interaction.editReply({ content: videos[videos.length - 1].url.replace('-.m3u8', '-.mp4').replace('.m3u8', '-.mp4') }); 73 | else await interaction.followUp({ content: videos[videos.length - 1].url.replace('-.m3u8', '-.mp4').replace('.m3u8', '-.mp4') }); 74 | } else if (!failed) { 75 | if (animatedArtwork && !res.attributes?.editorialVideo) { 76 | await interaction.followUp({ content: `Sorry ${interaction.user}, We cannot find an animated artwork for your query` }); 77 | } 78 | if (!res) return await interaction.editReply({ content: `No artwork found for \`${query}\`` }); 79 | if (!includeInfo) { 80 | return await interaction.editReply(res.attributes.artwork.url.replace('{w}', res.attributes.artwork.width).replace('{h}', res.attributes.artwork.height)); 81 | } 82 | return await interaction.editReply({ 83 | content: '', 84 | embeds: [ 85 | { 86 | color: resolveColor(`#${res.attributes.artwork.bgColor}`), 87 | title: res.attributes.name, 88 | description: `${res.attributes.artistName ? `by **${res.attributes.artistName}**` : ''} ${res.attributes.albumName ? `on **${res.attributes.albumName}**` : ''}\nKind: **${res.type.slice(0, -1)}**`, 89 | image: { url: res.attributes.artwork.url.replace('{w}', res.attributes.artwork.width).replace('{h}', res.attributes.artwork.height) }, 90 | url: res.attributes.url 91 | } 92 | ] 93 | }); 94 | } 95 | } 96 | }; 97 | -------------------------------------------------------------------------------- /src/commands/musickit/info.ts: -------------------------------------------------------------------------------- 1 | import { SlashCommandBuilder, EmbedBuilder, resolveColor, ChatInputCommandInteraction } from 'discord.js'; 2 | import { getInfo } from '../../integrations/musickitAPI.js'; 3 | import consola from 'consola'; 4 | 5 | export const command = { 6 | data: new SlashCommandBuilder() 7 | .setName('info') 8 | .setDescription('searches apple music for your query and returns the info') 9 | .addStringOption((o) => o.setName('query').setDescription('The song/artist to get the artwork of (works with apple music links and normal queries only)').setRequired(true)) 10 | .addStringOption((o) => o.setName('storefront').setDescription("Override the storefront to search in (defaults to 'us')").setRequired(false)), 11 | category: 'MusicKit', 12 | execute: async (interaction: ChatInputCommandInteraction) => { 13 | let client = interaction.client; 14 | let amAPIToken = client.amAPIToken; 15 | let query: string | URL = interaction.options.getString('query') || ''; 16 | let storefront = interaction.options.getString('storefront') || 'us'; 17 | let failed = false; 18 | 19 | if (query && !query.startsWith('https://')) { 20 | let href = new URL(`v1/catalog/${storefront}/search/`, 'https://api.music.apple.com/'); 21 | href.searchParams.set('term', query); 22 | href.searchParams.set('platform', 'web'); 23 | href.searchParams.set('types', 'activities,albums,apple-curators,artists,curators,editorial-items,music-movies,music-videos,playlists,songs,stations,tv-episodes,uploaded-videos,record-labels'); 24 | href.searchParams.set('limit', '1'); 25 | href.searchParams.set('with', 'serverBubbles,lyricHighlights'); 26 | href.searchParams.set('omit[resource]', 'autos'); 27 | query = href.pathname + href.search; 28 | } else if (!query.startsWith('https://music.apple.com/') && !query.startsWith('https://beta.music.apple.com/')) return await interaction.reply({ content: ' We only support apple music links and normal queries', ephemeral: true }); 29 | await interaction.reply({ content: 'Getting artwork from Apple Music' }); 30 | 31 | let info = await getInfo(amAPIToken, query).catch(async (err) => { 32 | consola.error(err); 33 | failed = true; 34 | if (err.name === 'TypeError') 35 | return interaction.editReply({ 36 | content: '', 37 | embeds: [ 38 | { 39 | color: resolveColor('Red'), 40 | author: { name: `${client.user.username} | Search Error`, icon_url: 'https://cdn.discordapp.com/attachments/912441248298696775/935348933213970442/Cider-Logo.png?width=671&height=671' }, 41 | description: `We cannot find the info that matches your query:\n\`${interaction.options.getString('query')}\``, 42 | footer: { text: `requested by ${interaction.user.tag}`, icon_url: interaction.user.displayAvatarURL() } 43 | } 44 | ] 45 | }); 46 | return interaction.editReply({ content: `An error occured while getting the info: \`${err}\`` }); 47 | }); 48 | if (!info) return await interaction.editReply({ content: 'Failed to get info from Apple Music' }); 49 | let embed = new EmbedBuilder() 50 | .setAuthor({ 51 | name: `${client.user.username} | ${info.type.slice(0, 1).toUpperCase()}${info.type.slice(1, -1)} Info`, 52 | iconURL: interaction.client.user.displayAvatarURL() 53 | }) 54 | .setTitle(info.attributes.name) 55 | .setURL(info.attributes.url) 56 | .setThumbnail(info.attributes.artwork.url.replace('{w}', info.attributes.artwork.width).replace('{h}', info.attributes.artwork.height)) 57 | .setColor(resolveColor(`#${info.attributes.artwork.bgColor}`)) 58 | .setFooter({ text: `requested by ${interaction.user.tag}`, iconURL: interaction.user.displayAvatarURL()}); 59 | if (info.type === 'apple-curators') embed.setDescription(info.attributes.editorialNotes.standard.split('\n')[0]); 60 | else if (info.attributes.editorialNotes) embed.setDescription(info.attributes.editorialNotes.short); 61 | if (info.attributes.artistName) embed.addFields({ name: 'Artist', value: info.attributes.artistName, inline: true }); 62 | if (info.attributes.albumName) embed.addFields({ name: 'Album', value: info.attributes.albumName, inline: true }); 63 | if (info.attributes.genreNames) embed.addFields({ name: 'Genre', value: info.attributes.genreNames.join(', '), inline: true }); 64 | if (info.attributes.releaseDate) embed.addFields({ name: 'Release Date', value: ``, inline: true }); 65 | if (info.attributes.recordLabel) embed.addFields({ name: 'Record Label', value: info.attributes.recordLabel, inline: true }); 66 | if (info.attributes.durationInMillis) embed.addFields({ name: 'Duration', value: msToTime(info.attributes.durationInMillis), inline: true }); 67 | if (info.attributes.isrc) embed.addFields({ name: 'ISRC', value: info.attributes.isrc, inline: true }); 68 | if (info.attributes.audioTraits?.length > 0) embed.addFields({ name: 'Audio Traits', value: info.attributes.audioTraits.join(', '), inline: true }); 69 | if (info.attributes.trackNumber != null) embed.addFields({ name: 'Track Number', value: `${info.attributes.trackNumber}`, inline: true }); 70 | if (info.attributes.lastModifiedDate) embed.addFields({ name: 'Last Modified', value: ``, inline: true }); 71 | if (info.attributes.playlistType) embed.addFields({ name: 'Playlist Type', value: info.attributes.playlistType, inline: true }); 72 | if (info.attributes.curatorName) embed.addFields({ name: 'Curator', value: info.attributes.curatorName, inline: true }); 73 | if (info.attributes.trackCount != null) embed.addFields({ name: 'Tracks', value: `${info.attributes.trackCount}`, inline: true }); 74 | await interaction.editReply({ content: '', embeds: [embed] }); 75 | } 76 | }; 77 | function msToTime(ms: number) { 78 | let secs = Math.floor(ms / 1000); 79 | ms %= 1000; 80 | let mins = Math.floor(secs / 60); 81 | secs %= 60; 82 | return mins + ":" + (secs < 10 ? "0" : "") + secs; 83 | } 84 | -------------------------------------------------------------------------------- /src/commands/support/help.ts: -------------------------------------------------------------------------------- 1 | import { SlashCommandBuilder, EmbedBuilder, StringSelectMenuBuilder, ActionRowBuilder, ChatInputCommandInteraction } from 'discord.js'; 2 | 3 | export const command = { 4 | data: new SlashCommandBuilder() 5 | .setName('help') 6 | .setDescription('Displays help commands'), 7 | category: 'Support', 8 | async execute(interaction: ChatInputCommandInteraction) { 9 | let client = interaction.client; 10 | let applicationCommands = await client.application.commands.fetch(); 11 | let categories: string[] = []; 12 | client.commands.each((command) => { 13 | if (!categories.includes(command.category)) { 14 | categories.push(command.category); 15 | } 16 | }); 17 | let msg = await interaction.reply({ 18 | content: '', 19 | embeds: [new EmbedBuilder().setColor('Random').setTitle('Help').setDescription('Use the dropdown menu provided below and select a category')], 20 | components: [ // @ts-ignore 21 | new ActionRowBuilder().addComponents( 22 | new StringSelectMenuBuilder() 23 | .setCustomId('help-dropdown') 24 | .setPlaceholder('Select a category') 25 | .addOptions([ 26 | ...categories.map((category) => { 27 | return { 28 | label: category, 29 | value: category, 30 | description: `Displays all commands in ${category}` 31 | }; 32 | }) 33 | ]) 34 | ) 35 | ], 36 | fetchReply: true 37 | }); 38 | const collector = msg.createMessageComponentCollector({ time: 120000 }); 39 | collector.on('collect', async (component: any) => { 40 | if(component.user.id !== interaction.user.id) return await component.reply({ content: `These components are not for you my guy`, ephemeral: true }); 41 | const categoryValue = component.values[0]; 42 | if(categories.includes(categoryValue)) return await component.update({ 43 | embeds: [ 44 | new EmbedBuilder() 45 | .setColor('Random') 46 | .setTitle(`Help - ${categoryValue}`) 47 | .setDescription(client.commands.filter((cmd) => cmd.category === categoryValue).map((cmd) => ` command.name === cmd.data.name)!.id}> - ${cmd.data.description}`).join('\n')) ], 48 | }); 49 | }); 50 | 51 | collector.on("end", async (collected) => { 52 | await msg.edit({ 53 | embeds: [new EmbedBuilder().setColor('Random').setTitle('Help').setDescription('This help menu has been disabled, use this command again to open another help menu')], 54 | components: [ // @ts-ignore 55 | new ActionRowBuilder().addComponents( 56 | new StringSelectMenuBuilder() 57 | .setCustomId('help-dropdown') 58 | .setPlaceholder('Select a category') 59 | .setDisabled(true) 60 | .addOptions([ 61 | ...categories.map((category) => { 62 | return { 63 | label: category, 64 | value: category, 65 | description: `Displays all commands in ${category}` 66 | }; 67 | }) 68 | ]) 69 | ) 70 | ] 71 | }); 72 | }); 73 | } 74 | }; 75 | -------------------------------------------------------------------------------- /src/commands/support/restrictions.ts: -------------------------------------------------------------------------------- 1 | import { SlashCommandBuilder, EmbedBuilder, ChatInputCommandInteraction, GuildMember } from 'discord.js'; 2 | 3 | export const command = { 4 | data: new SlashCommandBuilder() 5 | .setName('restrictions') 6 | .setDescription('Responds to "Why is my Cider skipping songs"') 7 | .addUserOption((option) => option.setName('user').setDescription('User to repond to')), 8 | category: 'Support', 9 | async execute(interaction: ChatInputCommandInteraction) { 10 | let embed = new EmbedBuilder() 11 | .setColor('Random') 12 | .setTitle('Why is Cider skipping some songs?') 13 | .setDescription( 14 | 'Your account might have content restrictions set to "Clean"\n\n In order to check, go to [Apple Media Account settings](https://tv.apple.com/settings) and check the "Content Restrictions" section.\n\n Make sure that Music is set to `Explicit`' 15 | ) 16 | .setFooter({ text: 'Requested by ' + (interaction.member as GuildMember).user.username, iconURL: (interaction.member as GuildMember).user.avatarURL() as string }) 17 | .setTimestamp(); 18 | let user = interaction.options.getUser('user') || null; 19 | if (user) { 20 | await interaction.reply({ content: `${user}`, embeds: [embed] }); 21 | } else { 22 | await interaction.reply({ embeds: [embed] }); 23 | } 24 | } 25 | }; 26 | -------------------------------------------------------------------------------- /src/commands/support/support.ts: -------------------------------------------------------------------------------- 1 | import { SlashCommandBuilder, EmbedBuilder, ChatInputCommandInteraction } from 'discord.js'; 2 | import 'dotenv/config'; 3 | 4 | export const command = { 5 | data: new SlashCommandBuilder().setName('support').setDescription("Need support?").addUserOption(option => option.setName('user').setDescription('User to repond to')), 6 | category: 'Support', 7 | async execute(interaction: ChatInputCommandInteraction) { 8 | let embed = new EmbedBuilder() 9 | .setColor('Random') 10 | .setTitle("Support") 11 | .setDescription("Need support? Or want to request for data deletion?\nContact us on these platforms:\n\n:envelope_with_arrow: \n[<:github:967957574525804624> Github](https://github.com/orgs/ciderapp/discussions)\n[<:twitter:1024171779289251970> Twitter](https://twitter.com/useCider/)") 12 | .setFooter({ text: `Bot Version: ${process.env.npm_package_version} ${process.env.NODE_ENV || ""}` }) 13 | let user = interaction.options.getUser('user') || null 14 | if (user) { 15 | await interaction.reply({ content: `${user}`, embeds: [embed]}); 16 | } else { 17 | await interaction.reply({ embeds: [embed], ephemeral: true }); 18 | } 19 | console.log(process.env) 20 | }, 21 | }; 22 | -------------------------------------------------------------------------------- /src/commands/support/verify.ts: -------------------------------------------------------------------------------- 1 | import { SlashCommandBuilder, EmbedBuilder, ChatInputCommandInteraction } from 'discord.js'; 2 | 3 | export const command = { 4 | data: new SlashCommandBuilder() 5 | .setName('verify') 6 | .setDescription('Verify you donation status (Open Collective only)') 7 | .addStringOption(option => option.setName('email') 8 | .setDescription('Email used') 9 | .setRequired(true) 10 | ), 11 | category: 'Support', 12 | async execute(interaction: ChatInputCommandInteraction) { 13 | await interaction.reply({ content: 'Verify command is currently disabled. Please open a ticket and send your receipt to verify instead.', ephemeral: true }); 14 | // await interaction.reply({ content: 'Verifying your Donation/s from OpenCollective...', ephemeral: true }); 15 | 16 | // let email = interaction.options.getString('email'); 17 | 18 | // if (await emailExists(email, interaction.user.id)) { 19 | // let ocResult = await fetch(`https://api.opencollective.com/v1/collectives/ciderapp/transactions/?apiKey=` + process.env.ocKey); 20 | // ocResult = await ocResult.json(); 21 | // let donations = ocResult.result.filter(transaction => transaction.type !== 'DEBIT' && transaction.createdByUser && transaction.createdByUser.email === email); 22 | 23 | // if (donations.length === 0) { 24 | // await interaction.editReply({ content: 'You have not donated to CiderApp', ephemeral: true }); 25 | // } else { 26 | // let embed = new EmbedBuilder() 27 | // .setTitle('Your donations') 28 | // .setColor('Random'); 29 | // donations.forEach(donation => { 30 | // embed.addFields({ 31 | // name: donation.createdAt, 32 | // value: `Initial Donation: \`${donation.amount / 100}\` ${donation.hostCurrency} 33 | // Payment Processor Fee: \`${donation.paymentProcessorFeeInHostCurrency / 100}\` ${donation.hostCurrency} 34 | // Received Amount: \`${donation.netAmountInCollectiveCurrency / 100}\` ${donation.hostCurrency} 35 | // `}); 36 | // firebase.addDonation(donation, interaction.member.id); 37 | // }); 38 | // if (interaction.guild.id === '843954443845238864') { 39 | // embed.setFooter({ text: 'Your role should be given to you shortly' }); 40 | // try { 41 | // interaction.guild.members.cache.get(interaction.member.id).roles.add('923351772532199445'); 42 | // interaction.guild.members.cache.get(interaction.member.id).roles.add('932811694751768656'); 43 | // } catch (error) { 44 | // // console.log(error) 45 | // } 46 | // } 47 | // firebase.addEmail(email, interaction.user.id); 48 | 49 | // await interaction.editReply({ content: "Thank you for donating to Cider!", embeds: [embed], ephemeral: true }); 50 | // } 51 | // } else { 52 | // await interaction.editReply({ content: "Sorry, we couldn't verify your donation. Please make sure you have entered the correct email.", ephemeral: true }); 53 | // } 54 | }, 55 | }; -------------------------------------------------------------------------------- /src/data/headers.js: -------------------------------------------------------------------------------- 1 | export const CiderGET = () => { 2 | return { 'User-Agent': 'Cider', Referer: 'localhost' }; 3 | }; 4 | export const CiderPOST = () => { 5 | return { 'User-Agent': 'Cider', Referer: 'localhost', 'Content-Type': 'application/json' }; 6 | }; 7 | export const MusicKit = (apiToken) => { 8 | return { 9 | Authorization: 'Bearer ' + apiToken, 10 | DNT: '1', 11 | authority: 'amp-api.music.apple.com', 12 | origin: 'https://beta.music.apple.com', 13 | referrer: 'https://beta.music.apple.com/', 14 | 'sec-fetch-dest': 'empty', 15 | 'sec-fetcher-mode': 'cors', 16 | 'sec-fetch-site': 'same-site' 17 | }; 18 | }; 19 | -------------------------------------------------------------------------------- /src/events/debug.ts: -------------------------------------------------------------------------------- 1 | import consola from 'consola'; 2 | import { Events } from 'discord.js' 3 | 4 | export default { 5 | name: Events.Debug, 6 | once: false, 7 | devOnly: true, 8 | execute(info: string) { 9 | consola.debug("\x1b[33m%s\x1b[90m%s\x1b[0m", "[DJS]", info); 10 | } 11 | } -------------------------------------------------------------------------------- /src/events/guildCreate.ts: -------------------------------------------------------------------------------- 1 | import consola from 'consola'; 2 | import { ActivityType, EmbedBuilder, Events, Guild, TextChannel } from 'discord.js' 3 | 4 | export default { 5 | name: Events.GuildCreate, 6 | once: false, 7 | execute(guild: Guild) { 8 | consola.info(`Joined guild ${guild.name} (${guild.id})`); 9 | const channel = guild.channels.cache.find(c => c.isTextBased() && c.permissionsFor(guild.client.user)?.has('SendMessages')) as TextChannel; 10 | channel.send({content: '', embeds: [ 11 | new EmbedBuilder() 12 | .setAuthor({ name: guild.client.user?.username, iconURL: guild.client.user?.avatarURL() as string, url: 'https://discord.com/users/921475709694771252' }) 13 | .setTitle(`Thanks for adding me!, ${guild.name}`) 14 | .setDescription("I'm Cider, the official companion bot from [Cider Collective](https://discord.gg/applemusic).\n\nSome Useful Commands:\n - plays music in your voice channel.\n - generates the latest build of Cider straight from our labs .\n - generates a high quality image of the album/artist provided.\n - gets the info of the query provided from Apple Music.\n - gets the lyrics of the song provided.\n\nIf you need any help for any of my commands, feel free to use to provide a quick guide or visiting my Discord Server for more info.") .setColor(0xf21f52) 15 | .setThumbnail(guild.iconURL()) 16 | .setTimestamp() 17 | ]}); 18 | guild.client.user.setActivity(`${guild.client.guilds.cache.size} servers`, { type: ActivityType.Listening }); 19 | } 20 | } -------------------------------------------------------------------------------- /src/events/interaction.ts: -------------------------------------------------------------------------------- 1 | import { BaseInteraction, ChatInputCommandInteraction, Client, Events } from 'discord.js' 2 | import consola from 'consola' 3 | export default { 4 | name: Events.InteractionCreate, 5 | once: false, 6 | execute(interaction: BaseInteraction) { 7 | if (interaction.isChatInputCommand()) { 8 | const command = interaction.client.commands.get(interaction.commandName); 9 | if (!command) return; 10 | try { 11 | command.execute(interaction); 12 | } 13 | catch (error) { 14 | console.error(error); 15 | interaction.reply({ content: 'There was an error while executing this command!', ephemeral: true }); 16 | } 17 | } 18 | else if (interaction.isButton()) { 19 | consola.info(interaction.customId); 20 | const command = interaction.client.commands.get(interaction.customId); 21 | if (!command) return; 22 | try { 23 | command.execute(interaction); 24 | } 25 | catch (error) { 26 | console.error(error); 27 | interaction.reply({ content: 'There was an error while executing this command!', ephemeral: true }); 28 | } 29 | } 30 | else if (interaction.isAutocomplete()) { 31 | const command = interaction.client.commands.get(interaction.commandName); 32 | if (!command) return; 33 | try { 34 | command.autocomplete(interaction); 35 | } 36 | catch (error) { 37 | console.error(error); 38 | } 39 | } else if(interaction.isStringSelectMenu()) { 40 | const command = interaction.client.interactions.get(interaction.customId); 41 | if (!command) return; 42 | try { 43 | command.execute(interaction); 44 | } 45 | catch (error) { 46 | console.error(error); 47 | } 48 | } 49 | 50 | 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /src/events/ready.ts: -------------------------------------------------------------------------------- 1 | import { ActivityType, Client, ColorResolvable, EmbedBuilder, Events, Guild, GuildBasedChannel, TextChannel } from 'discord.js'; 2 | import { getAPIToken } from '../integrations/musickitAPI.js'; 3 | import { firebase } from '../integrations/firebase.js'; 4 | import { getServiceStatus } from '../integrations/serviceStatus.js'; 5 | import { readFileSync, writeFileSync } from 'node:fs'; 6 | import consola from 'consola'; 7 | import 'dotenv/config'; 8 | 9 | export default { 10 | name: Events.ClientReady, 11 | once: true, 12 | async execute(client: Client) { 13 | client.amAPIToken = await getAPIToken(); 14 | // await client.player.extractors.loadDefault(); 15 | consola.success(`Logged in as ${client.user.tag}`); 16 | client.user.setActivity('Starting up...', { type: ActivityType.Playing }); 17 | const Guilds = client.guilds.cache.map((guild) => guild.name); 18 | let guild = client.guilds.cache.get(CiderServers.main); 19 | await syncAppleApiStatus(guild!); 20 | await syncOpenAIStatus(guild!); 21 | setInterval(() => { 22 | syncOpenAIStatus(guild!); 23 | }, 300000); 24 | setInterval(() => { 25 | syncAppleApiStatus(guild!); 26 | }, 300000); 27 | client.user.setActivity(`${client.guilds.cache.size} servers`, { type: ActivityType.Listening }); 28 | // playerEvents(client.player); 29 | checkSelfUpdate(client); 30 | if (process.env.NODE_ENV === 'development') return client.user.setPresence({ activities: [{ name: '⚙️ in development' }], status: 'idle' }); 31 | } 32 | }; 33 | async function syncAppleApiStatus(guild: Guild) { 34 | if (process.env.NODE_ENV != 'production') return; 35 | let channel = guild.channels.cache.get(CiderGuildChannels.appleServices); 36 | let services = await getServiceStatus(); 37 | if (services?.length === 0) return; 38 | let embeds = []; 39 | let statusEmoji = ''; 40 | 41 | for (let service of services!) { 42 | let found = false; 43 | let storedEvents = await firebase.getServiceEvents(service.serviceName); 44 | storedEvents.forEach((el: { messageId: string }) => { 45 | if (el.messageId === service.event.messageId) found = true; 46 | }); 47 | if (found) return; 48 | if (service.event.eventStatus === 'resolved' || service.event.eventStatus === 'completed') statusEmoji = '🟢'; 49 | else if (service.event.eventStatus === 'ongoing') statusEmoji = '🟠'; 50 | else if (service.event.eventStatus === 'scheduled' || service.event.eventStatus === 'upcoming') statusEmoji = '🟡'; 51 | else statusEmoji = '🔴'; 52 | let embed = new EmbedBuilder() 53 | .setAuthor({ name: service.serviceName, url: service.redirectUrl, iconURL: 'https://upload.wikimedia.org/wikipedia/commons/a/ab/Apple-logo.png' }) 54 | .setDescription(`${statusEmoji} ${service.event.statusType} - ${service.event.usersAffected}\n\n${service.event.message}`) 55 | .setFields([ 56 | { name: 'Status', value: `${service.event.eventStatus}`, inline: true }, 57 | { name: 'Message ID', value: service.event.messageId, inline: true }, 58 | { name: 'Affected Service', value: service.event.affectedServices || service.serviceName, inline: true } 59 | ]) 60 | .setTimestamp(); 61 | if (service.event.epochStartDate) embed.addFields({ name: 'Start Date', value: ``, inline: true }); 62 | if (service.event.epochEndDate) embed.addFields({ name: 'End Date', value: ``, inline: true }); 63 | if (service.event.eventStatus === 'resolved') embed.setColor([0, 255, 0]); 64 | else if (service.event.eventStatus === 'ongoing') embed.setColor([255, 180, 0]); 65 | embeds.push(embed); 66 | await firebase.addServiceEvent(service.serviceName, service.event); 67 | } 68 | (channel as TextChannel).send({ embeds }); 69 | } 70 | async function syncOpenAIStatus(guild: Guild) { 71 | if (process.env.NODE_ENV != 'production') return; 72 | let channel = guild.channels.cache.get(CiderGuildChannels.appleServices); 73 | let res: any = await fetch(`https://status.openai.com/api/v2/incidents.json`); 74 | res = await res.json(); 75 | if (res.incidents.length == 0) return; 76 | 77 | for (let incident of res.incidents) { 78 | let found = false; 79 | let storedEvents = await firebase.getOpenAIEvents(); 80 | storedEvents.forEach((el: any) => { 81 | if (el.id === incident.id && el.incident_updates.length == incident.incident_updates.length) found = true; 82 | }); 83 | if (found) return; 84 | await firebase.addOpenAIEvent(incident); 85 | let current = { 86 | name: incident.resolved_at ? 'Resolved Date' : ' Last Updated', 87 | date: incident.resolved_at ? `` : `` 88 | }; 89 | let status_indicator = ''; 90 | let status_color = [0, 0, 0] as ColorResolvable; 91 | switch (incident.status) { 92 | case 'postmortem': 93 | case 'resolved': 94 | status_indicator = '🟢'; 95 | status_color = [0, 255, 0]; 96 | break; 97 | case 'investigating': 98 | status_indicator = '🟠'; 99 | status_color = [255, 127, 0]; 100 | break; 101 | case 'identified': 102 | case 'monitoring': 103 | status_indicator = '🟡'; 104 | status_color = status_color = [255, 255, 0]; 105 | break; 106 | default: 107 | status_indicator = '🔴'; 108 | status_color = [255, 0, 0]; 109 | break; 110 | } 111 | consola.info(incident, current, status_indicator); 112 | let embed = new EmbedBuilder() 113 | .setAuthor({ name: 'OpenAI Status', url: 'https://status.openai.com/', iconURL: 'https://openai.com/content/images/2022/05/openai-avatar.png' }) 114 | .setTitle(`${status_indicator} [${incident.impact}] ${incident.name}`) 115 | .setDescription(incident.incident_updates[0].body) 116 | .setFields({ name: 'Start Date', value: ``, inline: true }, { name: `${current.name}`, value: current.date, inline: true }) 117 | .setTimestamp(); 118 | if (incident.incident_updates[0].affected_components) embed.addFields({ name: 'Affected Services', value: incident.incident_updates[0].affected_components.map((el: any) => el.name + ' - ' + el.new_status).join('\n') }); 119 | 120 | embed.setColor(status_color); 121 | 122 | (channel as TextChannel).send({ embeds: [embed] }); 123 | } 124 | } 125 | 126 | function checkSelfUpdate(client: Client) { 127 | if (process.env.NODE_ENV != 'production' || readFileSync('./update.lock', 'utf-8') == process.env.npm_package_version) return; 128 | client.guilds.cache.forEach(async (guild) => { 129 | // if(guild.id != CiderServers.testServer) return; 130 | let channel = guild.channels.cache.find((c) => c.isTextBased() && c.permissionsFor(client.user!)?.has('SendMessages') && c.name == 'general') as TextChannel; 131 | if (!channel) channel = guild.channels.cache.find((c) => c.isTextBased() && c.permissionsFor(client.user!)?.has('SendMessages')) as TextChannel; 132 | let changelog = ['- Removed Music capability due to Apple Music API changes (might spawn a new bot just for music)']; 133 | channel.send({ 134 | embeds: [ 135 | new EmbedBuilder() 136 | .setAuthor({ name: 'Cider Bot Updates', iconURL: client.user?.displayAvatarURL() }) 137 | .setTitle(`:tada: Updated to v${process.env.npm_package_version}`) 138 | .setDescription(`**Changelog**\n\n${changelog.join('\n')}}`) 139 | ] 140 | }); 141 | writeFileSync('./update.lock', `${process.env.npm_package_version}`); 142 | }); 143 | } 144 | -------------------------------------------------------------------------------- /src/index.ts: -------------------------------------------------------------------------------- 1 | import { Client, GatewayIntentBits, Partials, Collection, TextChannel, EmbedBuilder, Colors } from 'discord.js'; 2 | import 'dotenv/config'; 3 | import consola from 'consola'; 4 | import { readdirSync } from 'fs'; 5 | import * as Sentry from '@sentry/node'; 6 | 7 | Sentry.init({ 8 | dsn: 'https://abd160622caf3d98674db59f4ed21ad7@o4505637250793472.ingest.sentry.io/4505637252169728', 9 | // Performance Monitoring 10 | tracesSampleRate: 1.0 11 | }); 12 | 13 | declare module 'discord.js' { 14 | export interface Client { 15 | amAPIToken: string; 16 | commands: Collection; 17 | canPingKeefe: boolean; 18 | interactions: Collection; 19 | replies: Collection; 20 | // player: Player; 21 | // playerEmbeds: Map; 22 | } 23 | } 24 | 25 | const client = new Client({ 26 | intents: [ 27 | GatewayIntentBits.Guilds, 28 | GatewayIntentBits.GuildModeration, 29 | GatewayIntentBits.GuildMembers, 30 | GatewayIntentBits.GuildMessageReactions, 31 | GatewayIntentBits.GuildVoiceStates, 32 | GatewayIntentBits.DirectMessages, 33 | GatewayIntentBits.DirectMessageReactions, 34 | GatewayIntentBits.DirectMessageTyping 35 | ], 36 | partials: [Partials.Channel, Partials.User, Partials.GuildMember, Partials.Reaction] 37 | }); 38 | // client.playerEmbeds = new Map(); 39 | // client.player = new Player(client); 40 | client.commands = new Collection(); 41 | client.interactions = new Collection(); 42 | 43 | const mainFolder = process.env.NODE_ENV === 'development' ? 'src' : 'build'; 44 | const fileType = process.env.NODE_ENV === 'development' ? '.ts' : '.js'; 45 | 46 | /** REGISTER COMMANDS */ 47 | const commandFolders = readdirSync(`./${mainFolder}/commands/`); 48 | for (const folder of commandFolders) { 49 | const commandFiles = readdirSync(`./${mainFolder}/commands/${folder}`).filter((file) => file.endsWith(fileType)); 50 | for (const file of commandFiles) { 51 | const { command } = await import(`./commands/${folder}/${file}`); 52 | client.commands.set(command.data.name, command); 53 | consola.info('\x1b[32m%s\x1b[0m', 'Registered Command:', command.data.name, command?.category); 54 | } 55 | } 56 | 57 | /** REGISTER INTERACTIONS */ 58 | const interactionFiles = readdirSync(`./${mainFolder}/interactions`).filter((file) => file.endsWith(fileType)); 59 | for (const file of interactionFiles) { 60 | const { interaction } = await import(`./interactions/${file}`); 61 | client.interactions.set(interaction.data.name, interaction); 62 | consola.info('\x1b[32m%s\x1b[0m', 'Registered Interaction:', interaction.data.name); 63 | } 64 | 65 | const eventFiles = readdirSync(`./${mainFolder}/events`).filter((file) => file.endsWith(fileType)); 66 | for (const file of eventFiles) { 67 | const event = (await import(`./events/${file}`)).default; 68 | consola.info(`Loaded event: ${event.name}`); 69 | if (event?.devOnly && process.env.NODE_ENV !== 'development') continue; 70 | if (event?.once) { 71 | client.once(event.name, (...args) => event.execute(...args)); 72 | } else { 73 | client.on(event.name, (...args) => event.execute(...args)); 74 | } 75 | } 76 | try { 77 | client.login(process.env.DISCORD_TOKEN); 78 | } catch (e) { 79 | Sentry.captureException(e); 80 | } 81 | 82 | /*** ERROR HANDLING ***/ 83 | process.on('unhandledRejection', (error: Error) => { 84 | Sentry.captureException(error); 85 | consola.info('Unhandled Rejection'); 86 | consola.error(error); 87 | consola.error(error.stack); 88 | (client.channels.cache.get(CiderGuildChannels.botLog) as TextChannel)?.send({ content: `Unhandled Rejection`, embeds: [createErrorEmbed(error)] }); 89 | }); 90 | process.on('uncaughtException', (error: Error) => { 91 | Sentry.captureException(error); 92 | consola.info('Uncaught Exception'); 93 | consola.error(error); 94 | consola.error(error.stack); 95 | (client.channels.cache.get(CiderGuildChannels.botLog) as TextChannel)?.send({ content: `Uncaught Exception`, embeds: [createErrorEmbed(error)] }); 96 | }); 97 | 98 | function createErrorEmbed(error: Error) { 99 | return new EmbedBuilder() 100 | .setColor(Colors.Red) 101 | .setTitle(error.name) 102 | .setDescription(error.message) //@ts-ignore 103 | .addFields({ name: 'Origin', value: `\`\`\`${error.stack?.slice(0, 1024)}\`\`\`` }); 104 | } 105 | -------------------------------------------------------------------------------- /src/integrations/firebase.ts: -------------------------------------------------------------------------------- 1 | // Import the functions you need from the SDKs you need 2 | import consola from 'consola' 3 | import { initializeApp, cert, ServiceAccount } from "firebase-admin/app"; 4 | import { getFirestore, Timestamp, FieldValue } from 'firebase-admin/firestore' 5 | import serviceAccount from '../data/serviceAccountKey.json' assert { type: 'json' }; 6 | import 'dotenv/config' 7 | // TODO: Add SDKs for Firebase products that you want to use 8 | // https://firebase.google.com/docs/web/setup#available-libraries 9 | 10 | // Initialize Firebase 11 | const app = initializeApp({ 12 | credential: cert(serviceAccount as ServiceAccount) 13 | }); 14 | 15 | const firestore = getFirestore(app); 16 | 17 | consola.success("\x1b[32m%s\x1b[0m", '[firebase]', "Connected") 18 | 19 | export const firebase = { 20 | async commandCounter(command: string) { 21 | try { 22 | let analytics = firestore.doc(`cider-bot/analytics/commands/${command}`) 23 | analytics.update('count', FieldValue.increment(1), 'lastUsed', Timestamp.now()).catch(() => analytics.set({ count: 0, lastUsed: Timestamp.now() })) 24 | } 25 | catch (e) { 26 | consola.error(e) 27 | } 28 | }, 29 | async replyCounter(reply: string) { 30 | try { 31 | let analytics = firestore.doc(`cider-bot/analytics/replies/${reply}`) 32 | analytics.update('count', FieldValue.increment(1), 'lastUsed', Timestamp.now()).catch(() => analytics.set({ count: 0, lastUsed: Timestamp.now() })) 33 | } 34 | catch (e) { 35 | consola.error(e) 36 | } 37 | }, 38 | async syncReleaseData(branch: string) { 39 | consola.info(branch); 40 | switch(branch) { 41 | case 'cider2electron': 42 | firestore.doc(`cider-bot/releases/cider-2/${branch}`).set({ ready: false }) 43 | case 'cider2uwp': 44 | firestore.doc(`cider-bot/releases/cider-2/${branch}`).set({ ready: false }) 45 | default: 46 | 47 | try { 48 | let releases: any[] = await (await fetch(`https://api.github.com/repos/ciderapp/cider/releases?per_page=100`)).json() 49 | releases.sort((a: any, b: any) => { return Date.parse(b.published_at) - Date.parse(a.published_at) }) 50 | for (let release of releases) { 51 | if (String(release.name).split(' ')[String(release.name).split(' ').length - 1].replace(/[(+)]/g, '') === "1.6.1") { 52 | let links = { 'dmg': '', 'pkg': '', 'exe': '', 'winget': '', 'AppImage': '', 'deb': '', 'snap': ''}; 53 | for (let asset of release.assets) { 54 | switch (true) { 55 | case asset.name.endsWith('.dmg'): links.dmg = asset.browser_download_url; break; 56 | case asset.name.endsWith('.pkg'): links.pkg = asset.browser_download_url; break; 57 | case (asset.name.endsWith('.exe') && !asset.name.includes('-winget-')): links.exe = asset.browser_download_url; break; 58 | case (asset.name.endsWith('.exe') && asset.name.includes('-winget-')): links.winget = asset.browser_download_url; break; 59 | case asset.name.endsWith('.AppImage'): links.AppImage = asset.browser_download_url; break; 60 | case asset.name.endsWith('.deb'): links.deb = asset.browser_download_url; break; 61 | case asset.name.endsWith('.snap'): links.snap = asset.browser_download_url; break; 62 | } 63 | } 64 | 65 | let analytics = firestore.doc(`cider-bot/releases/cider-1/${branch}`) 66 | analytics.set({ 67 | 'tag' : release.tag_name, 68 | 'lastUpdated': Timestamp.fromDate(new Date(release.published_at)), 69 | 'timestamp': Timestamp.now(), 70 | 'releaseID': release.id, 71 | 'links': links 72 | }) 73 | return; 74 | } 75 | } 76 | } 77 | catch (e) { 78 | consola.error(e) 79 | } 80 | break; 81 | } 82 | 83 | 84 | }, 85 | async getLatestRelease(branch: string) { 86 | try { 87 | if (branch == 'alpha') { 88 | const authKey = Buffer.from(`${process.env.AZURE_USER}:${process.env.AZURE_PAT}`).toString('base64'); 89 | let runId = await fetch(`https://dev.azure.com/${process.env.AZURE_ORG}/${process.env.AZURE_PROJECT}/_apis/pipelines/1/runs?api-version=7.0`, { headers: { 'Authorization': `Basic ${authKey}` } }) 90 | runId = (await runId.json()).count 91 | let release = await (await fetch(`https://dev.azure.com/${process.env.AZURE_ORG}/${process.env.AZURE_PROJECT}/_apis/build/builds/${runId}/artifacts?artifactName=Cider-UWP&api-version=7.0`, { headers: { 'Authorization': `Basic ${authKey}` } })).json() 92 | console.log(release) 93 | return release.resource.downloadUrl; 94 | } 95 | let analytics = firestore.doc(`cider-bot/releases/cider-1/${branch}`) 96 | if(branch.includes('cider2')) analytics = firestore.doc(`cider-bot/releases/cider-2/${branch}`) 97 | let data = await analytics.get() 98 | return data.data() 99 | } 100 | catch (e) { 101 | consola.error(e) 102 | } 103 | }, 104 | async getActiveUsers() { 105 | try { 106 | let analytics = firestore.doc(`cider-bot/users`) 107 | let data = await analytics.get() 108 | return data.data()!.active 109 | } 110 | catch (e) { 111 | consola.error(e) 112 | } 113 | }, 114 | async setActiveUsers(count: number) { 115 | try { 116 | let analytics = firestore.doc(`cider-bot/users`) 117 | analytics.update('active', count) 118 | } 119 | catch (e) { 120 | consola.error(e) 121 | } 122 | }, 123 | async getTotalUsers() { 124 | try { 125 | let analytics = firestore.doc(`cider-bot/users`) 126 | let data = await analytics.get() 127 | return data.data()!.total 128 | } 129 | catch (e) { 130 | consola.error(e) 131 | } 132 | }, 133 | async setTotalUsers(count: number) { 134 | try { 135 | let analytics = firestore.doc(`cider-bot/users`) 136 | analytics.update('total', count) 137 | } 138 | catch (e) { 139 | consola.error(e) 140 | } 141 | }, 142 | async getUserTimezone(id: string) { 143 | try { 144 | let analytics = firestore.doc(`cider-bot/users/timezone/${id}`) 145 | let data = await analytics.get() 146 | return data.data()!.timezone 147 | } 148 | catch (e) { 149 | consola.error(e) 150 | } 151 | }, 152 | async setUserTimezone(id: string, timezone: string) { 153 | try { 154 | let analytics = firestore.doc(`cider-bot/users/timezone/${id}`) 155 | analytics.set({ timezone }) 156 | } 157 | catch (e) { 158 | consola.error(e) 159 | } 160 | }, 161 | async addServiceEvent(service: string, event: object) { 162 | try { 163 | let analytics = firestore.doc(`cider-bot/analytics/apple-services/${service}`) 164 | analytics.create({ events: [event] }).catch(() => analytics.update('events', FieldValue.arrayUnion(event))) 165 | } 166 | catch (e) { 167 | consola.error(e) 168 | } 169 | }, 170 | async getServiceEvents(service: string) { 171 | try { 172 | let analytics = firestore.doc(`cider-bot/analytics/apple-services/${service}`) 173 | let data = await analytics.get() 174 | if (!data.data()) return [] 175 | return data.data()!.events 176 | } 177 | catch (e) { 178 | consola.error(e) 179 | } 180 | }, 181 | async addOpenAIEvent(event: object) { 182 | try { 183 | let analytics = firestore.doc(`cider-bot/analytics/openai/events`) 184 | analytics.create({ events: [event] }).catch(() => analytics.update('events', FieldValue.arrayUnion(event))) 185 | } 186 | catch (e) { 187 | consola.error(e) 188 | } 189 | }, 190 | async getOpenAIEvents() { 191 | try { 192 | let analytics = firestore.doc(`cider-bot/analytics/openai/events`) 193 | let data = await analytics.get() 194 | if (!data.data()) return [] 195 | return data.data()!.events 196 | } 197 | catch (e) { 198 | consola.error(e) 199 | } 200 | } 201 | } 202 | 203 | 204 | 205 | 206 | 207 | 208 | 209 | -------------------------------------------------------------------------------- /src/integrations/musickitAPI.ts: -------------------------------------------------------------------------------- 1 | import { CiderGET as CiderHeader, MusicKit as MusicKitHeader } from '../data/headers.js'; 2 | import 'dotenv/config'; 3 | 4 | export const getAPIToken = async () => { 5 | let apiToken = await fetch('https://api.cider.sh/v1', { headers: CiderHeader() }); 6 | return (await apiToken.json()).token; 7 | }; 8 | 9 | export const getArtwork = async (apiToken: string, query: string, animatedArtwork: boolean) => { 10 | // console.info(`[MusicKit] Fetching artwork for ${query}`); 11 | if (query.startsWith('https://music.apple.com') || query.startsWith('https://beta.music.apple.com')) query = (await convertLinkToAPI(query)) as string; 12 | let href = `https://amp-api.music.apple.com${query}`; 13 | if (animatedArtwork && href.includes('?')) href = href + '&extend=editorialVideo&include=albums'; 14 | else if (animatedArtwork) href = href + '?extend=editorialVideo&include=albums'; 15 | let res = await (await fetch(href, { headers: MusicKitHeader(apiToken) })).json(); 16 | if (res.results) { 17 | res = res.results.top; 18 | if (res.data[0].type === 'songs') { 19 | res = await fetch(`https://amp-api.music.apple.com${res.data[0].href}?extend=editorialVideo&include=albums`, { headers: MusicKitHeader(apiToken) }); 20 | res = await res.json(); 21 | } 22 | } 23 | if (animatedArtwork && res.data[0].type === 'songs') res.data[0].attributes.editorialVideo = res.data[0].relationships.albums.data[0].attributes?.editorialVideo; 24 | return res.data[0]; 25 | }; 26 | 27 | export const getInfo = async (apiToken: string, query: string) => { 28 | if (query.startsWith('https://music.apple.com/') || query.startsWith('https://beta.music.apple.com/')) query = (await convertLinkToAPI(query)) as string; 29 | let href = `https://amp-api.music.apple.com${query}`; 30 | let res = await (await fetch(href, { headers: MusicKitHeader(apiToken) })).json(); 31 | if (res.results) res = res.results.top; 32 | return res.data[0]; 33 | }; 34 | 35 | export const search = async (apiToken: string, query: string, storefront: string = 'us', limit: number = 10) => { 36 | let href = new URL(`v1/catalog/${storefront}/search/`, 'https://amp-api.music.apple.com/'); 37 | href.searchParams.set('term', query); 38 | href.searchParams.set('platform', 'web'); 39 | href.searchParams.set('types', 'albums,playlists,songs'); 40 | href.searchParams.set('limit', `${limit}`); 41 | href.searchParams.set('with', 'serverBubbles,lyricHighlights'); 42 | href.searchParams.set('omit[resource]', 'autos'); 43 | 44 | let res = await (await fetch(href.toString(), { headers: MusicKitHeader(apiToken) })).json(); 45 | return res.results.top.data; 46 | 47 | }; 48 | 49 | const convertLinkToAPI = async (link: string) => { 50 | let catalog = link.split('/')[3]; 51 | let kind = link.split('/')[4]; 52 | let name = link.split('/')[5]; 53 | let albumId = link.split('/')[6]; 54 | let songId = link.split('=')[1]; 55 | if (kind === 'album') { 56 | if (songId) { 57 | return `/v1/catalog/${catalog}/songs/${songId}`; 58 | } 59 | return `/v1/catalog/${catalog}/albums/${albumId}`; 60 | } else if (kind === 'playlist') { 61 | return `/v1/catalog/${catalog}/playlists/${albumId}`; 62 | } else if (kind === 'artist') { 63 | return `/v1/catalog/${catalog}/artists/${albumId}`; 64 | } else if (kind === 'curator') { 65 | if (name.startsWith('apple-music-')) return `/v1/catalog/${catalog}/apple-curators/${albumId}`; 66 | return `/v1/catalog/${catalog}/curators/${albumId}`; 67 | } else if (kind === 'music-video') { 68 | return `/v1/catalog/${catalog}/music-videos/${albumId}`; 69 | } 70 | }; 71 | -------------------------------------------------------------------------------- /src/integrations/serviceStatus.ts: -------------------------------------------------------------------------------- 1 | import { firebase } from './firebase.js'; 2 | export const getServiceStatus = async () => { 3 | let res: any = await fetch(`https://www.apple.com/support/systemstatus/data/developer/system_status_en_US.js?callback=jsonCallback&_=${Date.now()}`); 4 | res = (await res.text()).split('jsonCallback(')[1].split(');')[0]; 5 | res = JSON.parse(res); 6 | let toReturn = []; 7 | for (let service of res.services) { 8 | if (service.events.length > 0) { 9 | let cachedServiceEvents = await firebase.getServiceEvents(service.serviceName); 10 | for (let event of service.events) { 11 | if (cachedServiceEvents.length === 0) { 12 | firebase.addServiceEvent(service.serviceName, event); 13 | toReturn.push({ serviceName: service.serviceName, redirectUrl: service.redirectUrl, event: event}); 14 | } else { 15 | for (let cachedEvent of cachedServiceEvents) 16 | if (event.messageId === cachedEvent.messageId && event.eventStatus !== cachedEvent.eventStatus) { 17 | firebase.addServiceEvent(service.serviceName, event); 18 | cachedEvent.eventStatus = event.eventStatus; 19 | toReturn.push({ serviceName: service.serviceName, redirectUrl: service.redirectUrl, event: event}); 20 | } 21 | } 22 | } 23 | return toReturn; 24 | } 25 | } 26 | }; -------------------------------------------------------------------------------- /src/interactions/branch.ts: -------------------------------------------------------------------------------- 1 | import { ActionRowBuilder, ButtonBuilder, ButtonStyle, GuildMemberRoleManager, StringSelectMenuInteraction } from 'discord.js'; 2 | import { firebase } from '../integrations/firebase.js'; 3 | import consola from 'consola'; 4 | 5 | export const interaction = { 6 | data: { name: 'branch' }, 7 | async execute(interaction: StringSelectMenuInteraction) { 8 | await interaction.update({ content: 'Generating Releases...', components: [] }); 9 | consola.info(interaction.user.username + '#' + interaction.user.discriminator + ' with UserID: ' + interaction.user.id + ' used branchbuild'); 10 | let branch = interaction.values[0].split('|')[0]; 11 | let show = interaction.values[0].split('|')[1] == 'true' || false; 12 | let user = interaction.values[0].split('|')[2] || ''; 13 | let memberRoles = (interaction.member!.roles as GuildMemberRoleManager).cache; 14 | let buttons = new ActionRowBuilder(); 15 | let buttonsMac = new ActionRowBuilder(); 16 | let release = null; 17 | await firebase.syncReleaseData(branch); 18 | release = await firebase.getLatestRelease(branch); 19 | consola.info('Release: ', release); 20 | if (release != null && release.ready != false) { 21 | if (release.links.AppImage) buttons.addComponents(new ButtonBuilder().setLabel('AppImage').setStyle(ButtonStyle.Link).setURL(`${release.links.AppImage}`)); 22 | if (release.links.exe) buttons.addComponents(new ButtonBuilder().setLabel('exe').setStyle(ButtonStyle.Link).setURL(`${release.links.exe}`)); 23 | if (release.links.deb) buttons.addComponents(new ButtonBuilder().setLabel('deb').setStyle(ButtonStyle.Link).setURL(`${release.links.deb}`)); 24 | if (release.links.snap) buttons.addComponents(new ButtonBuilder().setLabel('snap').setStyle(ButtonStyle.Link).setURL(`${release.links.snap}`)); 25 | if (release.links.dmg) buttonsMac.addComponents(new ButtonBuilder().setLabel('macos-dmg').setStyle(5).setURL(`${release.links.dmg}`)); 26 | if (release.links.pkg) buttonsMac.addComponents(new ButtonBuilder().setLabel('macos-pkg').setStyle(5).setURL(`${release.links.pkg}`)); 27 | if (release.links.uwp) buttons.addComponents(new ButtonBuilder().setLabel('UWP-Package').setStyle(ButtonStyle.Link).setURL(`${release.links.uwp}`)); 28 | let components = [buttons]; 29 | if (buttonsMac.components.length > 0) components.push(buttonsMac); 30 | if ((user != '' && memberRoles.has(CiderGuildRoles.dev)) || memberRoles.has(CiderGuildRoles.moderator)) 31 | return await interaction.editReply({ 32 | content: `${user}, What installer do you want from the **${branch}** branch?\nVersion: ${release.tag.slice(1)}\nLast Updated: `, //@ts-ignore 33 | components 34 | }); 35 | return await interaction.editReply({ 36 | content: `What installer do you want from the **${branch}** branch?\nVersion: ${release.tag.slice(1)}\nLast Updated: `, //@ts-ignore 37 | components 38 | }); 39 | } else if (release.ready == false) await interaction.editReply({ content: `The **${branch}** branch is currently being added to this bot, Check back later.` }); 40 | else { 41 | await interaction.editReply({ content: `The **${branch}** branch requires self-compilation! Check [Cider Docs - Self-Compiling](https://docs.cider.sh/compilation/) for more information.` }); 42 | } 43 | } 44 | }; 45 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | /* Visit https://aka.ms/tsconfig to read more about this file */ 4 | 5 | /* Projects */ 6 | // "incremental": true, /* Save .tsbuildinfo files to allow for incremental compilation of projects. */ 7 | // "composite": true, /* Enable constraints that allow a TypeScript project to be used with project references. */ 8 | // "tsBuildInfoFile": "./.tsbuildinfo", /* Specify the path to .tsbuildinfo incremental compilation file. */ 9 | // "disableSourceOfProjectReferenceRedirect": true, /* Disable preferring source files instead of declaration files when referencing composite projects. */ 10 | // "disableSolutionSearching": true, /* Opt a project out of multi-project reference checking when editing. */ 11 | // "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */ 12 | 13 | /* Language and Environment */ 14 | "target": "ESNext" /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */, 15 | // "lib": [], /* Specify a set of bundled library declaration files that describe the target runtime environment. */ 16 | // "jsx": "preserve", /* Specify what JSX code is generated. */ 17 | "experimentalDecorators": true, /* Enable experimental support for TC39 stage 2 draft decorators. */ 18 | "emitDecoratorMetadata": true, /* Emit design-type metadata for decorated declarations in source files. */ 19 | // "jsxFactory": "", /* Specify the JSX factory function used when targeting React JSX emit, e.g. 'React.createElement' or 'h'. */ 20 | // "jsxFragmentFactory": "", /* Specify the JSX Fragment reference used for fragments when targeting React JSX emit e.g. 'React.Fragment' or 'Fragment'. */ 21 | // "jsxImportSource": "", /* Specify module specifier used to import the JSX factory functions when using 'jsx: react-jsx*'. */ 22 | // "reactNamespace": "", /* Specify the object invoked for 'createElement'. This only applies when targeting 'react' JSX emit. */ 23 | // "noLib": true, /* Disable including any library files, including the default lib.d.ts. */ 24 | // "useDefineForClassFields": true, /* Emit ECMAScript-standard-compliant class fields. */ 25 | // "moduleDetection": "auto", /* Control what method is used to detect module-format JS files. */ 26 | 27 | /* Modules */ 28 | "module": "NodeNext" /* Specify what module code is generated. */, 29 | "rootDir": "./src", /* Specify the root folder within your source files. */ 30 | "moduleResolution": "NodeNext" /* Specify how TypeScript looks up a file from a given module specifier. */, 31 | // "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */ 32 | // "paths": {}, /* Specify a set of entries that re-map imports to additional lookup locations. */ 33 | "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */ 34 | // "typeRoots": [], /* Specify multiple folders that act like './node_modules/@types'. */ 35 | // "types": [], /* Specify type package names to be included without being referenced in a source file. */ 36 | // "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */ 37 | // "moduleSuffixes": [], /* List of file name suffixes to search when resolving a module. */ 38 | "resolveJsonModule": true, /* Enable importing .json files. */ 39 | // "noResolve": true, /* Disallow 'import's, 'require's or ''s from expanding the number of files TypeScript should add to a project. */ 40 | 41 | /* JavaScript Support */ 42 | "allowJs": true, /* Allow JavaScript files to be a part of your program. Use the 'checkJS' option to get errors from these files. */ 43 | // "checkJs": true, /* Enable error reporting in type-checked JavaScript files. */ 44 | // "maxNodeModuleJsDepth": 1, /* Specify the maximum folder depth used for checking JavaScript files from 'node_modules'. Only applicable with 'allowJs'. */ 45 | 46 | /* Emit */ 47 | // "declaration": true, /* Generate .d.ts files from TypeScript and JavaScript files in your project. */ 48 | // "declarationMap": true, /* Create sourcemaps for d.ts files. */ 49 | // "emitDeclarationOnly": true, /* Only output d.ts files and not JavaScript files. */ 50 | // "sourceMap": true, /* Create source map files for emitted JavaScript files. */ 51 | // "outFile": "./", /* Specify a file that bundles all outputs into one JavaScript file. If 'declaration' is true, also designates a file that bundles all .d.ts output. */ 52 | "outDir": "./build" /* Specify an output folder for all emitted files. */, 53 | // "removeComments": true, /* Disable emitting comments. */ 54 | "noEmit": true, /* Disable emitting files from a compilation. */ 55 | "importHelpers": true, /* Allow importing helper functions from tslib once per project, instead of including them per-file. */ 56 | // "importsNotUsedAsValues": "remove", /* Specify emit/checking behavior for imports that are only used for types. */ 57 | // "downlevelIteration": true, /* Emit more compliant, but verbose and less performant JavaScript for iteration. */ 58 | // "sourceRoot": "", /* Specify the root path for debuggers to find the reference source code. */ 59 | // "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */ 60 | // "inlineSourceMap": true, /* Include sourcemap files inside the emitted JavaScript. */ 61 | // "inlineSources": true, /* Include source code in the sourcemaps inside the emitted JavaScript. */ 62 | // "emitBOM": true, /* Emit a UTF-8 Byte Order Mark (BOM) in the beginning of output files. */ 63 | // "newLine": "crlf", /* Set the newline character for emitting files. */ 64 | // "stripInternal": true, /* Disable emitting declarations that have '@internal' in their JSDoc comments. */ 65 | // "noEmitHelpers": true, /* Disable generating custom helper functions like '__extends' in compiled output. */ 66 | // "noEmitOnError": true, /* Disable emitting files if any type checking errors are reported. */ 67 | // "preserveConstEnums": true, /* Disable erasing 'const enum' declarations in generated code. */ 68 | // "declarationDir": "./", /* Specify the output directory for generated declaration files. */ 69 | // "preserveValueImports": true, /* Preserve unused imported values in the JavaScript output that would otherwise be removed. */ 70 | 71 | /* Interop Constraints */ 72 | // "isolatedModules": true, /* Ensure that each file can be safely transpiled without relying on other imports. */ 73 | "allowSyntheticDefaultImports": true, /* Allow 'import x from y' when a module doesn't have a default export. */ 74 | "esModuleInterop": true /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */, 75 | // "preserveSymlinks": true, /* Disable resolving symlinks to their realpath. This correlates to the same flag in node. */ 76 | "forceConsistentCasingInFileNames": true /* Ensure that casing is correct in imports. */, 77 | 78 | /* Type Checking */ 79 | "strict": true /* Enable all strict type-checking options. */, 80 | // "noImplicitAny": true, /* Enable error reporting for expressions and declarations with an implied 'any' type. */ 81 | // "strictNullChecks": true, /* When type checking, take into account 'null' and 'undefined'. */ 82 | // "strictFunctionTypes": true, /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */ 83 | // "strictBindCallApply": true, /* Check that the arguments for 'bind', 'call', and 'apply' methods match the original function. */ 84 | // "strictPropertyInitialization": true, /* Check for class properties that are declared but not set in the constructor. */ 85 | // "noImplicitThis": true, /* Enable error reporting when 'this' is given the type 'any'. */ 86 | // "useUnknownInCatchVariables": true, /* Default catch clause variables as 'unknown' instead of 'any'. */ 87 | // "alwaysStrict": true, /* Ensure 'use strict' is always emitted. */ 88 | // "noUnusedLocals": true, /* Enable error reporting when local variables aren't read. */ 89 | // "noUnusedParameters": true, /* Raise an error when a function parameter isn't read. */ 90 | // "exactOptionalPropertyTypes": true, /* Interpret optional property types as written, rather than adding 'undefined'. */ 91 | // "noImplicitReturns": true, /* Enable error reporting for codepaths that do not explicitly return in a function. */ 92 | // "noFallthroughCasesInSwitch": true, /* Enable error reporting for fallthrough cases in switch statements. */ 93 | // "noUncheckedIndexedAccess": true, /* Add 'undefined' to a type when accessed using an index. */ 94 | // "noImplicitOverride": true, /* Ensure overriding members in derived classes are marked with an override modifier. */ 95 | // "noPropertyAccessFromIndexSignature": true, /* Enforces using indexed accessors for keys declared using an indexed type. */ 96 | // "allowUnusedLabels": true, /* Disable error reporting for unused labels. */ 97 | // "allowUnreachableCode": true, /* Disable error reporting for unreachable code. */ 98 | 99 | /* Completeness */ 100 | // "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */ 101 | "skipLibCheck": true /* Skip type checking all .d.ts files. */ 102 | }, 103 | "ts-node": { 104 | "esm": true 105 | }, 106 | "include": ["src/**/*", "environment.d.ts", "lyrics.tsx"] 107 | } 108 | --------------------------------------------------------------------------------