mirror of https://github.com/vizality/vizality
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
55 lines
1.3 KiB
55 lines
1.3 KiB
import { toPlural, toTitleCase } from '@vizality/util/string';
|
|
|
|
export default {
|
|
command: 'uninstall',
|
|
description: 'Uninstalls an addon.',
|
|
options: [
|
|
{ name: 'id', required: true }
|
|
],
|
|
async executor (args, type) {
|
|
let result;
|
|
|
|
if (!args || !args.length) {
|
|
return {
|
|
send: false,
|
|
result: `You must specify a ${type} to uninstall.`
|
|
};
|
|
}
|
|
|
|
if (vizality.manager[toPlural(type)].isInstalled(args[0])) {
|
|
try {
|
|
return vizality.manager[toPlural(type)].uninstall(args[0]);
|
|
} catch (err) {
|
|
result = err;
|
|
}
|
|
} else {
|
|
result = `${toTitleCase(type)} \`${args[0]}\` is not installed.`;
|
|
}
|
|
|
|
return {
|
|
send: false,
|
|
result
|
|
};
|
|
},
|
|
autocomplete (args, type) {
|
|
if (args.length > 1) return false;
|
|
|
|
const addons =
|
|
vizality.manager[toPlural(type)].keys
|
|
.sort((a, b) => a - b)
|
|
.map(plugin => vizality.manager[toPlural(type)].get(plugin));
|
|
|
|
return {
|
|
commands:
|
|
addons
|
|
.filter(addon => addon?.addonId.includes(args[0]))
|
|
.map(addon => ({
|
|
command: addon.addonId,
|
|
description: addon.manifest.description,
|
|
icon: addon.manifest.icon,
|
|
source: addon.manifest.name
|
|
}))
|
|
};
|
|
}
|
|
};
|