mirror of
https://github.com/sern-handler/tools
synced 2026-06-05 17:06:57 +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);
|
||||
|
||||
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.');
|
||||
}
|
||||
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;
|
||||
};
|
||||
|
||||
@@ -88,8 +82,8 @@ export class Publisher implements Init {
|
||||
contexts } = publish;
|
||||
return {
|
||||
name: module.name, type: applicationType,
|
||||
//@ts-ignore we know description is at least empty str or filled
|
||||
description: makeDescription(applicationType, module.description),
|
||||
//DO NOT IGNORE!
|
||||
description:(module.type == CommandType.CtxMsg || module.type == CommandType.CtxUser) ? '' : makeDescription(applicationType, module.description),
|
||||
//@ts-ignore shutup
|
||||
options: optionsTransformer(module?.options),
|
||||
default_member_permissions,
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@sern/publisher",
|
||||
"version": "1.1.4",
|
||||
"version": "1.1.5",
|
||||
"description": "Publish commands in sern with ease!",
|
||||
"main": "dist/index.js",
|
||||
"scripts": {
|
||||
@@ -9,8 +9,8 @@
|
||||
"test": "exit 0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@sern/handler": "^4.0.0",
|
||||
"discord.js": "^14.15.3",
|
||||
"@sern/handler": "^4.2.4",
|
||||
"discord.js": "^14.21.0",
|
||||
"vitest": "^1.2.2"
|
||||
},
|
||||
"keywords": [],
|
||||
|
||||
Reference in New Issue
Block a user