mirror of
https://github.com/sern-handler/tools
synced 2026-06-06 01:16:59 +00:00
fix: improve description validation and update dependencies
This commit is contained in:
@@ -18,15 +18,9 @@ const intoApplicationType = (type: number) =>
|
|||||||
type === 3 ? 1 : Math.log2(type);
|
type === 3 ? 1 : Math.log2(type);
|
||||||
|
|
||||||
const makeDescription = (type: number, desc: string) => {
|
const makeDescription = (type: number, desc: string) => {
|
||||||
if ((type == CommandType.Slash || type == CommandType.Both) && (!desc || desc.length === 0)) {
|
if ((type == CommandType.Slash || type == CommandType.Both) && !desc) {
|
||||||
throw new Error('Found application command that has no description field or is empty.');
|
throw new Error('Found application command that has no description field or is empty.');
|
||||||
}
|
}
|
||||||
if ((type == CommandType.CtxMsg || type == CommandType.CtxUser) && desc.length > 0) {
|
|
||||||
console.warn(
|
|
||||||
'Found context menu that has non empty description field. Implictly publishing with empty description.'
|
|
||||||
);
|
|
||||||
return '';
|
|
||||||
}
|
|
||||||
return desc;
|
return desc;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -88,8 +82,8 @@ export class Publisher implements Init {
|
|||||||
contexts } = publish;
|
contexts } = publish;
|
||||||
return {
|
return {
|
||||||
name: module.name, type: applicationType,
|
name: module.name, type: applicationType,
|
||||||
//@ts-ignore we know description is at least empty str or filled
|
//DO NOT IGNORE!
|
||||||
description: makeDescription(applicationType, module.description),
|
description:(module.type == CommandType.CtxMsg || module.type == CommandType.CtxUser) ? '' : makeDescription(applicationType, module.description),
|
||||||
//@ts-ignore shutup
|
//@ts-ignore shutup
|
||||||
options: optionsTransformer(module?.options),
|
options: optionsTransformer(module?.options),
|
||||||
default_member_permissions,
|
default_member_permissions,
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@sern/publisher",
|
"name": "@sern/publisher",
|
||||||
"version": "1.1.4",
|
"version": "1.1.5",
|
||||||
"description": "Publish commands in sern with ease!",
|
"description": "Publish commands in sern with ease!",
|
||||||
"main": "dist/index.js",
|
"main": "dist/index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
@@ -9,8 +9,8 @@
|
|||||||
"test": "exit 0"
|
"test": "exit 0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@sern/handler": "^4.0.0",
|
"@sern/handler": "^4.2.4",
|
||||||
"discord.js": "^14.15.3",
|
"discord.js": "^14.21.0",
|
||||||
"vitest": "^1.2.2"
|
"vitest": "^1.2.2"
|
||||||
},
|
},
|
||||||
"keywords": [],
|
"keywords": [],
|
||||||
|
|||||||
Reference in New Issue
Block a user