Archived
0
0
Fork 0

feat: Added startup

This commit is contained in:
Daryl Ronningen 2021-06-17 01:03:11 -07:00
parent f4cd25fcef
commit d1cf8a73dd
Signed by: Daryl Ronningen
GPG key ID: FD23F0C934A5EC6B
26 changed files with 1825 additions and 521 deletions

2
.gitignore vendored
View file

@ -672,3 +672,5 @@ DerivedData/
*.rdb *.rdb
# ---> Project
config.json

5
.idea/.gitignore vendored
View file

@ -1,5 +0,0 @@
# Default ignored files
/shelf/
/workspace.xml
# Editor-based HTTP Client requests
/httpRequests/

View file

@ -1,12 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="WEB_MODULE" version="4">
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$">
<excludeFolder url="file://$MODULE_DIR$/temp" />
<excludeFolder url="file://$MODULE_DIR$/.tmp" />
<excludeFolder url="file://$MODULE_DIR$/tmp" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>

View file

@ -1,106 +0,0 @@
<component name="ProjectCodeStyleConfiguration">
<code_scheme name="Project" version="173">
<option name="OTHER_INDENT_OPTIONS">
<value>
<option name="INDENT_SIZE" value="2" />
<option name="TAB_SIZE" value="2" />
<option name="USE_TAB_CHARACTER" value="true" />
<option name="SMART_TABS" value="true" />
</value>
</option>
<option name="LINE_SEPARATOR" value="&#10;" />
<option name="WRAP_WHEN_TYPING_REACHES_RIGHT_MARGIN" value="true" />
<option name="SOFT_MARGINS" value="80,120" />
<DBN-PSQL>
<case-options enabled="true">
<option name="KEYWORD_CASE" value="lower" />
<option name="FUNCTION_CASE" value="lower" />
<option name="PARAMETER_CASE" value="lower" />
<option name="DATATYPE_CASE" value="lower" />
<option name="OBJECT_CASE" value="preserve" />
</case-options>
<formatting-settings enabled="false" />
</DBN-PSQL>
<DBN-SQL>
<case-options enabled="true">
<option name="KEYWORD_CASE" value="lower" />
<option name="FUNCTION_CASE" value="lower" />
<option name="PARAMETER_CASE" value="lower" />
<option name="DATATYPE_CASE" value="lower" />
<option name="OBJECT_CASE" value="preserve" />
</case-options>
<formatting-settings enabled="false">
<option name="STATEMENT_SPACING" value="one_line" />
<option name="CLAUSE_CHOP_DOWN" value="chop_down_if_statement_long" />
<option name="ITERATION_ELEMENTS_WRAPPING" value="chop_down_if_not_single" />
</formatting-settings>
</DBN-SQL>
<HTMLCodeStyleSettings>
<option name="HTML_SPACE_INSIDE_EMPTY_TAG" value="true" />
</HTMLCodeStyleSettings>
<Markdown>
<option name="MAX_LINES_AROUND_HEADER" value="0" />
<option name="MAX_LINES_AROUND_BLOCK_ELEMENTS" value="0" />
<option name="MAX_LINES_BETWEEN_PARAGRAPHS" value="0" />
</Markdown>
<codeStyleSettings language="CSS">
<indentOptions>
<option name="INDENT_SIZE" value="2" />
<option name="CONTINUATION_INDENT_SIZE" value="2" />
<option name="TAB_SIZE" value="2" />
<option name="USE_TAB_CHARACTER" value="true" />
<option name="SMART_TABS" value="true" />
</indentOptions>
</codeStyleSettings>
<codeStyleSettings language="HTML">
<indentOptions>
<option name="INDENT_SIZE" value="2" />
<option name="CONTINUATION_INDENT_SIZE" value="2" />
<option name="TAB_SIZE" value="2" />
<option name="USE_TAB_CHARACTER" value="true" />
</indentOptions>
</codeStyleSettings>
<codeStyleSettings language="JSON">
<indentOptions>
<option name="CONTINUATION_INDENT_SIZE" value="2" />
<option name="TAB_SIZE" value="2" />
<option name="USE_TAB_CHARACTER" value="true" />
<option name="SMART_TABS" value="true" />
</indentOptions>
</codeStyleSettings>
<codeStyleSettings language="JavaScript">
<indentOptions>
<option name="INDENT_SIZE" value="2" />
<option name="CONTINUATION_INDENT_SIZE" value="2" />
<option name="TAB_SIZE" value="2" />
<option name="USE_TAB_CHARACTER" value="true" />
<option name="SMART_TABS" value="true" />
</indentOptions>
</codeStyleSettings>
<codeStyleSettings language="Markdown">
<indentOptions>
<option name="INDENT_SIZE" value="2" />
<option name="CONTINUATION_INDENT_SIZE" value="4" />
<option name="TAB_SIZE" value="2" />
<option name="USE_TAB_CHARACTER" value="true" />
<option name="SMART_TABS" value="true" />
</indentOptions>
</codeStyleSettings>
<codeStyleSettings language="TypeScript">
<indentOptions>
<option name="INDENT_SIZE" value="2" />
<option name="CONTINUATION_INDENT_SIZE" value="2" />
<option name="TAB_SIZE" value="2" />
<option name="USE_TAB_CHARACTER" value="true" />
<option name="SMART_TABS" value="true" />
</indentOptions>
</codeStyleSettings>
<codeStyleSettings language="Vue">
<indentOptions>
<option name="CONTINUATION_INDENT_SIZE" value="2" />
<option name="USE_TAB_CHARACTER" value="true" />
<option name="SMART_TABS" value="true" />
</indentOptions>
</codeStyleSettings>
</code_scheme>
</component>

