chore: removed the goddamn motherfucking pnp features
This commit is contained in:
parent
8bb2dc16b1
commit
82d66ffbe8
24 changed files with 426 additions and 1471 deletions
|
@ -47,7 +47,13 @@
|
||||||
<option name="HTML_DO_NOT_INDENT_CHILDREN_OF" value="" />
|
<option name="HTML_DO_NOT_INDENT_CHILDREN_OF" value="" />
|
||||||
</HTMLCodeStyleSettings>
|
</HTMLCodeStyleSettings>
|
||||||
<JSCodeStyleSettings version="0">
|
<JSCodeStyleSettings version="0">
|
||||||
|
<option name="FORCE_SEMICOLON_STYLE" value="true" />
|
||||||
<option name="SPACE_BEFORE_FUNCTION_LEFT_PARENTH" value="false" />
|
<option name="SPACE_BEFORE_FUNCTION_LEFT_PARENTH" value="false" />
|
||||||
|
<option name="USE_DOUBLE_QUOTES" value="false" />
|
||||||
|
<option name="FORCE_QUOTE_STYlE" value="true" />
|
||||||
|
<option name="ENFORCE_TRAILING_COMMA" value="WhenMultiline" />
|
||||||
|
<option name="SPACES_WITHIN_OBJECT_LITERAL_BRACES" value="true" />
|
||||||
|
<option name="SPACES_WITHIN_IMPORTS" value="true" />
|
||||||
</JSCodeStyleSettings>
|
</JSCodeStyleSettings>
|
||||||
<Markdown>
|
<Markdown>
|
||||||
<option name="MAX_LINES_AROUND_HEADER" value="0" />
|
<option name="MAX_LINES_AROUND_HEADER" value="0" />
|
||||||
|
@ -61,9 +67,15 @@
|
||||||
<option name="ENFORCE_QUOTES_ON_FORMAT" value="true" />
|
<option name="ENFORCE_QUOTES_ON_FORMAT" value="true" />
|
||||||
</ScssCodeStyleSettings>
|
</ScssCodeStyleSettings>
|
||||||
<TypeScriptCodeStyleSettings version="0">
|
<TypeScriptCodeStyleSettings version="0">
|
||||||
|
<option name="FORCE_SEMICOLON_STYLE" value="true" />
|
||||||
<option name="SPACE_BEFORE_FUNCTION_LEFT_PARENTH" value="false" />
|
<option name="SPACE_BEFORE_FUNCTION_LEFT_PARENTH" value="false" />
|
||||||
<option name="USE_PUBLIC_MODIFIER" value="true" />
|
<option name="USE_PUBLIC_MODIFIER" value="true" />
|
||||||
<option name="PREFER_AS_TYPE_CAST" value="true" />
|
<option name="PREFER_AS_TYPE_CAST" value="true" />
|
||||||
|
<option name="USE_DOUBLE_QUOTES" value="false" />
|
||||||
|
<option name="FORCE_QUOTE_STYlE" value="true" />
|
||||||
|
<option name="ENFORCE_TRAILING_COMMA" value="WhenMultiline" />
|
||||||
|
<option name="SPACES_WITHIN_OBJECT_LITERAL_BRACES" value="true" />
|
||||||
|
<option name="SPACES_WITHIN_IMPORTS" value="true" />
|
||||||
<option name="IMPORT_SORT_MODULE_NAME" value="true" />
|
<option name="IMPORT_SORT_MODULE_NAME" value="true" />
|
||||||
</TypeScriptCodeStyleSettings>
|
</TypeScriptCodeStyleSettings>
|
||||||
<codeStyleSettings language="CSS">
|
<codeStyleSettings language="CSS">
|
||||||
|
@ -105,8 +117,9 @@
|
||||||
</indentOptions>
|
</indentOptions>
|
||||||
</codeStyleSettings>
|
</codeStyleSettings>
|
||||||
<codeStyleSettings language="JavaScript">
|
<codeStyleSettings language="JavaScript">
|
||||||
|
<option name="ALIGN_MULTILINE_PARAMETERS" value="false" />
|
||||||
|
<option name="ALIGN_MULTILINE_FOR" value="false" />
|
||||||
<option name="SPACE_BEFORE_IF_PARENTHESES" value="false" />
|
<option name="SPACE_BEFORE_IF_PARENTHESES" value="false" />
|
||||||
<option name="SPACE_BEFORE_WHILE_PARENTHESES" value="false" />
|
|
||||||
<option name="SPACE_BEFORE_FOR_PARENTHESES" value="false" />
|
<option name="SPACE_BEFORE_FOR_PARENTHESES" value="false" />
|
||||||
<option name="SPACE_BEFORE_CATCH_PARENTHESES" value="false" />
|
<option name="SPACE_BEFORE_CATCH_PARENTHESES" value="false" />
|
||||||
<option name="SPACE_BEFORE_SWITCH_PARENTHESES" value="false" />
|
<option name="SPACE_BEFORE_SWITCH_PARENTHESES" value="false" />
|
||||||
|
@ -156,8 +169,9 @@
|
||||||
</arrangement>
|
</arrangement>
|
||||||
</codeStyleSettings>
|
</codeStyleSettings>
|
||||||
<codeStyleSettings language="TypeScript">
|
<codeStyleSettings language="TypeScript">
|
||||||
|
<option name="ALIGN_MULTILINE_PARAMETERS" value="false" />
|
||||||
|
<option name="ALIGN_MULTILINE_FOR" value="false" />
|
||||||
<option name="SPACE_BEFORE_IF_PARENTHESES" value="false" />
|
<option name="SPACE_BEFORE_IF_PARENTHESES" value="false" />
|
||||||
<option name="SPACE_BEFORE_WHILE_PARENTHESES" value="false" />
|
|
||||||
<option name="SPACE_BEFORE_FOR_PARENTHESES" value="false" />
|
<option name="SPACE_BEFORE_FOR_PARENTHESES" value="false" />
|
||||||
<option name="SPACE_BEFORE_CATCH_PARENTHESES" value="false" />
|
<option name="SPACE_BEFORE_CATCH_PARENTHESES" value="false" />
|
||||||
<option name="SPACE_BEFORE_SWITCH_PARENTHESES" value="false" />
|
<option name="SPACE_BEFORE_SWITCH_PARENTHESES" value="false" />
|
||||||
|
|
2
.vscode/extensions.json
vendored
2
.vscode/extensions.json
vendored
|
@ -3,4 +3,4 @@
|
||||||
"arcanis.vscode-zipfs",
|
"arcanis.vscode-zipfs",
|
||||||
"dbaeumer.vscode-eslint"
|
"dbaeumer.vscode-eslint"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
5
.vscode/settings.json
vendored
5
.vscode/settings.json
vendored
|
@ -1,13 +1,10 @@
|
||||||
{
|
{
|
||||||
"search.exclude": {
|
"search.exclude": {
|
||||||
"**/.yarn": true,
|
"**/.yarn": true,
|
||||||
"**/.pnp.*": true
|
|
||||||
},
|
},
|
||||||
"eslint.nodePath": ".yarn/sdks",
|
|
||||||
"editor.formatOnPaste": true,
|
"editor.formatOnPaste": true,
|
||||||
"editor.formatOnSave": true,
|
"editor.formatOnSave": true,
|
||||||
"editor.formatOnType": true,
|
"editor.formatOnType": true,
|
||||||
"typescript.tsdk": ".yarn/sdks/typescript/lib",
|
|
||||||
"typescript.enablePromptUseWorkspaceTsdk": true,
|
"typescript.enablePromptUseWorkspaceTsdk": true,
|
||||||
"eslint.format.enable": true,
|
"eslint.format.enable": true,
|
||||||
"eslint.lintTask.enable": true,
|
"eslint.lintTask.enable": true,
|
||||||
|
@ -15,4 +12,4 @@
|
||||||
"editor.insertSpaces": false,
|
"editor.insertSpaces": false,
|
||||||
"editor.tabSize": 2,
|
"editor.tabSize": 2,
|
||||||
"typescript.preferences.quoteStyle": "single"
|
"typescript.preferences.quoteStyle": "single"
|
||||||
}
|
}
|
||||||
|
|
398
.yarn/plugins/@yarnpkg/plugin-interactive-tools.cjs
vendored
398
.yarn/plugins/@yarnpkg/plugin-interactive-tools.cjs
vendored
File diff suppressed because one or more lines are too long
5
.yarn/plugins/@yarnpkg/plugin-typescript.cjs
vendored
5
.yarn/plugins/@yarnpkg/plugin-typescript.cjs
vendored
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
274
.yarn/releases/yarn-sources.cjs
vendored
274
.yarn/releases/yarn-sources.cjs
vendored
File diff suppressed because one or more lines are too long
20
.yarn/sdks/eslint/lib/api.js
vendored
20
.yarn/sdks/eslint/lib/api.js
vendored
|
@ -1,20 +0,0 @@
|
||||||
#!/usr/bin/env node
|
|
||||||
|
|
||||||
const {existsSync} = require(`fs`);
|
|
||||||
const {createRequire, createRequireFromPath} = require(`module`);
|
|
||||||
const {resolve} = require(`path`);
|
|
||||||
|
|
||||||
const relPnpApiPath = "../../../../.pnp.cjs";
|
|
||||||
|
|
||||||
const absPnpApiPath = resolve(__dirname, relPnpApiPath);
|
|
||||||
const absRequire = (createRequire || createRequireFromPath)(absPnpApiPath);
|
|
||||||
|
|
||||||
if (existsSync(absPnpApiPath)) {
|
|
||||||
if (!process.versions.pnp) {
|
|
||||||
// Setup the environment to be able to require eslint/lib/api.js
|
|
||||||
require(absPnpApiPath).setup();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Defer to the real eslint/lib/api.js your application uses
|
|
||||||
module.exports = absRequire(`eslint/lib/api.js`);
|
|
6
.yarn/sdks/eslint/package.json
vendored
6
.yarn/sdks/eslint/package.json
vendored
|
@ -1,6 +0,0 @@
|
||||||
{
|
|
||||||
"name": "eslint",
|
|
||||||
"version": "7.28.0-pnpify",
|
|
||||||
"main": "./lib/api.js",
|
|
||||||
"type": "commonjs"
|
|
||||||
}
|
|
5
.yarn/sdks/integrations.yml
vendored
5
.yarn/sdks/integrations.yml
vendored
|
@ -1,5 +0,0 @@
|
||||||
# This file is automatically generated by PnPify.
|
|
||||||
# Manual changes will be lost!
|
|
||||||
|
|
||||||
integrations:
|
|
||||||
- vscode
|
|
20
.yarn/sdks/typescript/lib/tsc.js
vendored
20
.yarn/sdks/typescript/lib/tsc.js
vendored
|
@ -1,20 +0,0 @@
|
||||||
#!/usr/bin/env node
|
|
||||||
|
|
||||||
const {existsSync} = require(`fs`);
|
|
||||||
const {createRequire, createRequireFromPath} = require(`module`);
|
|
||||||
const {resolve} = require(`path`);
|
|
||||||
|
|
||||||
const relPnpApiPath = "../../../../.pnp.cjs";
|
|
||||||
|
|
||||||
const absPnpApiPath = resolve(__dirname, relPnpApiPath);
|
|
||||||
const absRequire = (createRequire || createRequireFromPath)(absPnpApiPath);
|
|
||||||
|
|
||||||
if (existsSync(absPnpApiPath)) {
|
|
||||||
if (!process.versions.pnp) {
|
|
||||||
// Setup the environment to be able to require typescript/lib/tsc.js
|
|
||||||
require(absPnpApiPath).setup();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Defer to the real typescript/lib/tsc.js your application uses
|
|
||||||
module.exports = absRequire(`typescript/lib/tsc.js`);
|
|
143
.yarn/sdks/typescript/lib/tsserver.js
vendored
143
.yarn/sdks/typescript/lib/tsserver.js
vendored
|
@ -1,143 +0,0 @@
|
||||||
#!/usr/bin/env node
|
|
||||||
|
|
||||||
const {existsSync} = require(`fs`);
|
|
||||||
const {createRequire, createRequireFromPath} = require(`module`);
|
|
||||||
const {resolve} = require(`path`);
|
|
||||||
|
|
||||||
const relPnpApiPath = "../../../../.pnp.cjs";
|
|
||||||
|
|
||||||
const absPnpApiPath = resolve(__dirname, relPnpApiPath);
|
|
||||||
const absRequire = (createRequire || createRequireFromPath)(absPnpApiPath);
|
|
||||||
|
|
||||||
const moduleWrapper = tsserver => {
|
|
||||||
const {isAbsolute} = require(`path`);
|
|
||||||
const pnpApi = require(`pnpapi`);
|
|
||||||
|
|
||||||
const isVirtual = str => str.match(/\/(\$\$virtual|__virtual__)\//);
|
|
||||||
const normalize = str => str.replace(/\\/g, `/`).replace(/^\/?/, `/`);
|
|
||||||
|
|
||||||
const dependencyTreeRoots = new Set(pnpApi.getDependencyTreeRoots().map(locator => {
|
|
||||||
return `${locator.name}@${locator.reference}`;
|
|
||||||
}));
|
|
||||||
|
|
||||||
// VSCode sends the zip paths to TS using the "zip://" prefix, that TS
|
|
||||||
// doesn't understand. This layer makes sure to remove the protocol
|
|
||||||
// before forwarding it to TS, and to add it back on all returned paths.
|
|
||||||
|
|
||||||
function toEditorPath(str) {
|
|
||||||
// We add the `zip:` prefix to both `.zip/` paths and virtual paths
|
|
||||||
if (isAbsolute(str) && !str.match(/^\^zip:/) && (str.match(/\.zip\//) || isVirtual(str))) {
|
|
||||||
// We also take the opportunity to turn virtual paths into physical ones;
|
|
||||||
// this makes it much easier to work with workspaces that list peer
|
|
||||||
// dependencies, since otherwise Ctrl+Click would bring us to the virtual
|
|
||||||
// file instances instead of the real ones.
|
|
||||||
//
|
|
||||||
// We only do this to modules owned by the the dependency tree roots.
|
|
||||||
// This avoids breaking the resolution when jumping inside a vendor
|
|
||||||
// with peer dep (otherwise jumping into react-dom would show resolution
|
|
||||||
// errors on react).
|
|
||||||
//
|
|
||||||
const resolved = isVirtual(str) ? pnpApi.resolveVirtual(str) : str;
|
|
||||||
if (resolved) {
|
|
||||||
const locator = pnpApi.findPackageLocator(resolved);
|
|
||||||
if (locator && dependencyTreeRoots.has(`${locator.name}@${locator.reference}`)) {
|
|
||||||
str = resolved;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
str = normalize(str);
|
|
||||||
|
|
||||||
if (str.match(/\.zip\//)) {
|
|
||||||
switch (hostInfo) {
|
|
||||||
// Absolute VSCode `Uri.fsPath`s need to start with a slash.
|
|
||||||
// VSCode only adds it automatically for supported schemes,
|
|
||||||
// so we have to do it manually for the `zip` scheme.
|
|
||||||
// The path needs to start with a caret otherwise VSCode doesn't handle the protocol
|
|
||||||
//
|
|
||||||
// Ref: https://github.com/microsoft/vscode/issues/105014#issuecomment-686760910
|
|
||||||
//
|
|
||||||
case `vscode`: {
|
|
||||||
str = `^zip:${str}`;
|
|
||||||
} break;
|
|
||||||
|
|
||||||
// To make "go to definition" work,
|
|
||||||
// We have to resolve the actual file system path from virtual path
|
|
||||||
// and convert scheme to supported by [vim-rzip](https://github.com/lbrayner/vim-rzip)
|
|
||||||
case `coc-nvim`: {
|
|
||||||
str = normalize(resolved).replace(/\.zip\//, `.zip::`);
|
|
||||||
str = resolve(`zipfile:${str}`);
|
|
||||||
} break;
|
|
||||||
|
|
||||||
default: {
|
|
||||||
str = `zip:${str}`;
|
|
||||||
} break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return str;
|
|
||||||
}
|
|
||||||
|
|
||||||
function fromEditorPath(str) {
|
|
||||||
return process.platform === `win32`
|
|
||||||
? str.replace(/^\^?zip:\//, ``)
|
|
||||||
: str.replace(/^\^?zip:/, ``);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Force enable 'allowLocalPluginLoads'
|
|
||||||
// TypeScript tries to resolve plugins using a path relative to itself
|
|
||||||
// which doesn't work when using the global cache
|
|
||||||
// https://github.com/microsoft/TypeScript/blob/1b57a0395e0bff191581c9606aab92832001de62/src/server/project.ts#L2238
|
|
||||||
// VSCode doesn't want to enable 'allowLocalPluginLoads' due to security concerns but
|
|
||||||
// TypeScript already does local loads and if this code is running the user trusts the workspace
|
|
||||||
// https://github.com/microsoft/vscode/issues/45856
|
|
||||||
const ConfiguredProject = tsserver.server.ConfiguredProject;
|
|
||||||
const {enablePluginsWithOptions: originalEnablePluginsWithOptions} = ConfiguredProject.prototype;
|
|
||||||
ConfiguredProject.prototype.enablePluginsWithOptions = function() {
|
|
||||||
this.projectService.allowLocalPluginLoads = true;
|
|
||||||
return originalEnablePluginsWithOptions.apply(this, arguments);
|
|
||||||
};
|
|
||||||
|
|
||||||
// And here is the point where we hijack the VSCode <-> TS communications
|
|
||||||
// by adding ourselves in the middle. We locate everything that looks
|
|
||||||
// like an absolute path of ours and normalize it.
|
|
||||||
|
|
||||||
const Session = tsserver.server.Session;
|
|
||||||
const {onMessage: originalOnMessage, send: originalSend} = Session.prototype;
|
|
||||||
let hostInfo = `unknown`;
|
|
||||||
|
|
||||||
return Object.assign(Session.prototype, {
|
|
||||||
onMessage(/** @type {string} */ message) {
|
|
||||||
const parsedMessage = JSON.parse(message)
|
|
||||||
|
|
||||||
if (
|
|
||||||
parsedMessage != null &&
|
|
||||||
typeof parsedMessage === `object` &&
|
|
||||||
parsedMessage.arguments &&
|
|
||||||
typeof parsedMessage.arguments.hostInfo === `string`
|
|
||||||
) {
|
|
||||||
hostInfo = parsedMessage.arguments.hostInfo;
|
|
||||||
}
|
|
||||||
|
|
||||||
return originalOnMessage.call(this, JSON.stringify(parsedMessage, (key, value) => {
|
|
||||||
return typeof value === `string` ? fromEditorPath(value) : value;
|
|
||||||
}));
|
|
||||||
},
|
|
||||||
|
|
||||||
send(/** @type {any} */ msg) {
|
|
||||||
return originalSend.call(this, JSON.parse(JSON.stringify(msg, (key, value) => {
|
|
||||||
return typeof value === `string` ? toEditorPath(value) : value;
|
|
||||||
})));
|
|
||||||
}
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
if (existsSync(absPnpApiPath)) {
|
|
||||||
if (!process.versions.pnp) {
|
|
||||||
// Setup the environment to be able to require typescript/lib/tsserver.js
|
|
||||||
require(absPnpApiPath).setup();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Defer to the real typescript/lib/tsserver.js your application uses
|
|
||||||
module.exports = moduleWrapper(absRequire(`typescript/lib/tsserver.js`));
|
|
20
.yarn/sdks/typescript/lib/typescript.js
vendored
20
.yarn/sdks/typescript/lib/typescript.js
vendored
|
@ -1,20 +0,0 @@
|
||||||
#!/usr/bin/env node
|
|
||||||
|
|
||||||
const {existsSync} = require(`fs`);
|
|
||||||
const {createRequire, createRequireFromPath} = require(`module`);
|
|
||||||
const {resolve} = require(`path`);
|
|
||||||
|
|
||||||
const relPnpApiPath = "../../../../.pnp.cjs";
|
|
||||||
|
|
||||||
const absPnpApiPath = resolve(__dirname, relPnpApiPath);
|
|
||||||
const absRequire = (createRequire || createRequireFromPath)(absPnpApiPath);
|
|
||||||
|
|
||||||
if (existsSync(absPnpApiPath)) {
|
|
||||||
if (!process.versions.pnp) {
|
|
||||||
// Setup the environment to be able to require typescript/lib/typescript.js
|
|
||||||
require(absPnpApiPath).setup();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Defer to the real typescript/lib/typescript.js your application uses
|
|
||||||
module.exports = absRequire(`typescript/lib/typescript.js`);
|
|
6
.yarn/sdks/typescript/package.json
vendored
6
.yarn/sdks/typescript/package.json
vendored
|
@ -1,6 +0,0 @@
|
||||||
{
|
|
||||||
"name": "typescript",
|
|
||||||
"version": "4.3.3-pnpify",
|
|
||||||
"main": "./lib/typescript.js",
|
|
||||||
"type": "commonjs"
|
|
||||||
}
|
|
|
@ -1,9 +1,11 @@
|
||||||
plugins:
|
plugins:
|
||||||
|
- path: .yarn/plugins/@yarnpkg/plugin-typescript.cjs
|
||||||
|
spec: "@yarnpkg/plugin-typescript"
|
||||||
- path: .yarn/plugins/@yarnpkg/plugin-interactive-tools.cjs
|
- path: .yarn/plugins/@yarnpkg/plugin-interactive-tools.cjs
|
||||||
spec: "@yarnpkg/plugin-interactive-tools"
|
spec: "@yarnpkg/plugin-interactive-tools"
|
||||||
- path: .yarn/plugins/@yarnpkg/plugin-workspace-tools.cjs
|
- path: .yarn/plugins/@yarnpkg/plugin-workspace-tools.cjs
|
||||||
spec: "@yarnpkg/plugin-workspace-tools"
|
spec: "@yarnpkg/plugin-workspace-tools"
|
||||||
- path: .yarn/plugins/@yarnpkg/plugin-typescript.cjs
|
|
||||||
spec: "@yarnpkg/plugin-typescript"
|
|
||||||
|
|
||||||
yarnPath: .yarn/releases/yarn-sources.cjs
|
yarnPath: .yarn/releases/yarn-sources.cjs
|
||||||
|
|
||||||
|
nodeLinker: node-modules
|
||||||
|
|
|
@ -81,7 +81,6 @@
|
||||||
"@typescript-eslint/eslint-plugin": "^4.28.1",
|
"@typescript-eslint/eslint-plugin": "^4.28.1",
|
||||||
"@typescript-eslint/parser": "^4.28.1",
|
"@typescript-eslint/parser": "^4.28.1",
|
||||||
"@typescript-eslint/typescript-estree": "^4.28.1",
|
"@typescript-eslint/typescript-estree": "^4.28.1",
|
||||||
"@yarnpkg/pnpify": "^3.0.0-rc.7",
|
|
||||||
"chai": "^4.3.4",
|
"chai": "^4.3.4",
|
||||||
"eslint": "^7.29.0",
|
"eslint": "^7.29.0",
|
||||||
"eslint-formatter-pretty": "^4.1.0",
|
"eslint-formatter-pretty": "^4.1.0",
|
||||||
|
|
58
src/commands/general/help.ts
Normal file
58
src/commands/general/help.ts
Normal file
|
@ -0,0 +1,58 @@
|
||||||
|
/*
|
||||||
|
* This file is part of ArgonBot
|
||||||
|
*
|
||||||
|
* ArgonBot is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* ArgonBot is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with ArgonBot. If not, see <https: //www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
import Command from '@structures/command';
|
||||||
|
import { Client, Message, MessageEmbed } from 'discord.js';
|
||||||
|
import i18next from 'i18next';
|
||||||
|
import path from 'path';
|
||||||
|
|
||||||
|
export default class extends Command {
|
||||||
|
public constructor(client: Client, file: string) {
|
||||||
|
super(client, file, {
|
||||||
|
shortDescription: i18next.t('commands:help.shortDescription'),
|
||||||
|
extendedDescription: i18next.t('commands:help.extendedDescription'),
|
||||||
|
args: [
|
||||||
|
{
|
||||||
|
name: 'command',
|
||||||
|
description: i18next.t('commands:help.commandArg'),
|
||||||
|
optional: true,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public async run(message: Message, command: string): Promise<void> {
|
||||||
|
if(!command) {
|
||||||
|
const commandGroups: { name: string; embeds: MessageEmbed, commands: Command[] }[] = [];
|
||||||
|
|
||||||
|
this.client.commands.forEach((command) => {
|
||||||
|
const findCommand = commandGroups.find((val) => val.name === command.options.group);
|
||||||
|
|
||||||
|
if(findCommand) {
|
||||||
|
findCommand.commands.push(command);
|
||||||
|
} else {
|
||||||
|
commandGroups.push({
|
||||||
|
name: command.options.group!,
|
||||||
|
embeds: new MessageEmbed(),
|
||||||
|
commands: [command],
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
console.log(path.basename(this.file));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -21,7 +21,7 @@ import i18next from 'i18next';
|
||||||
import { transpile } from 'typescript';
|
import { transpile } from 'typescript';
|
||||||
import { NodeVM } from 'vm2';
|
import { NodeVM } from 'vm2';
|
||||||
|
|
||||||
export class vm extends Command {
|
export default class extends Command {
|
||||||
public constructor(client: Client, file: string) {
|
public constructor(client: Client, file: string) {
|
||||||
super(client, file, {
|
super(client, file, {
|
||||||
shortDescription: i18next.t('commands:vm.shortDescription'),
|
shortDescription: i18next.t('commands:vm.shortDescription'),
|
||||||
|
@ -59,7 +59,7 @@ export class vm extends Command {
|
||||||
|
|
||||||
await message.reply(`\`\`\`js\n${returnVal}\`\`\``);
|
await message.reply(`\`\`\`js\n${returnVal}\`\`\``);
|
||||||
} catch(err) {
|
} catch(err) {
|
||||||
await message.reply(i18next.t('commands:vm.error', { error: err.message }));
|
await message.reply(i18next.t('commands:vm.error', { error: err.message, language: 'JavaScript' }));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'ts':
|
case 'ts':
|
||||||
|
@ -77,7 +77,7 @@ export class vm extends Command {
|
||||||
|
|
||||||
await message.reply(`\`\`\`js\n${returnVal}\`\`\``);
|
await message.reply(`\`\`\`js\n${returnVal}\`\`\``);
|
||||||
} catch(err) {
|
} catch(err) {
|
||||||
await message.reply(i18next.t('commands:vm.error', { error: err.message }));
|
await message.reply(i18next.t('commands:vm.error', { error: err.message, language: 'TypeScript' }));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
|
20
src/index.ts
20
src/index.ts
|
@ -14,16 +14,15 @@
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with ArgonBot. If not, see <https: //www.gnu.org/licenses/>.
|
* along with ArgonBot. If not, see <https: //www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
require('module-alias/register');
|
import 'module-alias/register';
|
||||||
|
|
||||||
import type Command from '@structures/command';
|
import ArgonClient from '@lib/ArgonClient';
|
||||||
import { Defaults } from '@utils/defaults';
|
import { Defaults } from '@utils/defaults';
|
||||||
import { debug, error, fatal, info, verbose } from '@utils/logger';
|
import { debug, error, fatal, info, verbose } from '@utils/logger';
|
||||||
import { ECommandRunIn, ELoggingScope } from '@utils/types';
|
import { ECommandRunIn, ELoggingScope } from '@utils/types';
|
||||||
import { walkDir } from '@utils/utils';
|
import { walkDir } from '@utils/utils';
|
||||||
import chalk from 'chalk';
|
import chalk from 'chalk';
|
||||||
import config from 'config';
|
import config from 'config';
|
||||||
import { Client, Collection } from 'discord.js';
|
|
||||||
import figlet from 'figlet';
|
import figlet from 'figlet';
|
||||||
import gradient from 'gradient-string';
|
import gradient from 'gradient-string';
|
||||||
import i18next from 'i18next';
|
import i18next from 'i18next';
|
||||||
|
@ -38,7 +37,6 @@ import path from 'path';
|
||||||
import process from 'process';
|
import process from 'process';
|
||||||
|
|
||||||
let isBotReady = false;
|
let isBotReady = false;
|
||||||
const commands: Collection<string, Command> = new Collection();
|
|
||||||
|
|
||||||
info('Starting bot... Please wait!', ELoggingScope.Startup);
|
info('Starting bot... Please wait!', ELoggingScope.Startup);
|
||||||
debug('Checking config JSON schema', ELoggingScope.Startup);
|
debug('Checking config JSON schema', ELoggingScope.Startup);
|
||||||
|
@ -70,7 +68,7 @@ figlet('Argon Bot', (err, data) => {
|
||||||
info(gradient.rainbow.multiline(`\n${data}`), ELoggingScope.Startup);
|
info(gradient.rainbow.multiline(`\n${data}`), ELoggingScope.Startup);
|
||||||
});
|
});
|
||||||
|
|
||||||
const client = new Client({
|
const client = new ArgonClient({
|
||||||
intents: ['GUILDS', 'GUILD_MESSAGES'],
|
intents: ['GUILDS', 'GUILD_MESSAGES'],
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -83,11 +81,11 @@ client.on('message', async (msg) => {
|
||||||
const args = msg.content.slice((config.get('prefix') as string).length).trim().split(/ +/);
|
const args = msg.content.slice((config.get('prefix') as string).length).trim().split(/ +/);
|
||||||
const command = args.shift()!.toLowerCase();
|
const command = args.shift()!.toLowerCase();
|
||||||
|
|
||||||
const findCommand = commands.find((com) => com.options.name === command);
|
const findCommand = client.commands.find((com) => com.options.name === command);
|
||||||
|
|
||||||
if(!findCommand) return;
|
if(!findCommand) return;
|
||||||
|
|
||||||
await msg.channel.startTyping();
|
msg.channel.startTyping();
|
||||||
|
|
||||||
if(findCommand.options.ownerOnly && msg.author.id !== config.get('owner')) {
|
if(findCommand.options.ownerOnly && msg.author.id !== config.get('owner')) {
|
||||||
await msg.reply(i18next.t('commands:errors.ownerOnly'));
|
await msg.reply(i18next.t('commands:errors.ownerOnly'));
|
||||||
|
@ -105,7 +103,7 @@ client.on('message', async (msg) => {
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
info(`Command ${findCommand.options.name} is being ran in ${msg.guild ? msg.guild.name : 'DMs'}`, ELoggingScope.Command);
|
info(`Command ${findCommand.options.name} is being ran in ${msg.guild ? msg.guild.name : 'DMs'} by ${msg.author.username}`, ELoggingScope.Command);
|
||||||
await findCommand.run(msg, ...args);
|
await findCommand.run(msg, ...args);
|
||||||
info(`Finished running ${findCommand.options.name} in ${msg.guild ? msg.guild.name : `${msg.author.username} DMs`}`, ELoggingScope.Command);
|
info(`Finished running ${findCommand.options.name} in ${msg.guild ? msg.guild.name : `${msg.author.username} DMs`}`, ELoggingScope.Command);
|
||||||
msg.channel.stopTyping();
|
msg.channel.stopTyping();
|
||||||
|
@ -148,15 +146,15 @@ client.on('ready', async () => {
|
||||||
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
||||||
const fileCommand = require(file);
|
const fileCommand = require(file);
|
||||||
|
|
||||||
const command = new fileCommand[path.basename(file, path.extname(file))](client, path.basename(file, path.extname(file)));
|
const command = new fileCommand['default'](client, path.basename(file, path.extname(file)));
|
||||||
|
|
||||||
commands.set(command.options.name, command);
|
client.commands.set(command.options.name, command);
|
||||||
|
|
||||||
debug(`Loaded command ${command.options.name}`, ELoggingScope.Startup);
|
debug(`Loaded command ${command.options.name}`, ELoggingScope.Startup);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
info(`Finished loading commands! Found ${commands.size} commands.`, ELoggingScope.Startup);
|
info(`Finished loading commands! Found ${client.commands.size} commands.`, ELoggingScope.Startup);
|
||||||
} catch(err) {
|
} catch(err) {
|
||||||
fatal(`An error has occurred while attempting to load command files! Please see error below\n${err.message}`, ELoggingScope.Startup);
|
fatal(`An error has occurred while attempting to load command files! Please see error below\n${err.message}`, ELoggingScope.Startup);
|
||||||
}
|
}
|
||||||
|
|
26
src/lib/ArgonClient.ts
Normal file
26
src/lib/ArgonClient.ts
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
/*
|
||||||
|
* This file is part of ArgonBot
|
||||||
|
*
|
||||||
|
* ArgonBot is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* ArgonBot is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with ArgonBot. If not, see <https: //www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
import type Command from '@structures/command';
|
||||||
|
import { Client, ClientOptions, Collection } from 'discord.js';
|
||||||
|
|
||||||
|
export default class extends Client {
|
||||||
|
public readonly commands: Collection<string, Command> = new Collection();
|
||||||
|
|
||||||
|
public constructor(options: ClientOptions) {
|
||||||
|
super(options);
|
||||||
|
}
|
||||||
|
}
|
|
@ -31,7 +31,7 @@ export default abstract class Command {
|
||||||
|
|
||||||
const defaultOptions: ICommandOptions = {
|
const defaultOptions: ICommandOptions = {
|
||||||
name: path.basename(this.file, path.extname(this.file)),
|
name: path.basename(this.file, path.extname(this.file)),
|
||||||
group: path.basename(path.dirname(this.file)) === 'commands' ? '' : path.basename(path.dirname(this.file)),
|
group: path.dirname(this.file) === 'commands' ? '' : path.dirname(this.file),
|
||||||
ownerOnly: false,
|
ownerOnly: false,
|
||||||
runIn: ECommandRunIn.Both,
|
runIn: ECommandRunIn.Both,
|
||||||
shortDescription: '',
|
shortDescription: '',
|
||||||
|
|
16
src/lib/utils/augments.ts
Normal file
16
src/lib/utils/augments.ts
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
/*
|
||||||
|
* This file is part of ArgonBot
|
||||||
|
*
|
||||||
|
* ArgonBot is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* ArgonBot is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with ArgonBot. If not, see <https: //www.gnu.org/licenses/>.
|
||||||
|
*/
|
|
@ -5,9 +5,15 @@
|
||||||
"languageArg": "The language to use (JavaScript/TypeScript)",
|
"languageArg": "The language to use (JavaScript/TypeScript)",
|
||||||
"codeArg": "The code to run in the VM",
|
"codeArg": "The code to run in the VM",
|
||||||
"computing": "Computing { $language } code... Please wait!",
|
"computing": "Computing { $language } code... Please wait!",
|
||||||
"error": "An error has occurred while executing JavaScript code!\n```\n{ $error }\n```",
|
"error": "An error has occurred while executing { $language } code!\n```\n{ $error }\n```",
|
||||||
"unknown": "Unknown language given!"
|
"unknown": "Unknown language given!"
|
||||||
},
|
},
|
||||||
|
"help": {
|
||||||
|
"shortDescription": "Shows help menu",
|
||||||
|
"extendedDescription": "Shows an advanced help menu for commands to show usage",
|
||||||
|
"commandArg": "The command to see",
|
||||||
|
"unknownCommand": "Unknown command given!"
|
||||||
|
},
|
||||||
"errors": {
|
"errors": {
|
||||||
"ownerOnly": "Only the bot owner can run this command!",
|
"ownerOnly": "Only the bot owner can run this command!",
|
||||||
"dmsOnly": "You can only run this command in DMs!",
|
"dmsOnly": "You can only run this command in DMs!",
|
||||||
|
|
Reference in a new issue