✨ Add a work command
This commit is contained in:
parent
5cf3138c53
commit
8e47072fca
18 changed files with 1133 additions and 1037 deletions
92
.eslintrc
92
.eslintrc
|
@ -1,46 +1,46 @@
|
|||
{
|
||||
"extends": ["airbnb", "prettier"],
|
||||
"plugins": ["prettier"],
|
||||
"rules": {
|
||||
"arrow-spacing": ["warn", { "before": true, "after": true }],
|
||||
"brace-style": ["error", "stroustrup", { "allowSingleLine": true }],
|
||||
"comma-dangle": ["error", "always-multiline"],
|
||||
"comma-spacing": "error",
|
||||
"comma-style": "error",
|
||||
"curly": ["error", "multi-line", "consistent"],
|
||||
"dot-location": ["error", "property"],
|
||||
"handle-callback-err": "off",
|
||||
"indent": ["error", "tab"],
|
||||
"keyword-spacing": "error",
|
||||
"max-nested-callbacks": ["error", { "max": 4 }],
|
||||
"max-statements-per-line": ["error", { "max": 2 }],
|
||||
"no-console": "off",
|
||||
"no-empty-function": "error",
|
||||
"no-floating-decimal": "error",
|
||||
"no-inline-comments": "error",
|
||||
"no-lonely-if": "error",
|
||||
"no-multi-spaces": "error",
|
||||
"no-multiple-empty-lines": ["error", { "max": 2, "maxEOF": 1, "maxBOF": 0 }],
|
||||
"no-shadow": ["error", { "allow": ["err", "resolve", "reject"] }],
|
||||
"no-trailing-spaces": ["error"],
|
||||
"no-var": "error",
|
||||
"object-curly-spacing": ["error", "always"],
|
||||
"prefer-const": "error",
|
||||
"quotes": ["error", "single"],
|
||||
"semi": ["error", "always"],
|
||||
"space-before-blocks": "error",
|
||||
"space-before-function-paren": [
|
||||
"error",
|
||||
{
|
||||
"anonymous": "never",
|
||||
"named": "never",
|
||||
"asyncArrow": "always"
|
||||
}
|
||||
],
|
||||
"space-in-parens": "error",
|
||||
"space-infix-ops": "error",
|
||||
"space-unary-ops": "error",
|
||||
"spaced-comment": "error",
|
||||
"yoda": "error"
|
||||
}
|
||||
}
|
||||
{
|
||||
"extends": ["airbnb", "prettier"],
|
||||
"plugins": ["prettier"],
|
||||
"rules": {
|
||||
"arrow-spacing": ["warn", { "before": true, "after": true }],
|
||||
"brace-style": ["error", "stroustrup", { "allowSingleLine": true }],
|
||||
"comma-dangle": ["error", "always-multiline"],
|
||||
"comma-spacing": "error",
|
||||
"comma-style": "error",
|
||||
"curly": ["error", "multi-line", "consistent"],
|
||||
"dot-location": ["error", "property"],
|
||||
"handle-callback-err": "off",
|
||||
"indent": ["error", "tab"],
|
||||
"keyword-spacing": "error",
|
||||
"max-nested-callbacks": ["error", { "max": 4 }],
|
||||
"max-statements-per-line": ["error", { "max": 2 }],
|
||||
"no-console": "off",
|
||||
"no-empty-function": "error",
|
||||
"no-floating-decimal": "error",
|
||||
"no-inline-comments": "error",
|
||||
"no-lonely-if": "error",
|
||||
"no-multi-spaces": "error",
|
||||
"no-multiple-empty-lines": ["error", { "max": 2, "maxEOF": 1, "maxBOF": 0 }],
|
||||
"no-shadow": ["error", { "allow": ["err", "resolve", "reject"] }],
|
||||
"no-trailing-spaces": ["error"],
|
||||
"no-var": "error",
|
||||
"object-curly-spacing": ["error", "always"],
|
||||
"prefer-const": "error",
|
||||
"quotes": ["error", "single"],
|
||||
"semi": ["error", "always"],
|
||||
"space-before-blocks": "error",
|
||||
"space-before-function-paren": [
|
||||
"error",
|
||||
{
|
||||
"anonymous": "never",
|
||||
"named": "never",
|
||||
"asyncArrow": "always"
|
||||
}
|
||||
],
|
||||
"space-in-parens": "error",
|
||||
"space-infix-ops": "error",
|
||||
"space-unary-ops": "error",
|
||||
"spaced-comment": "error",
|
||||
"yoda": "error"
|
||||
}
|
||||
}
|
||||
|
|
30
.eslintrc.js
30
.eslintrc.js
|
@ -1,15 +1,15 @@
|
|||
module.exports = {
|
||||
env: {
|
||||
commonjs: true,
|
||||
es2021: true,
|
||||
node: true,
|
||||
},
|
||||
extends: [
|
||||
'airbnb-base',
|
||||
],
|
||||
parserOptions: {
|
||||
ecmaVersion: 'latest',
|
||||
},
|
||||
rules: {
|
||||
},
|
||||
};
|
||||
module.exports = {
|
||||
env: {
|
||||
commonjs: true,
|
||||
es2021: true,
|
||||
node: true,
|
||||
},
|
||||
extends: [
|
||||
'airbnb-base',
|
||||
],
|
||||
parserOptions: {
|
||||
ecmaVersion: 'latest',
|
||||
},
|
||||
rules: {
|
||||
},
|
||||
};
|
||||
|
|
272
.gitignore
vendored
272
.gitignore
vendored
|
@ -1,136 +1,136 @@
|
|||
json.sqlite
|
||||
node_modules
|
||||
.env
|
||||
config.json
|
||||
package-lock.json
|
||||
|
||||
# Logs
|
||||
logs
|
||||
*.log
|
||||
npm-debug.log*
|
||||
yarn-debug.log*
|
||||
yarn-error.log*
|
||||
lerna-debug.log*
|
||||
.pnpm-debug.log*
|
||||
|
||||
# Diagnostic reports (https://nodejs.org/api/report.html)
|
||||
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
|
||||
|
||||
# Runtime data
|
||||
pids
|
||||
*.pid
|
||||
*.seed
|
||||
*.pid.lock
|
||||
|
||||
# Directory for instrumented libs generated by jscoverage/JSCover
|
||||
lib-cov
|
||||
|
||||
# Coverage directory used by tools like istanbul
|
||||
coverage
|
||||
*.lcov
|
||||
|
||||
# nyc test coverage
|
||||
.nyc_output
|
||||
|
||||
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
|
||||
.grunt
|
||||
|
||||
# Bower dependency directory (https://bower.io/)
|
||||
bower_components
|
||||
|
||||
# node-waf configuration
|
||||
.lock-wscript
|
||||
|
||||
# Compiled binary addons (https://nodejs.org/api/addons.html)
|
||||
build/Release
|
||||
|
||||
# Dependency directories
|
||||
node_modules/
|
||||
jspm_packages/
|
||||
|
||||
# Snowpack dependency directory (https://snowpack.dev/)
|
||||
web_modules/
|
||||
|
||||
# TypeScript cache
|
||||
*.tsbuildinfo
|
||||
|
||||
# Optional npm cache directory
|
||||
.npm
|
||||
|
||||
# Optional eslint cache
|
||||
.eslintcache
|
||||
|
||||
# Optional stylelint cache
|
||||
.stylelintcache
|
||||
|
||||
# Microbundle cache
|
||||
.rpt2_cache/
|
||||
.rts2_cache_cjs/
|
||||
.rts2_cache_es/
|
||||
.rts2_cache_umd/
|
||||
|
||||
# Optional REPL history
|
||||
.node_repl_history
|
||||
|
||||
# Output of 'npm pack'
|
||||
*.tgz
|
||||
|
||||
# Yarn Integrity file
|
||||
.yarn-integrity
|
||||
|
||||
# dotenv environment variable files
|
||||
.env
|
||||
.env.development.local
|
||||
.env.test.local
|
||||
.env.production.local
|
||||
.env.local
|
||||
|
||||
# parcel-bundler cache (https://parceljs.org/)
|
||||
.cache
|
||||
.parcel-cache
|
||||
|
||||
# Next.js build output
|
||||
.next
|
||||
out
|
||||
|
||||
# Nuxt.js build / generate output
|
||||
.nuxt
|
||||
dist
|
||||
|
||||
# Gatsby files
|
||||
.cache/
|
||||
# Comment in the public line in if your project uses Gatsby and not Next.js
|
||||
# https://nextjs.org/blog/next-9-1#public-directory-support
|
||||
# public
|
||||
|
||||
# vuepress build output
|
||||
.vuepress/dist
|
||||
|
||||
# vuepress v2.x temp and cache directory
|
||||
.temp
|
||||
.cache
|
||||
|
||||
# Docusaurus cache and generated files
|
||||
.docusaurus
|
||||
|
||||
# Serverless directories
|
||||
.serverless/
|
||||
|
||||
# FuseBox cache
|
||||
.fusebox/
|
||||
|
||||
# DynamoDB Local files
|
||||
.dynamodb/
|
||||
|
||||
# TernJS port file
|
||||
.tern-port
|
||||
|
||||
# Stores VSCode versions used for testing VSCode extensions
|
||||
.vscode-test
|
||||
|
||||
# yarn v2
|
||||
.yarn/cache
|
||||
.yarn/unplugged
|
||||
.yarn/build-state.yml
|
||||
.yarn/install-state.gz
|
||||
.pnp.*
|
||||
json.sqlite
|
||||
node_modules
|
||||
.env
|
||||
config.json
|
||||
package-lock.json
|
||||
|
||||
# Logs
|
||||
logs
|
||||
*.log
|
||||
npm-debug.log*
|
||||
yarn-debug.log*
|
||||
yarn-error.log*
|
||||
lerna-debug.log*
|
||||
.pnpm-debug.log*
|
||||
|
||||
# Diagnostic reports (https://nodejs.org/api/report.html)
|
||||
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
|
||||
|
||||
# Runtime data
|
||||
pids
|
||||
*.pid
|
||||
*.seed
|
||||
*.pid.lock
|
||||
|
||||
# Directory for instrumented libs generated by jscoverage/JSCover
|
||||
lib-cov
|
||||
|
||||
# Coverage directory used by tools like istanbul
|
||||
coverage
|
||||
*.lcov
|
||||
|
||||
# nyc test coverage
|
||||
.nyc_output
|
||||
|
||||
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
|
||||
.grunt
|
||||
|
||||
# Bower dependency directory (https://bower.io/)
|
||||
bower_components
|
||||
|
||||
# node-waf configuration
|
||||
.lock-wscript
|
||||
|
||||
# Compiled binary addons (https://nodejs.org/api/addons.html)
|
||||
build/Release
|
||||
|
||||
# Dependency directories
|
||||
node_modules/
|
||||
jspm_packages/
|
||||
|
||||
# Snowpack dependency directory (https://snowpack.dev/)
|
||||
web_modules/
|
||||
|
||||
# TypeScript cache
|
||||
*.tsbuildinfo
|
||||
|
||||
# Optional npm cache directory
|
||||
.npm
|
||||
|
||||
# Optional eslint cache
|
||||
.eslintcache
|
||||
|
||||
# Optional stylelint cache
|
||||
.stylelintcache
|
||||
|
||||
# Microbundle cache
|
||||
.rpt2_cache/
|
||||
.rts2_cache_cjs/
|
||||
.rts2_cache_es/
|
||||
.rts2_cache_umd/
|
||||
|
||||
# Optional REPL history
|
||||
.node_repl_history
|
||||
|
||||
# Output of 'npm pack'
|
||||
*.tgz
|
||||
|
||||
# Yarn Integrity file
|
||||
.yarn-integrity
|
||||
|
||||
# dotenv environment variable files
|
||||
.env
|
||||
.env.development.local
|
||||
.env.test.local
|
||||
.env.production.local
|
||||
.env.local
|
||||
|
||||
# parcel-bundler cache (https://parceljs.org/)
|
||||
.cache
|
||||
.parcel-cache
|
||||
|
||||
# Next.js build output
|
||||
.next
|
||||
out
|
||||
|
||||
# Nuxt.js build / generate output
|
||||
.nuxt
|
||||
dist
|
||||
|
||||
# Gatsby files
|
||||
.cache/
|
||||
# Comment in the public line in if your project uses Gatsby and not Next.js
|
||||
# https://nextjs.org/blog/next-9-1#public-directory-support
|
||||
# public
|
||||
|
||||
# vuepress build output
|
||||
.vuepress/dist
|
||||
|
||||
# vuepress v2.x temp and cache directory
|
||||
.temp
|
||||
.cache
|
||||
|
||||
# Docusaurus cache and generated files
|
||||
.docusaurus
|
||||
|
||||
# Serverless directories
|
||||
.serverless/
|
||||
|
||||
# FuseBox cache
|
||||
.fusebox/
|
||||
|
||||
# DynamoDB Local files
|
||||
.dynamodb/
|
||||
|
||||
# TernJS port file
|
||||
.tern-port
|
||||
|
||||
# Stores VSCode versions used for testing VSCode extensions
|
||||
.vscode-test
|
||||
|
||||
# yarn v2
|
||||
.yarn/cache
|
||||
.yarn/unplugged
|
||||
.yarn/build-state.yml
|
||||
.yarn/install-state.gz
|
||||
.pnp.*
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
{
|
||||
"printWidth": 100,
|
||||
"singleQuote": true
|
||||
{
|
||||
"printWidth": 100,
|
||||
"singleQuote": true
|
||||
}
|
108
.vscode/settings.json
vendored
108
.vscode/settings.json
vendored
|
@ -1,50 +1,58 @@
|
|||
{
|
||||
"editor.wordWrapColumn": 100,
|
||||
"editor.tabSize": 2,
|
||||
// "workbench.colorCustomizations": {
|
||||
// "titleBar.activeBackground": "#336699",
|
||||
// "titleBar.inactiveBackground": "#33669999",
|
||||
// "titleBar.activeForeground": "#e7e7e7",
|
||||
// "titleBar.inactiveForeground": "#e7e7e799",
|
||||
// "statusBarItem.hoverBackground": "#407fbf",
|
||||
// "activityBar.activeBackground": "#407fbf",
|
||||
// "activityBar.activeBorder": "#77284f",
|
||||
// "activityBar.background": "#407fbf",
|
||||
// "activityBar.foreground": "#e7e7e7",
|
||||
// "activityBar.inactiveForeground": "#e7e7e799",
|
||||
// "activityBarBadge.background": "#77284f",
|
||||
// "activityBarBadge.foreground": "#e7e7e7",
|
||||
// "sash.hoverBorder": "#407fbf",
|
||||
// "statusBarItem.remoteBackground": "#336699",
|
||||
// "statusBarItem.remoteForeground": "#e7e7e7"
|
||||
// },
|
||||
"editor.formatOnSave": true,
|
||||
"javascript.format.enable": false,
|
||||
"eslint.autoFixOnSave": true,
|
||||
"files.eol": "\n",
|
||||
"prettier.endOfLine": "lf",
|
||||
"prettier.singleQuote": true,
|
||||
"prettier.trailingComma": "es5",
|
||||
"peacock.color": "#369",
|
||||
"editor.codeActionsOnSave": {
|
||||
"source.fixAll.eslint": true
|
||||
},
|
||||
"workbench.colorCustomizations": {
|
||||
"activityBar.activeBackground": "#407fbf",
|
||||
"activityBar.activeBorder": "#77284f",
|
||||
"activityBar.background": "#407fbf",
|
||||
"activityBar.foreground": "#e7e7e7",
|
||||
"activityBar.inactiveForeground": "#e7e7e799",
|
||||
"activityBarBadge.background": "#77284f",
|
||||
"activityBarBadge.foreground": "#e7e7e7",
|
||||
"sash.hoverBorder": "#407fbf",
|
||||
"statusBarItem.hoverBackground": "#407fbf",
|
||||
"statusBarItem.remoteBackground": "#336699",
|
||||
"statusBarItem.remoteForeground": "#e7e7e7",
|
||||
"titleBar.activeBackground": "#336699",
|
||||
"titleBar.activeForeground": "#e7e7e7",
|
||||
"titleBar.inactiveBackground": "#33669999",
|
||||
"titleBar.inactiveForeground": "#e7e7e799"
|
||||
},
|
||||
"cSpell.words": ["Controlpanel", "discordjs", "pino", "upsert", "uuidv"]
|
||||
}
|
||||
{
|
||||
"editor.wordWrapColumn": 100,
|
||||
"editor.tabSize": 2,
|
||||
// "workbench.colorCustomizations": {
|
||||
// "titleBar.activeBackground": "#336699",
|
||||
// "titleBar.inactiveBackground": "#33669999",
|
||||
// "titleBar.activeForeground": "#e7e7e7",
|
||||
// "titleBar.inactiveForeground": "#e7e7e799",
|
||||
// "statusBarItem.hoverBackground": "#407fbf",
|
||||
// "activityBar.activeBackground": "#407fbf",
|
||||
// "activityBar.activeBorder": "#77284f",
|
||||
// "activityBar.background": "#407fbf",
|
||||
// "activityBar.foreground": "#e7e7e7",
|
||||
// "activityBar.inactiveForeground": "#e7e7e799",
|
||||
// "activityBarBadge.background": "#77284f",
|
||||
// "activityBarBadge.foreground": "#e7e7e7",
|
||||
// "sash.hoverBorder": "#407fbf",
|
||||
// "statusBarItem.remoteBackground": "#336699",
|
||||
// "statusBarItem.remoteForeground": "#e7e7e7"
|
||||
// },
|
||||
"editor.formatOnSave": true,
|
||||
"javascript.format.enable": false,
|
||||
"eslint.autoFixOnSave": true,
|
||||
"files.eol": "\n",
|
||||
"prettier.endOfLine": "lf",
|
||||
"prettier.singleQuote": true,
|
||||
"prettier.trailingComma": "es5",
|
||||
"peacock.color": "#369",
|
||||
"editor.codeActionsOnSave": {
|
||||
"source.fixAll.eslint": true
|
||||
},
|
||||
"workbench.colorCustomizations": {
|
||||
"activityBar.activeBackground": "#407fbf",
|
||||
"activityBar.activeBorder": "#77284f",
|
||||
"activityBar.background": "#407fbf",
|
||||
"activityBar.foreground": "#e7e7e7",
|
||||
"activityBar.inactiveForeground": "#e7e7e799",
|
||||
"activityBarBadge.background": "#77284f",
|
||||
"activityBarBadge.foreground": "#e7e7e7",
|
||||
"sash.hoverBorder": "#407fbf",
|
||||
"statusBarItem.hoverBackground": "#407fbf",
|
||||
"statusBarItem.remoteBackground": "#336699",
|
||||
"statusBarItem.remoteForeground": "#e7e7e7",
|
||||
"titleBar.activeBackground": "#336699",
|
||||
"titleBar.activeForeground": "#e7e7e7",
|
||||
"titleBar.inactiveBackground": "#33669999",
|
||||
"titleBar.inactiveForeground": "#e7e7e799"
|
||||
},
|
||||
"cSpell.words": [
|
||||
"Controlpanel",
|
||||
"discordjs",
|
||||
"pino",
|
||||
"runned",
|
||||
"Timout",
|
||||
"upsert",
|
||||
"uuidv"
|
||||
]
|
||||
}
|
||||
|
|
38
README.md
38
README.md
|
@ -1,19 +1,19 @@
|
|||
# Xyter
|
||||
|
||||
## Installation
|
||||
|
||||
Rename config.json.example to config.json and fill in the fields.
|
||||
|
||||
_Please note that mongodb.url needs to be inside of double quotes ("YourURL")._
|
||||
|
||||
You can leave any of the **footer** fields empty, it will not impact the bot.
|
||||
|
||||
Then run **node deploy-commands.js** the first time then you can start the bot by **node src/index.js**
|
||||
|
||||
**Free MongoDB hosting**
|
||||
|
||||
- https://atlas.mongodb.com/
|
||||
|
||||
## Credits
|
||||
|
||||
**Please leave of some credits or if anyone ask about the bot, give them a link to the repository. Thanks!**
|
||||
# Xyter
|
||||
|
||||
## Installation
|
||||
|
||||
Rename config.json.example to config.json and fill in the fields.
|
||||
|
||||
_Please note that mongodb.url needs to be inside of double quotes ("YourURL")._
|
||||
|
||||
You can leave any of the **footer** fields empty, it will not impact the bot.
|
||||
|
||||
Then run **node deploy-commands.js** the first time then you can start the bot by **node src/index.js**
|
||||
|
||||
**Free MongoDB hosting**
|
||||
|
||||
- https://atlas.mongodb.com/
|
||||
|
||||
## Credits
|
||||
|
||||
**Please leave of some credits or if anyone ask about the bot, give them a link to the repository. Thanks!**
|
||||
|
|
|
@ -1,22 +1,22 @@
|
|||
{
|
||||
"bot": {
|
||||
"token": "required",
|
||||
"clientId": "required",
|
||||
"guildId": "required"
|
||||
},
|
||||
"credits": {
|
||||
"url": "scheme://domain/api/",
|
||||
"token": "required",
|
||||
"timeout": "5000",
|
||||
"rate": "1",
|
||||
"minimumLength": "5",
|
||||
"excludedChannels": ["channel_id", "channel_id"]
|
||||
},
|
||||
"colors": { "success": "0x22bb33", "error": "0xbb2124", "wait": "0xf0ad4e" },
|
||||
"mongodb": {
|
||||
"url": "mongodb+srv://username:password@server/database?retryWrites=true&w=majority"
|
||||
},
|
||||
"footer": { "icon": "https://avatars.githubusercontent.com/u/83163073", "text": "https://github.com/ZynerOrg/xyter" },
|
||||
"disable": { "redeem": false },
|
||||
"debug": false
|
||||
}
|
||||
{
|
||||
"bot": {
|
||||
"token": "required",
|
||||
"clientId": "required",
|
||||
"guildId": "required"
|
||||
},
|
||||
"credits": {
|
||||
"url": "scheme://domain/api/",
|
||||
"token": "required",
|
||||
"timeout": "5000",
|
||||
"rate": "1",
|
||||
"minimumLength": "5",
|
||||
"excludedChannels": ["channel_id", "channel_id"]
|
||||
},
|
||||
"colors": { "success": "0x22bb33", "error": "0xbb2124", "wait": "0xf0ad4e" },
|
||||
"mongodb": {
|
||||
"url": "mongodb+srv://username:password@server/database?retryWrites=true&w=majority"
|
||||
},
|
||||
"footer": { "icon": "https://avatars.githubusercontent.com/u/83163073", "text": "https://github.com/ZynerOrg/xyter" },
|
||||
"disable": { "redeem": false },
|
||||
"debug": false
|
||||
}
|
||||
|
|
88
package.json
88
package.json
|
@ -1,44 +1,44 @@
|
|||
{
|
||||
"name": "xyter",
|
||||
"version": "2.3.1",
|
||||
"description": "Earn credits while chatting! And more",
|
||||
"main": "src/index.js",
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1",
|
||||
"start": "nodemon | pino-pretty -i pid,hostname -t yyyy-mm-dd HH:MM:s"
|
||||
},
|
||||
"keywords": [
|
||||
"zyner",
|
||||
"controlpanel",
|
||||
"controlpanel.gg",
|
||||
"vermium"
|
||||
],
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/ZynerOrg/xyter.git"
|
||||
},
|
||||
"author": "Vermium Sifell <vermium@zyner.org> (https://zyner.org)",
|
||||
"license": "GPL-3.0-only",
|
||||
"bugs": {
|
||||
"url": "https://github.com/ZynerOrg/xyter/issues",
|
||||
"email": "vermium@zyner.org"
|
||||
},
|
||||
"dependencies": {
|
||||
"@discordjs/builders": "^0.12.0",
|
||||
"@discordjs/rest": "^0.3.0",
|
||||
"axios": "^0.26.0",
|
||||
"better-sqlite3": "^7.5.0",
|
||||
"discord-api-types": "^0.27.3",
|
||||
"discord.js": "^13.6.0",
|
||||
"dotenv": "^16.0.0",
|
||||
"mongoose": "^6.2.3",
|
||||
"pino": "^7.0.0-rc.9",
|
||||
"quick.db": "^7.1.3",
|
||||
"uuid": "^8.3.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"eslint": "8.10.0",
|
||||
"eslint-config-airbnb-base": "15.0.0",
|
||||
"eslint-plugin-import": "2.25.4"
|
||||
}
|
||||
}
|
||||
{
|
||||
"name": "xyter",
|
||||
"version": "2.3.1",
|
||||
"description": "Earn credits while chatting! And more",
|
||||
"main": "src/index.js",
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1",
|
||||
"start": "nodemon | pino-pretty -i pid,hostname -t yyyy-mm-dd HH:MM:s"
|
||||
},
|
||||
"keywords": [
|
||||
"zyner",
|
||||
"controlpanel",
|
||||
"controlpanel.gg",
|
||||
"vermium"
|
||||
],
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/ZynerOrg/xyter.git"
|
||||
},
|
||||
"author": "Vermium Sifell <vermium@zyner.org> (https://zyner.org)",
|
||||
"license": "GPL-3.0-only",
|
||||
"bugs": {
|
||||
"url": "https://github.com/ZynerOrg/xyter/issues",
|
||||
"email": "vermium@zyner.org"
|
||||
},
|
||||
"dependencies": {
|
||||
"@discordjs/builders": "^0.12.0",
|
||||
"@discordjs/rest": "^0.3.0",
|
||||
"axios": "^0.26.0",
|
||||
"better-sqlite3": "^7.5.0",
|
||||
"discord-api-types": "^0.27.3",
|
||||
"discord.js": "^13.6.0",
|
||||
"dotenv": "^16.0.0",
|
||||
"mongoose": "^6.2.3",
|
||||
"pino": "^7.0.0-rc.9",
|
||||
"quick.db": "^7.1.3",
|
||||
"uuid": "^8.3.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"eslint": "8.10.0",
|
||||
"eslint-config-airbnb-base": "15.0.0",
|
||||
"eslint-plugin-import": "2.25.4"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
{
|
||||
"extends": [
|
||||
"config:base"
|
||||
]
|
||||
}
|
||||
{
|
||||
"extends": [
|
||||
"config:base"
|
||||
]
|
||||
}
|
||||
|
|
|
@ -9,6 +9,7 @@ module.exports = async (interaction) => {
|
|||
const user = await interaction.options.getUser('user');
|
||||
|
||||
await credits
|
||||
// eslint-disable-next-line max-len
|
||||
.findOne({ userId: user ? user.id : interaction.user.id, guildId: interaction.member.guild.id })
|
||||
.then(async (data) => {
|
||||
if (!data) {
|
||||
|
|
|
@ -10,6 +10,7 @@ module.exports = async (interaction) => {
|
|||
const user = await interaction.options.getUser('user');
|
||||
const amount = await interaction.options.getInteger('amount');
|
||||
const reason = await interaction.options.getString('reason');
|
||||
// eslint-disable-next-line max-len
|
||||
const data = await credits.findOne({ userId: interaction.user.id, guildId: interaction.member.guild.id });
|
||||
|
||||
if (user.id === interaction.user.id) {
|
||||
|
@ -72,7 +73,7 @@ module.exports = async (interaction) => {
|
|||
};
|
||||
const dmEmbed = {
|
||||
title: 'Gift',
|
||||
description: `You recieved ${creditNoun(amount)} from ${interaction.user}${reason ? ` with reason: ${reason}` : ''}. Your new balance is ${creditNoun(
|
||||
description: `You received ${creditNoun(amount)} from ${interaction.user}${reason ? ` with reason: ${reason}` : ''}. Your new balance is ${creditNoun(
|
||||
toUser.balance,
|
||||
)}.`,
|
||||
color: 0x22bb33,
|
||||
|
|
|
@ -23,6 +23,7 @@ module.exports = async (interaction) => {
|
|||
}
|
||||
const amount = await interaction.options.getInteger('amount');
|
||||
|
||||
// eslint-disable-next-line max-len
|
||||
const user = await credits.findOne({ userId: interaction.user.id, guildId: interaction.member.guild.id });
|
||||
const dmUser = interaction.client.users.cache.get(interaction.member.user.id);
|
||||
|
||||
|
|
|
@ -3,6 +3,7 @@ const logger = require('../../../handlers/logger');
|
|||
|
||||
const guilds = require('../../../helpers/database/models/guildSchema');
|
||||
|
||||
// eslint-disable-next-line consistent-return
|
||||
module.exports = async (interaction) => {
|
||||
try {
|
||||
const status = await interaction.options.getBoolean('status');
|
||||
|
@ -11,6 +12,8 @@ module.exports = async (interaction) => {
|
|||
const rate = await interaction.options.getNumber('rate');
|
||||
const timeout = await interaction.options.getNumber('timeout');
|
||||
const minimumLength = await interaction.options.getNumber('minimum-length');
|
||||
const workRate = await interaction.options.getNumber('work-rate');
|
||||
const workTimeout = await interaction.options.getNumber('work-timeout');
|
||||
|
||||
const guild = await guilds.findOne({ guildId: interaction.member.guild.id });
|
||||
|
||||
|
@ -19,6 +22,9 @@ module.exports = async (interaction) => {
|
|||
guild.credits.token = token !== null ? token : guild.credits.token;
|
||||
guild.credits.rate = rate !== null ? rate : guild.credits.rate;
|
||||
guild.credits.timeout = timeout !== null ? timeout : guild.credits.timeout;
|
||||
guild.credits.workRate = workRate !== null ? workRate : guild.credits.workRate;
|
||||
// eslint-disable-next-line max-len
|
||||
guild.credits.workTimeout = workTimeout !== null ? workTimeout : guild.credits.workTimeout;
|
||||
// eslint-disable-next-line max-len
|
||||
guild.credits.minimumLength = minimumLength !== null ? minimumLength : guild.credits.minimumLength;
|
||||
|
||||
|
@ -27,7 +33,14 @@ module.exports = async (interaction) => {
|
|||
title: 'Credits',
|
||||
description: 'Following settings is set',
|
||||
color: config.colors.success,
|
||||
fields: [{ name: 'Status', value: `${guild.credits.status}`, inline: true }, { name: 'URL', value: `${guild.credits.url}`, inline: true }, { name: 'Token', value: `${guild.credits.token}` }, { name: 'Rate', value: `${guild.credits.rate}`, inline: true }, { name: 'Minimum Length', value: `${guild.credits.minimumLength}`, inline: true }, { name: 'Timeout', value: `${guild.credits.timeout}`, inline: true }],
|
||||
fields: [{ name: 'Status', value: `${guild.credits.status}`, inline: true },
|
||||
{ name: 'URL', value: `${guild.credits.url}`, inline: true },
|
||||
{ name: 'Token', value: `${guild.credits.token}` },
|
||||
{ name: 'Rate', value: `${guild.credits.rate}`, inline: true },
|
||||
{ name: 'Minimum Length', value: `${guild.credits.minimumLength}`, inline: true },
|
||||
{ name: 'Timeout', value: `${guild.credits.timeout}`, inline: true },
|
||||
{ name: 'Work Rate', value: `${guild.credits.workRate}`, inline: true },
|
||||
{ name: 'Work Timeout', value: `${guild.credits.workTimeout}`, inline: true }],
|
||||
timestamp: new Date(),
|
||||
footer: { iconURL: config.footer.icon, text: config.footer.text },
|
||||
};
|
||||
|
|
65
src/commands/credits/addons/work.js
Normal file
65
src/commands/credits/addons/work.js
Normal file
|
@ -0,0 +1,65 @@
|
|||
const config = require('../../../../config.json');
|
||||
const logger = require('../../../handlers/logger');
|
||||
const guilds = require('../../../helpers/database/models/guildSchema');
|
||||
const credits = require('../../../helpers/database/models/creditSchema');
|
||||
const creditNoun = require('../../../helpers/creditNoun');
|
||||
|
||||
const workedRecently = new Set();
|
||||
|
||||
// eslint-disable-next-line consistent-return
|
||||
module.exports = async (interaction) => {
|
||||
try {
|
||||
const guild = await guilds.findOne({ guildId: interaction.member.guild.id });
|
||||
if (!workedRecently.has(interaction.member.id)) {
|
||||
const creditsEarned = Math.floor(Math.random() * guild.credits.workRate);
|
||||
await credits
|
||||
.findOneAndUpdate(
|
||||
{ userId: interaction.member.id, guildId: interaction.member.guild.id },
|
||||
{ $inc: { balance: creditsEarned } },
|
||||
{ new: true, upsert: true },
|
||||
)
|
||||
.then(async () => {
|
||||
logger.debug(`Credits added to user: ${interaction.member.id}`);
|
||||
const embed = {
|
||||
title: 'Work',
|
||||
description: `You earned ${creditNoun(creditsEarned)}`,
|
||||
color: config.colors.success,
|
||||
timestamp: new Date(),
|
||||
footer: { iconURL: config.footer.icon, text: config.footer.text },
|
||||
};
|
||||
|
||||
return interaction.editReply({ embeds: [embed], ephemeral: true });
|
||||
})
|
||||
.catch(async (err) => {
|
||||
await logger.error(err);
|
||||
});
|
||||
|
||||
workedRecently.add(interaction.member.id);
|
||||
setTimeout(() => {
|
||||
logger.debug(
|
||||
`User: ${interaction.member.id} has not worked within last ${
|
||||
guild.credits.workTimeout / 1000
|
||||
} seconds, work can be runned`,
|
||||
);
|
||||
workedRecently.delete(interaction.member.id);
|
||||
}, guild.credits.timeout);
|
||||
} else {
|
||||
logger.debug(
|
||||
`User: ${interaction.member.id} has already worked within last ${
|
||||
guild.credits.workTimeout / 1000
|
||||
} seconds, no work is runned`,
|
||||
);
|
||||
const embed = {
|
||||
title: 'Work',
|
||||
description: `You can not work now, wait ${guild.credits.workTimeout / 1000} seconds until timeout is out.`,
|
||||
color: config.colors.error,
|
||||
timestamp: new Date(),
|
||||
footer: { iconURL: config.footer.icon, text: config.footer.text },
|
||||
};
|
||||
|
||||
return interaction.editReply({ embeds: [embed], ephemeral: true });
|
||||
}
|
||||
} catch (e) {
|
||||
await logger.error(e);
|
||||
}
|
||||
};
|
|
@ -13,6 +13,7 @@ const top = require('./addons/top');
|
|||
const transfer = require('./addons/transfer');
|
||||
const set = require('./addons/set');
|
||||
const settings = require('./addons/settings');
|
||||
const work = require('./addons/work');
|
||||
|
||||
module.exports = {
|
||||
permissions: new Permissions([
|
||||
|
@ -78,24 +79,17 @@ module.exports = {
|
|||
.addSubcommand((subcommand) => subcommand
|
||||
.setName('settings')
|
||||
.setDescription('Manage credit settings. (ADMIN)')
|
||||
.addBooleanOption((option) => option
|
||||
.setName('status')
|
||||
.setDescription('Toggle credits.'))
|
||||
.addStringOption((option) => option
|
||||
.setName('url')
|
||||
.setDescription('Controlpanel.gg URL.'))
|
||||
.addStringOption((option) => option
|
||||
.setName('token')
|
||||
.setDescription('Controlpanel.gg token.'))
|
||||
.addNumberOption((option) => option
|
||||
.setName('rate')
|
||||
.setDescription('Credits rate.'))
|
||||
.addNumberOption((option) => option
|
||||
.setName('minimum-length')
|
||||
.setDescription('Minimum length for credits.'))
|
||||
.addNumberOption((option) => option
|
||||
.setName('timeout')
|
||||
.setDescription('Timeout between credits (milliseconds).'))),
|
||||
.addBooleanOption((option) => option.setName('status').setDescription('Toggle credits.'))
|
||||
.addStringOption((option) => option.setName('url').setDescription('Controlpanel.gg URL.'))
|
||||
.addStringOption((option) => option.setName('token').setDescription('Controlpanel.gg token.'))
|
||||
.addNumberOption((option) => option.setName('rate').setDescription('Credits rate.'))
|
||||
.addNumberOption((option) => option.setName('minimum-length').setDescription('Minimum length for credits.'))
|
||||
.addNumberOption((option) => option.setName('work-rate').setDescription('Work rate (rate).'))
|
||||
.addNumberOption((option) => option.setName('work-timeout').setDescription('Timeout between working for credits (milliseconds).'))
|
||||
.addNumberOption((option) => option.setName('timeout').setDescription('Timeout between credits (milliseconds).')))
|
||||
.addSubcommand((subcommand) => subcommand
|
||||
.setName('work')
|
||||
.setDescription('Work for credits.')),
|
||||
async execute(interaction) {
|
||||
const guild = await guilds.findOne({ guildId: interaction.member.guild.id });
|
||||
|
||||
|
@ -130,6 +124,8 @@ module.exports = {
|
|||
await transfer(interaction);
|
||||
} else if (interaction.options.getSubcommand() === 'set') {
|
||||
await set(interaction);
|
||||
} else if (interaction.options.getSubcommand() === 'work') {
|
||||
await work(interaction);
|
||||
}
|
||||
return true;
|
||||
},
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
const config = require('../../config.json');
|
||||
const logger = require('../handlers/logger');
|
||||
|
||||
const guilds = require('../helpers/database/models/guildSchema');
|
||||
|
@ -6,8 +5,14 @@ const guilds = require('../helpers/database/models/guildSchema');
|
|||
module.exports = {
|
||||
name: 'interactionCreate',
|
||||
async execute(guild) {
|
||||
const guildExist = await guilds.findOne({ guildId: guild.id });
|
||||
const guildExist = await guilds.findOne({ guildId: guild.id })
|
||||
.then(logger.debug(`Found guild: ${guild.id}`))
|
||||
.catch(logger.error);
|
||||
|
||||
if (!guildExist) { await guilds.create({ guildId: guild.id }); }
|
||||
if (!guildExist) {
|
||||
await guilds.create({ guildId: guild.id })
|
||||
.then(() => logger.debug(`Create guild: ${guild.id} was success`))
|
||||
.catch((e) => logger.error(e));
|
||||
}
|
||||
},
|
||||
};
|
||||
|
|
|
@ -28,6 +28,12 @@ const guildSchema = new mongoose.Schema(
|
|||
timeout: {
|
||||
type: mongoose.SchemaTypes.Number, default: 5000,
|
||||
},
|
||||
workRate: {
|
||||
type: mongoose.SchemaTypes.Number, default: 15,
|
||||
},
|
||||
workTimeout: {
|
||||
type: mongoose.SchemaTypes.Number, default: 900000,
|
||||
},
|
||||
},
|
||||
},
|
||||
{ timestamps: true },
|
||||
|
|
Loading…
Add table
Reference in a new issue