View file

@ -1,5 +0,0 @@
<component name="ProjectCodeStyleConfiguration">
<state>
<option name="USE_PER_PROJECT_SETTINGS" value="true" />
</state>
</component>

View file

@ -1,6 +0,0 @@
<component name="CopyrightManager">
<copyright>
<option name="notice" value="ArgonBot&#10;Copyright (C) 2021-Present Daryl Ronningen &amp;amp; Contributors&#10;&#10;This program 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.&#10;&#10;This program 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.&#10;&#10;You should have received a copy of the GNU General Public License along with this program. If not, see &lt;https://www.gnu.org/licenses/&gt;." />
<option name="myName" value="GPL" />
</copyright>
</component>

View file

@ -1,6 +0,0 @@
<component name="InspectionProjectProfileManager">
<profile version="1.0">
<option name="myName" value="Project Default" />
<inspection_tool class="Eslint" enabled="true" level="WARNING" enabled_by_default="true" />
</profile>
</component>

View file

@ -1,8 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/ArgonBot.iml" filepath="$PROJECT_DIR$/.idea/ArgonBot.iml" />
</modules>
</component>
</project>

View file

@ -1,6 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$" vcs="Git" />
</component>
</project>

11
.vscode/settings.json vendored
View file

@ -5,6 +5,9 @@
}, },
"eslint.nodePath": ".yarn/sdks", "eslint.nodePath": ".yarn/sdks",
"prettier.prettierPath": ".yarn/sdks/prettier/index.js", "prettier.prettierPath": ".yarn/sdks/prettier/index.js",
"editor.formatOnPaste": true,
"editor.formatOnSave": true,
"editor.formatOnType": true,
"typescript.tsdk": ".yarn/sdks/typescript/lib", "typescript.tsdk": ".yarn/sdks/typescript/lib",
"typescript.enablePromptUseWorkspaceTsdk": true, "typescript.enablePromptUseWorkspaceTsdk": true,
"fileHeaderComment.parameter": { "fileHeaderComment.parameter": {
@ -36,5 +39,11 @@
"${commentprefix} ${license_gpl-3.0-or-later}", "${commentprefix} ${license_gpl-3.0-or-later}",
"${commentend}" "${commentend}"
] ]
} },
"eslint.format.enable": true,
"eslint.lintTask.enable": true,
"eslint.packageManager": "yarn",
"editor.insertSpaces": false,
"editor.tabSize": 2,
"typescript.preferences.quoteStyle": "single"
} }

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -4,7 +4,7 @@ const {existsSync} = require(`fs`);
const {createRequire, createRequireFromPath} = require(`module`); const {createRequire, createRequireFromPath} = require(`module`);
const {resolve} = require(`path`); const {resolve} = require(`path`);
const relPnpApiPath = "../../../../.pnp.js"; const relPnpApiPath = "../../../../.pnp.cjs";
const absPnpApiPath = resolve(__dirname, relPnpApiPath); const absPnpApiPath = resolve(__dirname, relPnpApiPath);
const absRequire = (createRequire || createRequireFromPath)(absPnpApiPath); const absRequire = (createRequire || createRequireFromPath)(absPnpApiPath);

View file

