meta files

This commit is contained in:
Erik 2024-03-22 22:14:59 +02:00
parent c325bf5ab4
commit 441d9ada97
12 changed files with 5804 additions and 1622 deletions

View File

@ -1,30 +1,60 @@
module.exports = {
{
"plugins": [
// "jest",
"@typescript-eslint"
],
"env": {
"es6": true,
"node": true
// "jest/globals": true
},
"extends": "eslint:recommended",
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/recommended"
],
"globals": {
"Atomics": "readonly",
"SharedArrayBuffer": "readonly"
"SharedArrayBuffer": "readonly",
"BigInt": true
},
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": 2020,
"ecmaVersion": 2022,
"sourceType": "module"
},
"rules": {
"@typescript-eslint/no-unused-vars": "off",
"@typescript-eslint/no-non-null-assertion": "off",
"accessor-pairs": "warn",
"array-callback-return": "warn",
"array-bracket-newline": [ "warn", "consistent" ],
"array-bracket-spacing": [ "warn", "always", { "objectsInArrays": false, "arraysInArrays": false }],
// "arrow-parens": "warn",
"array-bracket-newline": [
"warn",
"consistent"
],
"array-bracket-spacing": [
"warn",
"always",
{
"objectsInArrays": false,
"arraysInArrays": false
}
],
"arrow-spacing": "warn",
"block-scoped-var": "warn",
"block-spacing": [ "warn", "always" ],
"brace-style": [ "warn", "1tbs" ],
"block-spacing": [
"warn",
"always"
],
"brace-style": [
"warn",
"allman"
],
"callback-return": "warn",
"camelcase": "warn",
"comma-dangle": [ "warn", "only-multiline" ],
"comma-dangle": [
"warn",
"only-multiline"
],
"comma-spacing": [
"warn",
{
@ -52,7 +82,7 @@ module.exports = {
"warn",
"never"
],
"eqeqeq": "warn",
"eqeqeq": "error",
"func-call-spacing": "warn",
"func-name-matching": "warn",
"func-names": "warn",
@ -65,41 +95,80 @@ module.exports = {
"id-blacklist": "warn",
"id-match": "warn",
"implicit-arrow-linebreak": "warn",
"indent": "warn",
"indent": [
"warn",
4,
{
"SwitchCase": 1
}
],
"init-declarations": "warn",
"jsx-quotes": [ "warn", "prefer-single" ],
"key-spacing": [ "warn", { "beforeColon": false, "afterColon": true }],
"keyword-spacing": [ "warn", { "after": true, "before": true }],
"quotes": [
"error",
"single"
],
"jsx-quotes": [
"warn",
"prefer-single"
],
"key-spacing": [
"warn",
{
"beforeColon": false,
"afterColon": true
}
],
"keyword-spacing": [
"warn",
{
"after": true,
"before": true
}
],
"linebreak-style": [
"error",
"windows"
"unix"
],
"lines-around-comment": "warn",
"lines-around-directive": "warn",
"lines-between-class-members": [
"warn",
"always"
],
"max-classes-per-file": "warn",
"max-nested-callbacks": "warn",
"max-len": [
"warn",
{
"code": 140,
"ignoreComments": true,
"ignoreStrings": true,
"ignoreTemplateLiterals": true,
"ignoreRegExpLiterals": true
}
],
"max-lines-per-function": [
"warn",
140
],
"max-depth": [
"warn",
3
],
"new-parens": "warn",
"no-alert": "warn",
"no-array-constructor": "warn",
"no-bitwise": "warn",
// "no-bitwise": "warn",
"no-buffer-constructor": "warn",
"no-caller": "warn",
"no-console": "warn",
"no-constant-binary-expression": "error",
"no-div-regex": "warn",
"no-dupe-else-if": "warn",
"no-duplicate-imports": "warn",
"no-else-return": "warn",
"no-empty-function": "warn",
"no-eq-null": "warn",
"no-eq-null": "error",
"no-eval": "warn",
"no-extend-native": "warn",
"no-extra-bind": "warn",
"no-extra-label": "warn",
"no-extra-parens": "warn",
"no-floating-decimal": "warn",
"no-implicit-coercion": "warn",
"no-implicit-globals": "warn",
@ -108,7 +177,6 @@ module.exports = {
"no-invalid-this": "warn",
"no-iterator": "warn",
"no-label-var": "warn",
// "no-labels": "warn",
"no-lone-blocks": "warn",
"no-lonely-if": "warn",
"no-loop-func": "warn",
@ -135,23 +203,27 @@ module.exports = {
"no-restricted-modules": "warn",
"no-restricted-properties": "warn",
"no-restricted-syntax": "warn",
"no-return-assign": "warn",
"no-return-assign": [
"warn",
"except-parens"
],
"no-return-await": "warn",
"no-script-url": "warn",
"no-self-compare": "warn",
"no-sequences": "warn",
"no-setter-return": "warn",
"no-spaced-func": "warn",
"no-shadow": "error",
"@typescript-eslint/no-shadow": "error",
"no-tabs": "warn",
"no-template-curly-in-string": "error",
"no-throw-literal": "warn",
"no-trailing-spaces": "warn",
"no-undef-init": "error",
"no-undefined": "error",
"no-unmodified-loop-condition": "warn",
"no-unneeded-ternary": "error",
"no-unused-expressions": "warn",
"no-use-before-define": "error",
"@typescript-eslint/no-use-before-define": "error",
"no-useless-call": "warn",
"no-useless-computed-key": "warn",
"no-useless-concat": "warn",
@ -159,20 +231,39 @@ module.exports = {
"no-useless-rename": "warn",
"no-useless-return": "warn",
"no-var": "warn",
"no-void": "warn",
// "no-void": "warn",
"no-whitespace-before-property": "error",
"nonblock-statement-body-position": "warn",
"nonblock-statement-body-position": [
"warn",
"below"
],
"object-curly-spacing": [
"warn",
"always"
],
"object-property-newline": [ "warn", { "allowAllPropertiesOnSameLine": true }],
"object-property-newline": [
"warn",
{
"allowAllPropertiesOnSameLine": true
}
],
"object-shorthand": "warn",
"one-var-declaration-per-line": "warn",
"operator-assignment": "warn",
"operator-linebreak": [ "warn", "before" ],
"operator-linebreak": [
"warn",
"before"
],
"padding-line-between-statements": "warn",
"padded-blocks": [ "warn", { "switches": "never" }, { "allowSingleLineBlocks": true }],
"padded-blocks": [
"warn",
{
"switches": "never"
},
{
"allowSingleLineBlocks": true
}
],
"prefer-arrow-callback": "warn",
"prefer-const": "warn",
"prefer-destructuring": "warn",
@ -193,12 +284,18 @@ module.exports = {
"last"
],
"space-before-blocks": "warn",
"space-before-function-paren": [ "error", "always" ],
"space-before-function-paren": [
"error",
"always"
],
"space-in-parens": [
"warn",
"never"
],
"spaced-comment": [ "warn", "always" ],
"spaced-comment": [
"warn",
"always"
],
"strict": "warn",
"switch-colon-spacing": "warn",
"symbol-description": "warn",
@ -218,6 +315,16 @@ module.exports = {
"yoda": [
"warn",
"never"
],
"no-warning-comments": [
1,
{
"terms": [
"todo",
"fixme"
],
"location": "anywhere"
}
]
}
};
}

View File

@ -32,7 +32,7 @@ jobs:
strategy:
fail-fast: false
matrix:
language: [ 'javascript' ]
language: [ 'typescript' ]
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ]
# Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support

7
.gitignore vendored
View File

@ -1,5 +1,5 @@
# Env
config.js
config.ts
# Node bs
node_modules
@ -9,5 +9,8 @@ logs
modmail_cache
persistent_cache.json
canned_replies.json
config - server.js
config.js*
old.eslintrc.js
.yarn/install-state.gz
build

893
.yarn/releases/yarn-4.1.1.cjs vendored Normal file

File diff suppressed because one or more lines are too long

5
.yarnrc.yml Normal file
View File

@ -0,0 +1,5 @@
nodeLinker: node-modules
npmRegistryServer: "https://registry.corgi.wtf"
yarnPath: .yarn/releases/yarn-4.1.1.cjs

View File

@ -1,7 +1,11 @@
FROM node:lts-alpine3.12
FROM node:lts-alpine3.19
WORKDIR /modmail
COPY . .
RUN yarn install --production
COPY build build
COPY package.json package.json
COPY ./.yarnrc.yml ./.yarnrc.yml
COPY ./.yarn/releases ./.yarn/releases
RUN yarn install
VOLUME [ "/modmail/modmail_cache" ]
#ENTRYPOINT [ "/bin/ash" ]
CMD ["node", "index.js"]
# ENTRYPOINT [ "/bin/ash" ]
CMD ["node", "--enable-source-maps", "build/index.js"]
# CMD ["/bin/ash"]

View File

@ -1,42 +0,0 @@
// remove .example from the name to use this file, make sure to fill in the configs
module.exports = {
discordToken: '', // Discord bot token
galacticToken: '', // Token for Galactic's API for integration with Galactic Bot, not a thing yet
mainGuild: '', // main server of operation
bansGuild: '', // optional bans server for potential appeals processing
prefix: '!',
modmailCategory: [], // Should have 3 category IDs (AS STRINGS), main category (new), answered/waiting for reply, graveyard (old modmail channels getting ready for deletion)
context: 10, // How many messages to load for context
staffRoles: [], // Roles that have access to the bot commands
graveyardInactive: 60, // How long a channel should be inactive for in the graveyard before deletion
readInactive: 30, // How long a channel should be inactive for in the read category before moving to graveyard
channelSweepInterval: 10, // How often channel transitions should be processed in minutes
saveInterval: 1, // How often modmail history should be written to file in minutes
sudo: [], // Array of IDs (user or role) that have elevated access to the bot, i.e. eval, disable and any other elevated permission commands
anonColor: 0, // A colour value, 0 will default to the bot's highest coloured role
modmailReminderInterval: 10, // How often the bot should send a reminder of x new modmails in queue
modmailReminderChannel: '', // channel to send reminders in
logChannel: '', // Channel in which modmail logs are sent
inlineResponse: null, // The response the bot gives when a user DMs the bot, null will have the bot use the default
clientOptions: {
intents: [ // Needs at least these
'GUILDS',
'GUILD_MEMBERS',
'DIRECT_MESSAGES'
],
presence: { // Playing status
activity: {
name: 'DM to contact Server Staff',
type: 'PLAYING'
}
}
},
loggerOptions: { // This is for logging errors to a discord webhook
webhook: { // If you're not using the webhook, disable it
disabled: true,
id: '',
token: ''
}
}
};

41
config.example.jsonc Normal file
View File

@ -0,0 +1,41 @@
// remove .example from the name to use this file, make sure to fill in the configs
{
"discordToken": "", // Discord bot token
"galacticToken": "", // Token for Galactic"s API for integration with Galactic Bot, not a thing yet
"mainGuild": "", // main server of operation
"bansGuild": "", // optional bans server for potential appeals processing
"prefix": "!",
"modmailCategory": [], // Should have 3 category IDs (AS STRINGS), main category (new), answered/waiting for reply, graveyard (old modmail channels getting ready for deletion)
"context": 10, // How many messages to load for context
"staffRoles": [], // Roles that have access to the bot commands
"graveyardInactive": 60, // How long a channel should be inactive for in the graveyard before deletion
"readInactive": 30, // How long a channel should be inactive for in the read category before moving to graveyard
"channelSweepInterval": 10, // How often channel transitions should be processed in minutes
"saveInterval": 1, // How often modmail history should be written to file in minutes
"sudo": [], // Array of IDs (user or role) that have elevated access to the bot, i.e. eval, disable and any other elevated permission commands
"anonColor": 0, // A colour value, 0 will default to the bot"s highest coloured role
"modmailReminderInterval": 10, // How often the bot should send a reminder of x new modmails in queue
"modmailReminderChannel": "", // channel to send reminders in
"logChannel": "", // Channel in which modmail logs are sent
"inlineResponse": null, // The response the bot gives when a user DMs the bot, null will have the bot use the default
"clientOptions": {
"intents": [ // Needs at least these
"GUILDS",
"GUILD_MEMBERS",
"DIRECT_MESSAGES"
],
"presence": { // Playing status
"activity": {
"name": "DM to contact Server Staff",
"type": "PLAYING"
}
}
},
"loggerOptions": { // This is for logging errors to a discord webhook
"webhook": { // If you"re not using the webhook, disable it
"disabled": true,
"id": "",
"token": ""
}
}
}

View File

@ -4,23 +4,30 @@
"main": "index.js",
"author": "Navy <navydotgif@gmail.com>",
"license": "MIT",
"private": false,
"description": "Modmail bot with eventual integration with Galactic Bot's API",
"type": "module",
"scripts": {
"start": "node index.js",
"dev": "nodemon --ignore *.json index.js",
"dockerpub": "tsc && docker build . --tag navydotgif/modmail:latest && docker push navydotgif/modmail:latest "
"start": "yarn build && node --enable-source-maps build/index.js",
"build": "tsc --build",
"lint": "eslint src/ --fix",
"dev": "nodemon -e js --delay 5 --ignore *.json build/index.js",
"dockerpub": "docker build . --tag navydotgif/modmail:latest && docker push navydotgif/modmail:latest "
},
"devDependencies": {
"eslint": "^7.28.0",
"@babel/core": "^7.24.3",
"@babel/preset-env": "^7.24.3",
"@babel/preset-typescript": "^7.24.1",
"@typescript-eslint/eslint-plugin": "^7.3.1",
"@typescript-eslint/parser": "^7.3.1",
"eslint": "^8.57.0",
"eslint-plugin-node": "^11.1.0",
"nodemon": "^2.0.7"
},
"dependencies": {
"chalk": "^4.0.0",
"diagnostics": "^2.0.2",
"discord.js": "^12.5.3",
"@navy.gif/logger": "^2.5.4",
"discord.js": "^14.14.1",
"moment": "^2.29.4",
"winston": "^3.3.3",
"winston-transport": "^4.4.0"
}
"typescript": "^5.4.3"
},
"packageManager": "yarn@4.1.1"
}

115
tsconfig.json Normal file
View File

@ -0,0 +1,115 @@
{
"compilerOptions": {
// "watch": true,
/* Visit https://aka.ms/tsconfig to read more about this file */
/* Projects */
// "incremental": true, /* Save .tsbuildinfo files to allow for incremental compilation of projects. */
// "composite": true, /* Enable constraints that allow a TypeScript project to be used with project references. */
// "tsBuildInfoFile": "./.tsbuildinfo", /* Specify the path to .tsbuildinfo incremental compilation file. */
// "disableSourceOfProjectReferenceRedirect": true, /* Disable preferring source files instead of declaration files when referencing composite projects. */
// "disableSolutionSearching": true, /* Opt a project out of multi-project reference checking when editing. */
// "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */
/* Language and Environment */
"target": "ES2022", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */
"lib": ["ES2022"], /* Specify a set of bundled library declaration files that describe the target runtime environment. */
// "jsx": "preserve", /* Specify what JSX code is generated. */
// "experimentalDecorators": true, /* Enable experimental support for legacy experimental decorators. */
// "emitDecoratorMetadata": true, /* Emit design-type metadata for decorated declarations in source files. */
// "jsxFactory": "", /* Specify the JSX factory function used when targeting React JSX emit, e.g. 'React.createElement' or 'h'. */
// "jsxFragmentFactory": "", /* Specify the JSX Fragment reference used for fragments when targeting React JSX emit e.g. 'React.Fragment' or 'Fragment'. */
// "jsxImportSource": "", /* Specify module specifier used to import the JSX factory functions when using 'jsx: react-jsx*'. */
// "reactNamespace": "", /* Specify the object invoked for 'createElement'. This only applies when targeting 'react' JSX emit. */
// "noLib": true, /* Disable including any library files, including the default lib.d.ts. */
// "useDefineForClassFields": true, /* Emit ECMAScript-standard-compliant class fields. */
// "moduleDetection": "auto", /* Control what method is used to detect module-format JS files. */
/* Modules */
"module": "NodeNext", /* Specify what module code is generated. */
// "module": "AMD",
// "rootDir": "./", /* Specify the root folder within your source files. */
"moduleResolution": "nodenext", /* Specify how TypeScript looks up a file from a given module specifier. */
// "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */
// "paths": {}, /* Specify a set of entries that re-map imports to additional lookup locations. */
// "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */
"typeRoots": [
"./node_modules/@types",
"./@types/**"
], /* Specify multiple folders that act like './node_modules/@types'. */
// "types": [], /* Specify type package names to be included without being referenced in a source file. */
// "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
// "moduleSuffixes": [], /* List of file name suffixes to search when resolving a module. */
// "allowImportingTsExtensions": true, /* Allow imports to include TypeScript file extensions. Requires '--moduleResolution bundler' and either '--noEmit' or '--emitDeclarationOnly' to be set. */
// "resolvePackageJsonExports": true, /* Use the package.json 'exports' field when resolving package imports. */
// "resolvePackageJsonImports": true, /* Use the package.json 'imports' field when resolving imports. */
// "customConditions": [], /* Conditions to set in addition to the resolver-specific defaults when resolving imports. */
// "resolveJsonModule": true, /* Enable importing .json files. */
// "allowArbitraryExtensions": true, /* Enable importing files with any extension, provided a declaration file is present. */
// "noResolve": true, /* Disallow 'import's, 'require's or '<reference>'s from expanding the number of files TypeScript should add to a project. */
/* JavaScript Support */
"allowJs": false, /* Allow JavaScript files to be a part of your program. Use the 'checkJS' option to get errors from these files. */
// "checkJs": true, /* Enable error reporting in type-checked JavaScript files. */
// "maxNodeModuleJsDepth": 1, /* Specify the maximum folder depth used for checking JavaScript files from 'node_modules'. Only applicable with 'allowJs'. */
/* Emit */
// "declaration": true, /* Generate .d.ts files from TypeScript and JavaScript files in your project. */
// "declarationMap": true, /* Create sourcemaps for d.ts files. */
// "emitDeclarationOnly": true, /* Only output d.ts files and not JavaScript files. */
// "sourceMap": true, /* Create source map files for emitted JavaScript files. */
"inlineSourceMap": true, /* Include sourcemap files inside the emitted JavaScript. */
// "outFile": "./build/out-esm.js", /* Specify a file that bundles all outputs into one JavaScript file. If 'declaration' is true, also designates a file that bundles all .d.ts output. */
"outDir": "./build", /* Specify an output folder for all emitted files. */
"removeComments": true, /* Disable emitting comments. */
// "noEmit": true, /* Disable emitting files from a compilation. */
// "importHelpers": true, /* Allow importing helper functions from tslib once per project, instead of including them per-file. */
// "importsNotUsedAsValues": "remove", /* Specify emit/checking behavior for imports that are only used for types. */
// "downlevelIteration": true, /* Emit more compliant, but verbose and less performant JavaScript for iteration. */
// "sourceRoot": "", /* Specify the root path for debuggers to find the reference source code. */
// "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */
// "inlineSources": true, /* Include source code in the sourcemaps inside the emitted JavaScript. */
// "emitBOM": true, /* Emit a UTF-8 Byte Order Mark (BOM) in the beginning of output files. */
// "newLine": "crlf", /* Set the newline character for emitting files. */
"stripInternal": true, /* Disable emitting declarations that have '@internal' in their JSDoc comments. */
// "noEmitHelpers": true, /* Disable generating custom helper functions like '__extends' in compiled output. */
// "noEmitOnError": true, /* Disable emitting files if any type checking errors are reported. */
// "preserveConstEnums": true, /* Disable erasing 'const enum' declarations in generated code. */
// "declarationDir": "./", /* Specify the output directory for generated declaration files. */
// "preserveValueImports": true, /* Preserve unused imported values in the JavaScript output that would otherwise be removed. */
/* Interop Constraints */
// "isolatedModules": true, /* Ensure that each file can be safely transpiled without relying on other imports. */
// "verbatimModuleSyntax": true, /* Do not transform or elide any imports or exports not marked as type-only, ensuring they are written in the output file's format based on the 'module' setting. */
// "allowSyntheticDefaultImports": true, /* Allow 'import x from y' when a module doesn't have a default export. */
"esModuleInterop": true, /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */
// "preserveSymlinks": true, /* Disable resolving symlinks to their realpath. This correlates to the same flag in node. */
"forceConsistentCasingInFileNames": true, /* Ensure that casing is correct in imports. */
/* Type Checking */
"strict": true, /* Enable all strict type-checking options. */
"noImplicitAny": true, /* Enable error reporting for expressions and declarations with an implied 'any' type. */
// "strictNullChecks": true, /* When type checking, take into account 'null' and 'undefined'. */
"strictFunctionTypes": true, /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */
"strictBindCallApply": true, /* Check that the arguments for 'bind', 'call', and 'apply' methods match the original function. */
"strictPropertyInitialization": true, /* Check for class properties that are declared but not set in the constructor. */
"noImplicitThis": true, /* Enable error reporting when 'this' is given the type 'any'. */
// "useUnknownInCatchVariables": true, /* Default catch clause variables as 'unknown' instead of 'any'. */
"alwaysStrict": true, /* Ensure 'use strict' is always emitted. */
"noUnusedLocals": true, /* Enable error reporting when local variables aren't read. */
"noUnusedParameters": true, /* Raise an error when a function parameter isn't read. */
// "exactOptionalPropertyTypes": true, /* Interpret optional property types as written, rather than adding 'undefined'. */
"noImplicitReturns": true, /* Enable error reporting for codepaths that do not explicitly return in a function. */
"noFallthroughCasesInSwitch": true, /* Enable error reporting for fallthrough cases in switch statements. */
// "noUncheckedIndexedAccess": true, /* Add 'undefined' to a type when accessed using an index. */
"noImplicitOverride": true, /* Ensure overriding members in derived classes are marked with an override modifier. */
// "noPropertyAccessFromIndexSignature": true, /* Enforces using indexed accessors for keys declared using an indexed type. */
// "allowUnusedLabels": true, /* Disable error reporting for unused labels. */
// "allowUnreachableCode": true, /* Disable error reporting for unreachable code. */
/* Completeness */
// "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */
"skipLibCheck": true /* Skip type checking all .d.ts files. */
},
"compileOnSave": true
}

5505
yarn.lock

File diff suppressed because it is too large Load Diff