Fixed config checker bugs & added new flags
This commit is contained in:
@@ -80,9 +80,22 @@ The team behind Open Ticket!
|
||||
### ❤️ Sponsors
|
||||
A big thanks to all our sponsors! Without them, it wouldn't be possible to create this project!
|
||||
|
||||
|<img src="https://github.com/SpyEye2.png" alt="Profile Picture" width="80px"></img>|<img src="https://github.com/DOSEV5.png" alt="Profile Picture" width="80px"></img>|<img src="https://github.com/mods-hd.png" alt="Profile Picture" width="80px"></img>|
|
||||
|----|-|-|
|
||||
|**[SpyEye](https://github.com/SpyEye2)**|**[DOSEV5](https://github.com/DOSEV5)**|**[Mods HD](https://github.com/mods-hd)**|
|
||||
<table>
|
||||
<tr>
|
||||
<td><img src="https://github.com/DOSEV5.png" alt="Profile Picture" width="80px"></td>
|
||||
<td><img src="https://github.com/roppl3r.png" alt="Profile Picture" width="80px"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th><a href="https://github.com/DOSEV5">DOSEV5</a></th>
|
||||
<th><a href="https://github.com/roppl3r">roppl3r</a></th>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
**Past Sponsors:**<br>
|
||||
<a href="https://github.com/sponsors/DJj123dj">
|
||||
<img src="https://github.com/SpyEye2.png" alt="SpyEye" width="40px">
|
||||
<img src="https://github.com/mods-hd.png" alt="Mods HD" width="40px">
|
||||
</a>
|
||||
|
||||
### 💬 Translators
|
||||
|Language |Maintainer (discord name) |Status |
|
||||
|
||||
@@ -3,48 +3,48 @@ const fs = require("fs")
|
||||
const ts = require("typescript")
|
||||
const nodepath = require('path')
|
||||
|
||||
//REMOVE EXISTING BUILDS
|
||||
console.log("OT: Removing Prebuilds...")
|
||||
fs.rmSync("./dist",{recursive:true,force:true})
|
||||
if (!process.argv.includes("--no-compile")){
|
||||
//REMOVE EXISTING BUILDS
|
||||
console.log("OT: Removing Prebuilds...")
|
||||
fs.rmSync("./dist",{recursive:true,force:true})
|
||||
|
||||
//COMPILE TYPESCRIPT
|
||||
console.log("OT: Compiling Typescript...")
|
||||
const configPath = nodepath.resolve('./tsconfig.json')
|
||||
const configFile = ts.readConfigFile(configPath,ts.sys.readFile)
|
||||
//COMPILE TYPESCRIPT
|
||||
console.log("OT: Compiling Typescript...")
|
||||
const configPath = nodepath.resolve('./tsconfig.json')
|
||||
const configFile = ts.readConfigFile(configPath,ts.sys.readFile)
|
||||
|
||||
//check for tsconfig errors
|
||||
if (configFile.error){
|
||||
const message = ts.formatDiagnosticsWithColorAndContext([configFile.error],ts.createCompilerHost({}))
|
||||
console.error(message)
|
||||
process.exit(1)
|
||||
//check for tsconfig errors
|
||||
if (configFile.error){
|
||||
const message = ts.formatDiagnosticsWithColorAndContext([configFile.error],ts.createCompilerHost({}))
|
||||
console.error(message)
|
||||
process.exit(1)
|
||||
}
|
||||
|
||||
//parse tsconfig file
|
||||
const parsedConfig = ts.parseJsonConfigFileContent(configFile.config,ts.sys,nodepath.dirname(configPath))
|
||||
|
||||
//create program/compiler
|
||||
const program = ts.createProgram({
|
||||
rootNames:parsedConfig.fileNames,
|
||||
options:parsedConfig.options
|
||||
})
|
||||
|
||||
//emit all compiled files
|
||||
const emitResult = program.emit()
|
||||
|
||||
//print emit errors/warnings (type errors)
|
||||
const allDiagnostics = ts.getPreEmitDiagnostics(program).concat(emitResult.diagnostics)
|
||||
const formattedDiagnostics = ts.formatDiagnosticsWithColorAndContext(allDiagnostics, ts.createCompilerHost(parsedConfig.options))
|
||||
console.log(formattedDiagnostics)
|
||||
|
||||
if (emitResult.emitSkipped || allDiagnostics.find((d) => d.category == ts.DiagnosticCategory.Error || d.category == ts.DiagnosticCategory.Warning)){
|
||||
console.log("OT: Compilation Failed!")
|
||||
process.exit(1)
|
||||
}
|
||||
}
|
||||
|
||||
//parse tsconfig file
|
||||
const parsedConfig = ts.parseJsonConfigFileContent(configFile.config,ts.sys,nodepath.dirname(configPath))
|
||||
|
||||
//create program/compiler
|
||||
const program = ts.createProgram({
|
||||
rootNames:parsedConfig.fileNames,
|
||||
options:parsedConfig.options
|
||||
})
|
||||
|
||||
//emit all compiled files
|
||||
const emitResult = program.emit()
|
||||
|
||||
//print emit errors/warnings (type errors)
|
||||
const allDiagnostics = ts.getPreEmitDiagnostics(program).concat(emitResult.diagnostics)
|
||||
const formattedDiagnostics = ts.formatDiagnosticsWithColorAndContext(allDiagnostics, ts.createCompilerHost(parsedConfig.options))
|
||||
console.log(formattedDiagnostics)
|
||||
|
||||
//run with code
|
||||
if (emitResult.emitSkipped){
|
||||
console.log("OT: Compilation Failed!")
|
||||
process.exit(1)
|
||||
}else{
|
||||
console.log("OT: Compilation Succeeded!")
|
||||
if (process.argv.includes("-%-compile")) process.exit(0) //exit when only compile is required!
|
||||
|
||||
//START THE BOT
|
||||
console.log("OT: Starting Bot!")
|
||||
require("./dist/src/index.js")
|
||||
}
|
||||
//START BOT
|
||||
console.log("OT: Compilation Succeeded!")
|
||||
if (process.argv.includes("--compile-only")) process.exit(0) //exit when only compile is required!
|
||||
console.log("OT: Starting Bot!")
|
||||
require("./dist/src/index.js")
|
||||
@@ -345,6 +345,7 @@ export class ODCheckerTranslationRegister_Default extends ODCheckerTranslationRe
|
||||
*/
|
||||
export interface ODCheckerFunctionManagerIds_Default {
|
||||
"openticket:unused-options":ODCheckerFunction,
|
||||
"openticket:unused-questions":ODCheckerFunction,
|
||||
"openticket:dropdown-options":ODCheckerFunction
|
||||
}
|
||||
|
||||
@@ -355,14 +356,14 @@ export interface ODCheckerFunctionManagerIds_Default {
|
||||
* This default class is made for the global variable `openticket.checkers.functions`!
|
||||
*/
|
||||
export class ODCheckerFunctionManager_Default extends ODCheckerFunctionManager {
|
||||
get<CheckerFunctionId extends keyof ODCheckerManagerIds_Default>(id:CheckerFunctionId): ODCheckerManagerIds_Default[CheckerFunctionId]
|
||||
get<CheckerFunctionId extends keyof ODCheckerFunctionManagerIds_Default>(id:CheckerFunctionId): ODCheckerFunctionManagerIds_Default[CheckerFunctionId]
|
||||
get(id:ODValidId): ODCheckerFunction|null
|
||||
|
||||
get(id:ODValidId): ODCheckerFunction|null {
|
||||
return super.get(id)
|
||||
}
|
||||
|
||||
remove<CheckerFunctionId extends keyof ODCheckerManagerIds_Default>(id:CheckerFunctionId): ODCheckerManagerIds_Default[CheckerFunctionId]
|
||||
remove<CheckerFunctionId extends keyof ODCheckerFunctionManagerIds_Default>(id:CheckerFunctionId): ODCheckerFunctionManagerIds_Default[CheckerFunctionId]
|
||||
remove(id:ODValidId): ODCheckerFunction|null
|
||||
|
||||
remove(id:ODValidId): ODCheckerFunction|null {
|
||||
|
||||
@@ -21,6 +21,8 @@ export interface ODFlagManagerIds_Default {
|
||||
"openticket:no-plugins":ODFlag,
|
||||
"openticket:soft-plugins":ODFlag,
|
||||
"openticket:force-slash-update":ODFlag,
|
||||
"openticket:no-compile":ODFlag,
|
||||
"openticket:compile-only":ODFlag,
|
||||
}
|
||||
|
||||
/**## ODFlagManager_Default `default_class`
|
||||
|
||||
@@ -1192,12 +1192,20 @@ export class ODCheckerCustomStructure_EmojiString extends ODCheckerStringStructu
|
||||
const newOptions = options ?? {}
|
||||
newOptions.custom = (checker,value,locationTrace,locationId,locationDocs) => {
|
||||
const lt = checker.locationTraceDeref(locationTrace)
|
||||
|
||||
if (typeof value != "string") return false
|
||||
else if ([...value].length < minLength){
|
||||
|
||||
const emojis: string[] = []
|
||||
const emojiSplitRegex = /(?:(?:\u00a9|\u00ae|[\u2000-\u3300]|\ud83c[\ud000-\udfff]|\ud83d[\ud000-\udfff]|\ud83e[\ud000-\udfff])|(?:<a?:[^:]*:[0-9]+>))/g
|
||||
let emoji = emojiSplitRegex.exec(value)
|
||||
while (emoji != null){
|
||||
emojis.push(emoji[0])
|
||||
emoji = emojiSplitRegex.exec(value)
|
||||
}
|
||||
|
||||
if (emojis.length < minLength){
|
||||
checker.createMessage("openticket:emoji-too-short","error",`This string needs to have at least ${minLength} emoji's!`,lt,null,[maxLength.toString()],this.id,(this.options.docs ?? null))
|
||||
return false
|
||||
}else if ([...value].length > maxLength){
|
||||
}else if (emojis.length > maxLength){
|
||||
checker.createMessage("openticket:emoji-too-long","error",`This string needs to have at most ${maxLength} emoji's!`,lt,null,[maxLength.toString()],this.id,(this.options.docs ?? null))
|
||||
return false
|
||||
}else if (!allowCustomDiscordEmoji && /<a?:[^:]*:[0-9]+>/.test(value)){
|
||||
|
||||
@@ -12,6 +12,7 @@ export const loadAllConfigCheckers = async () => {
|
||||
|
||||
export const loadAllConfigCheckerFunctions = async () => {
|
||||
openticket.checkers.functions.add(new api.ODCheckerFunction("openticket:unused-options",defaultUnusedOptionsFunction))
|
||||
openticket.checkers.functions.add(new api.ODCheckerFunction("openticket:unused-questions",defaultUnusedQuestionsFunction))
|
||||
openticket.checkers.functions.add(new api.ODCheckerFunction("openticket:dropdown-options",defaultDropdownOptionsFunction))
|
||||
}
|
||||
|
||||
|
||||
@@ -13,4 +13,6 @@ export const loadAllFlags = async () => {
|
||||
openticket.flags.add(new api.ODFlag("openticket:no-plugins","No Plugins","Disable all Open Ticket plugins!","--no-plugins",["-np"]))
|
||||
openticket.flags.add(new api.ODFlag("openticket:soft-plugins","Soft Plugins","Don't crash the bot when a plugin crashes!","--soft-plugins",["-sp"]))
|
||||
openticket.flags.add(new api.ODFlag("openticket:force-slash-update","Force Slash Update","Force update all slash commands.","--force-slash",["-fs"]))
|
||||
openticket.flags.add(new api.ODFlag("openticket:no-compile","No Compile","Disable compilation of plugins & bot before starting.","--no-compile",[]))
|
||||
openticket.flags.add(new api.ODFlag("openticket:compile-only","Compile Only","This description will never be shown because the bot wouldn't run when this flag is enabled :)","--compile-only",[]))
|
||||
}
|
||||
Reference in New Issue
Block a user