| 1238 | 1238 | </div> |
| 1239 | 1239 | `, |
| 1240 | 1240 | })); |
| 1241 | + SlashCommandParser.addCommandObject(SlashCommand.fromProps({ |
| 1242 | + name: 'extension-state', |
| 1243 | + callback: async (_, extensionName) => { |
| 1244 | + if (typeof extensionName !== 'string') throw new Error('Extension name must be a string. Closures or arrays are not allowed.'); |
| 1245 | + const internalExtensionName = extensionNames.find(x => equalsIgnoreCaseAndAccents(x, extensionName)); |
| 1246 | + if (!internalExtensionName) { |
| 1247 | + toastr.warning(`Extension ${extensionName} does not exist.`); |
| 1248 | + return ''; |
| 1249 | + } |
| 1250 | + |
| 1251 | + const isEnabled = !extension_settings.disabledExtensions.includes(internalExtensionName); |
| 1252 | + return String(isEnabled); |
| 1253 | + }, |
| 1254 | + unnamedArgumentList: [ |
| 1255 | + SlashCommandArgument.fromProps({ |
| 1256 | + description: 'Extension name', |
| 1257 | + typeList: [ARGUMENT_TYPE.STRING], |
| 1258 | + isRequired: true, |
| 1259 | + enumProvider: () => extensionNames.map(name => new SlashCommandEnumValue(name)), |
| 1260 | + forceEnum: true, |
| 1261 | + }), |
| 1262 | + ], |
| 1263 | + helpString: ` |
| 1264 | + <div> |
| 1265 | + Returns the state of a specified extension (true if enabled, false if disabled). |
| 1266 | + </div> |
| 1267 | + <div> |
| 1268 | + <strong>Example:</strong> |
| 1269 | + <ul> |
| 1270 | + <li> |
| 1271 | + <pre><code class="language-stscript">/extension-state Summarize</code></pre> |
| 1272 | + </li> |
| 1273 | + </ul> |
| 1274 | + </div> |
| 1275 | + `, |
| 1276 | + })); |
| 1277 | + SlashCommandParser.addCommandObject(SlashCommand.fromProps({ |
| 1278 | + name: 'extension-exists', |
| 1279 | + aliases: ['extension-installed'], |
| 1280 | + callback: async (_, extensionName) => { |
| 1281 | + if (typeof extensionName !== 'string') throw new Error('Extension name must be a string. Closures or arrays are not allowed.'); |
| 1282 | + const exists = extensionNames.find(x => equalsIgnoreCaseAndAccents(x, extensionName)) !== undefined; |
| 1283 | + return exists ? 'true' : 'false'; |
| 1284 | + }, |
| 1285 | + unnamedArgumentList: [ |
| 1286 | + SlashCommandArgument.fromProps({ |
| 1287 | + description: 'Extension name', |
| 1288 | + typeList: [ARGUMENT_TYPE.STRING], |
| 1289 | + isRequired: true, |
| 1290 | + enumProvider: () => extensionNames.map(name => new SlashCommandEnumValue(name)), |
| 1291 | + forceEnum: true, |
| 1292 | + }), |
| 1293 | + ], |
| 1294 | + helpString: ` |
| 1295 | + <div> |
| 1296 | + Checks if a specified extension exists. |
| 1297 | + </div> |
| 1298 | + <div> |
| 1299 | + <strong>Example:</strong> |
| 1300 | + <ul> |
| 1301 | + <li> |
| 1302 | + <pre><code class="language-stscript">/extension-exists LALib</code></pre> |
| 1303 | + </li> |
| 1304 | + </ul> |
| 1305 | + </div> |
| 1306 | + `, |
| 1307 | + })); |
| 1241 | 1308 | |
| 1242 | 1309 | SlashCommandParser.addCommandObject(SlashCommand.fromProps({ |
| 1243 | 1310 | name: 'reload-page', |