@ -4,7 +4,7 @@ const {existsSync} = require(`fs`);
const {createRequire, createRequireFromPath} = require(`module`); const {createRequire, createRequireFromPath} = require(`module`);
const {resolve} = require(`path`); const {resolve} = require(`path`);
const relPnpApiPath = "../../../../.pnp.js"; const relPnpApiPath = "../../../../.pnp.cjs";
const absPnpApiPath = resolve(__dirname, relPnpApiPath); const absPnpApiPath = resolve(__dirname, relPnpApiPath);
const absRequire = (createRequire || createRequireFromPath)(absPnpApiPath); const absRequire = (createRequire || createRequireFromPath)(absPnpApiPath);

View file

@ -4,7 +4,7 @@ const {existsSync} = require(`fs`);
const {createRequire, createRequireFromPath} = require(`module`); const {createRequire, createRequireFromPath} = require(`module`);
const {resolve} = require(`path`); const {resolve} = require(`path`);
const relPnpApiPath = "../../../../.pnp.js"; const relPnpApiPath = "../../../../.pnp.cjs";
const absPnpApiPath = resolve(__dirname, relPnpApiPath); const absPnpApiPath = resolve(__dirname, relPnpApiPath);
const absRequire = (createRequire || createRequireFromPath)(absPnpApiPath); const absRequire = (createRequire || createRequireFromPath)(absPnpApiPath);

View file

@ -4,7 +4,7 @@ const {existsSync} = require(`fs`);
const {createRequire, createRequireFromPath} = require(`module`); const {createRequire, createRequireFromPath} = require(`module`);
const {resolve} = require(`path`); const {resolve} = require(`path`);
const relPnpApiPath = "../../../../.pnp.js"; const relPnpApiPath = "../../../../.pnp.cjs";
const absPnpApiPath = resolve(__dirname, relPnpApiPath); const absPnpApiPath = resolve(__dirname, relPnpApiPath);
const absRequire = (createRequire || createRequireFromPath)(absPnpApiPath); const absRequire = (createRequire || createRequireFromPath)(absPnpApiPath);

View file

@ -1,6 +1,6 @@
{ {
"name": "typescript", "name": "typescript",
"version": "4.3.2-pnpify", "version": "4.3.3-pnpify",
"main": "./lib/typescript.js", "main": "./lib/typescript.js",
"type": "commonjs" "type": "commonjs"
} }

4
config.json.example Normal file
View file

@ -0,0 +1,4 @@
{
"token": "",
"loglevel": ""
}

View file

@ -7,34 +7,48 @@
"bugs": "https://code.relms.dev/Relms/ArgonBot/issues", "bugs": "https://code.relms.dev/Relms/ArgonBot/issues",
"homepage": "https://code.relms.dev/Relms/ArgonBot/src/branch/master/README.md", "homepage": "https://code.relms.dev/Relms/ArgonBot/src/branch/master/README.md",
"author": "Daryl Ronningen <relms@relms.dev>", "author": "Daryl Ronningen <relms@relms.dev>",
"maintainers": [], "maintainers": [
"Daryl Ronningen <relms@relms.dev>"
],
"contributors": [], "contributors": [],
"license": "GPL-3.0-or-later", "license": "GPL-3.0-or-later",
"private": true, "private": true,
"scripts": { "scripts": {
"clean": "rimraf dist",
"compile:dev": "tsc", "compile:dev": "tsc",
"compile:final": "rollup -c --compact", "compile:prod": "rollup -c --compact",
"commit": "commit", "commit": "commit",
"lint": "eslint --format=pretty src/**/*.ts", "lint": "eslint --format=pretty src/**/*.ts",
"lint:save": "eslint --format=pretty --save src/**/*.ts", "lint:save": "eslint --format=pretty --save src/**/*.ts",
"release:alpha": "standard-version --prelease alpha -s", "release:alpha": "standard-version --prelease alpha -s",
"release:beta": "standard-version --prelease beta -s", "release:beta": "standard-version --prelease beta -s",
"release:full": "standard-version -s", "release:full": "standard-version -s",
"run:dev": "node dist/src/index.js", "run:dev": "node dist/src/index.js --dev",
"run:prod": "node dist/index.js", "run:prod": "node dist/index.js",
"watch": "tsc --watch" "watch:bot": "nodemon dist/src/index.js --dev",
"watch:rollup": "tsc --watch",
"watch:tsc": "tsc --watch"
}, },
"dependencies": { "dependencies": {
"@discordjs/opus": "^0.5.3", "@discordjs/opus": "^0.5.3",
"@discordjs/voice": "^0.3.1", "@discordjs/voice": "^0.5.0",
"bufferutil": "^4.0.3", "bufferutil": "^4.0.3",
"discord.js": "dev", "chalk": "^4.1.1",
"color-convert": "^2.0.1",
"discord.js": "^13.0.0-dev.a3cbcca13da1af416c219bd64a0a6e84bb87a057",
"erlpack": "^0.1.3", "erlpack": "^0.1.3",
"ffmpeg-static": "^4.3.0", "ffmpeg-static": "^4.3.0",
"figlet": "^1.5.0",
"gradient-string": "^1.2.0",
"jsonschema": "^1.4.0",
"luxon": "^1.27.0",
"node-gyp": "^8.1.0", "node-gyp": "^8.1.0",
"sodium": "^3.0.2", "sodium": "^3.0.2",
"supports-color": "^9.0.1",
"terminal-link": "^3.0.0",
"tslib": "^2.3.0", "tslib": "^2.3.0",
"utf-8-validate": "^5.0.5", "utf-8-validate": "^5.0.5",
"yargs": "^17.0.1",
"zlib-sync": "^0.1.7" "zlib-sync": "^0.1.7"
}, },
"devDependencies": { "devDependencies": {
@ -44,20 +58,31 @@
"@commitlint/prompt-cli": "^12.1.4", "@commitlint/prompt-cli": "^12.1.4",
"@rollup/plugin-json": "^4.1.0", "@rollup/plugin-json": "^4.1.0",
"@rollup/plugin-typescript": "^8.2.1", "@rollup/plugin-typescript": "^8.2.1",
"@types/color-convert": "^2",
"@types/eslint": "^7.2.13", "@types/eslint": "^7.2.13",
"@typescript-eslint/eslint-plugin": "^4.26.1", "@types/figlet": "^1.5.1",
"@typescript-eslint/parser": "^4.26.1", "@types/gradient-string": "^1",
"@typescript-eslint/typescript-estree": "^4.26.1", "@types/luxon": "^1",
"@types/node": "^15.12.2",
"@types/rimraf": "^3",
"@types/yargs": "^17",
"@typescript-eslint/eslint-plugin": "^4.27.0",
"@typescript-eslint/parser": "^4.27.0",
"@typescript-eslint/typescript-estree": "^4.27.0",
"@yarnpkg/pnpify": "^3.0.0-rc.6", "@yarnpkg/pnpify": "^3.0.0-rc.6",
"eslint": "^7.28.0", "eslint": "^7.28.0",
"eslint-formatter-pretty": "^4.1.0", "eslint-formatter-pretty": "^4.1.0",
"eslint-plugin-import": "^2.23.4", "eslint-plugin-import": "^2.23.4",
"husky": "^6.0.0", "husky": "^6.0.0",
"lint-staged": "^11.0.0",
"mocha": "^9.0.0", "mocha": "^9.0.0",
"nodemon": "^2.0.7",
"nyc": "^15.1.0", "nyc": "^15.1.0",
"rollup": "^2.51.2", "rimraf": "^3.0.2",
"rollup": "^2.52.0",
"rollup-plugin-terser": "^7.0.2",
"standard-version": "^9.3.0", "standard-version": "^9.3.0",
"typescript": "^4.3.2", "typescript": "^4.3.3",
"typescript-eslint-language-service": "^4.1.4" "typescript-eslint-language-service": "^4.1.4"
}, },
"eslintConfig": { "eslintConfig": {
@ -124,9 +149,13 @@
}, },
"husky": { "husky": {
"hooks": { "hooks": {
"pre-commit": "lint-staged",
"commit-msg": "commitlint -E HUSKY_GIT_PARAMS" "commit-msg": "commitlint -E HUSKY_GIT_PARAMS"
} }
}, },
"lint-staged": {
"src/**/*.ts": ["yarn lint"]
},
"commitlint": { "commitlint": {
"extends": [ "extends": [
"@commitlint/config-conventional" "@commitlint/config-conventional"

View file

@ -1,11 +1,15 @@
import typescript from '@rollup/plugin-typescript'; import typescript from '@rollup/plugin-typescript';
import json from '@rollup/plugin-json'; import json from '@rollup/plugin-json';
import { terser } from 'rollup-plugin-terser';
export default { export default {
input: 'src/index.ts', input: 'src/index.ts',
output: { output: {
dir: 'dist', dir: 'dist',
format: 'cjs' format: 'cjs',
}, },
plugins: [typescript({ module: 'ESNext' }), json( {compact: true, preferConst: true })], plugins: [
typescript({ module: 'ESNext', include: ['src/**/*.ts', '*.json'] }),
json({ compact: true, preferConst: true }),
terser(),
],
}; };

View file

@ -17,6 +17,25 @@
* along with ArgonBot. If not, see <https: //www.gnu.org/licenses/>. * along with ArgonBot. If not, see <https: //www.gnu.org/licenses/>.
*/ */
import discord from "discord.js"; import { Client } from 'discord.js';
import figlet from 'figlet';
import gradient from 'gradient-string';
const client = new discord.Client(); import { token } from '../config.json';
import { info } from './utils/logger';
figlet('Argon Bot', (err, data) => {
if (err) return;
info(gradient.rainbow.multiline(`\n${data}`));
});
const client = new Client({
intents: ['GUILDS', 'GUILD_MESSAGES'],
});
client.on('ready', () => {
info('Startup!');
});
client.login(token);

82
src/utils/logger.ts Normal file
View file

@ -0,0 +1,82 @@
import chalk from 'chalk';
import { DateTime } from 'luxon';
import { loglevel } from '../../config.json';
const logger = new chalk.Instance({ level: 3 });
const date = DateTime.now().toLocal().setLocale(Intl.DateTimeFormat().resolvedOptions().locale).toFormat('yyyy-LL-dd HH:mm:ss');
let verboseLevel = false;
let debugLevel = false;
let infoLevel = false;
let warnLevel = false;
let errorLevel = false;
let fatalLevel = false;
switch (loglevel.toLowerCase()) {
case 'verbose':
verboseLevel = true;
debugLevel = true;
infoLevel = true;
warnLevel = true;
errorLevel = true;
fatalLevel = true;
break;
case 'debug':
debugLevel = true;
infoLevel = true;
warnLevel = true;
errorLevel = true;
fatalLevel = true;
break;
case 'info':
infoLevel = true;
warnLevel = true;
errorLevel = true;
fatalLevel = true;
break;
case 'warn':
warnLevel = true;
errorLevel = true;
fatalLevel = true;
break;
case 'error':
errorLevel = true;
fatalLevel = true;
break;
case 'fatal':
fatalLevel = true;
break;
default:
break;
}
export function verbose(message: string): void {
if(verboseLevel)
console.log(logger`{grey (${date})} {white.bold [VERBOSE]}: ${message}`);
}
export function debug(message: string): void {
if(debugLevel)
console.log(logger`{grey (${date})} {blue.bold [DEBUG]}: ${message}`);
}
export function info(message: string): void {
if(infoLevel)
console.log(logger`{grey (${date})} {green.bold [INFO]}: ${message}`);
}
export function warn(message: string): void {
if(warnLevel)
console.log(logger`{grey (${date})} {yellow.bold.underline [WARN]}: ${message}`);
}
export function error(message: string): void {
if(errorLevel)
console.log(logger`{grey (${date})} {orange.bold.underline [ERROR]}: ${message}`);
}
export function fatal(message: string): void {
if(fatalLevel)
console.log(logger`{grey (${date})} {red.bold.underline [FATAL]}: ${message}`);
}

View file

@ -4,7 +4,10 @@
"downlevelIteration": true, "downlevelIteration": true,
"importHelpers": true, "importHelpers": true,
"incremental": true, "incremental": true,
"lib": ["ESNext", "DOM"], "lib": [
"ESNext",
"DOM"
],
"module": "CommonJS", "module": "CommonJS",
"outDir": "dist", "outDir": "dist",
"tsBuildInfoFile": "dist/.tsbuildinfo", "tsBuildInfoFile": "dist/.tsbuildinfo",
@ -44,18 +47,24 @@
"preserveConstEnums": true, "preserveConstEnums": true,
"resolveJsonModule": true, "resolveJsonModule": true,
"traceResolution": false, "traceResolution": false,
"plugins": [{ "plugins": [
{
"name": "typescript-eslint-language-service" "name": "typescript-eslint-language-service"
}] }
]
}, },
"watchOptions": { "watchOptions": {
"watchFile": "useFsEvents", "watchFile": "useFsEvents",
"watchDirectory": "useFsEvents", "watchDirectory": "useFsEvents",
"fallbackPolling": "dynamicpriority", "fallbackPolling": "dynamicpriority",
"synchronousWatchDirectory": true, "synchronousWatchDirectory": true,
"excludeDirectories": ["node_modules", "dist"] "excludeDirectories": [
"node_modules",
"dist"
]
}, },
"include": [ "include": [
"src/**/*.ts" "src/**/*.ts",
"*.json"
] ]
} }

1210
yarn.lock

File diff suppressed because it is too large Load diff