🎨 formatted files
This commit is contained in:
parent
8a48c44a80
commit
8f081f3863
20 changed files with 433 additions and 339 deletions
32
.eslintrc.js
32
.eslintrc.js
|
@ -1,16 +1,16 @@
|
|||
module.exports = {
|
||||
env: {
|
||||
es6: true,
|
||||
browser: true,
|
||||
es2021: true,
|
||||
},
|
||||
extends: ['airbnb-base', 'prettier'],
|
||||
parserOptions: {
|
||||
ecmaVersion: 12,
|
||||
sourceType: 'module',
|
||||
},
|
||||
rules: {
|
||||
'prettier/prettier': 'error',
|
||||
},
|
||||
plugins: ['prettier'],
|
||||
};
|
||||
module.exports = {
|
||||
env: {
|
||||
es6: true,
|
||||
browser: true,
|
||||
es2021: true,
|
||||
},
|
||||
extends: ['airbnb-base', 'prettier'],
|
||||
parserOptions: {
|
||||
ecmaVersion: 12,
|
||||
sourceType: 'module',
|
||||
},
|
||||
rules: {
|
||||
'prettier/prettier': 'error',
|
||||
},
|
||||
plugins: ['prettier'],
|
||||
};
|
||||
|
|
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.*
|
||||
|
|
13
.prettierrc
13
.prettierrc
|
@ -1,7 +1,6 @@
|
|||
{
|
||||
"trailingComma": "es5",
|
||||
"tabWidth": 2,
|
||||
"printWidth": 100,
|
||||
"semi": true,
|
||||
"singleQuote": true
|
||||
}
|
||||
{
|
||||
"trailingComma": "es5",
|
||||
"tabWidth": 2,
|
||||
"semi": true,
|
||||
"singleQuote": true
|
||||
}
|
||||
|
|
46
README.md
46
README.md
|
@ -1,23 +1,23 @@
|
|||
# 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!**
|
||||
|
||||
## Add it to your server
|
||||
|
||||
We have a official bot for this repository. [Invite bot!](https://discord.com/api/oauth2/authorize?client_id=949998000401436673&permissions=8&scope=bot%20applications.commands)
|
||||
# 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!**
|
||||
|
||||
## Add it to your server
|
||||
|
||||
We have a official bot for this repository. [Invite bot!](https://discord.com/api/oauth2/authorize?client_id=949998000401436673&permissions=8&scope=bot%20applications.commands)
|
||||
|
|
|
@ -1,34 +1,23 @@
|
|||
{
|
||||
"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"
|
||||
},
|
||||
"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
|
||||
}
|
||||
|
|
0
log.json
0
log.json
92
package.json
92
package.json
|
@ -1,46 +1,46 @@
|
|||
{
|
||||
"name": "xyter",
|
||||
"version": "3.1.0",
|
||||
"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.28.0",
|
||||
"discord.js": "^13.6.0",
|
||||
"dotenv": "^16.0.0",
|
||||
"i18next": "^21.6.13",
|
||||
"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-config-prettier": "8.5.0",
|
||||
"eslint-plugin-import": "2.25.4"
|
||||
}
|
||||
}
|
||||
{
|
||||
"name": "xyter",
|
||||
"version": "3.1.0",
|
||||
"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.28.0",
|
||||
"discord.js": "^13.6.0",
|
||||
"dotenv": "^16.0.0",
|
||||
"i18next": "^21.6.13",
|
||||
"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-config-prettier": "8.5.0",
|
||||
"eslint-plugin-import": "2.25.4"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -45,14 +45,18 @@ module.exports = async (interaction) => {
|
|||
|
||||
// Get toUser object
|
||||
|
||||
const toUser = await credits.findOne({ userId: user.id, guildId: interaction.member.guild.id });
|
||||
const toUser = await credits.findOne({
|
||||
userId: user.id,
|
||||
guildId: interaction.member.guild.id,
|
||||
});
|
||||
|
||||
// Stop if user has zero or below credits
|
||||
|
||||
if (!toUser) {
|
||||
const embed = {
|
||||
title: 'Give',
|
||||
description: 'That user has no credits, I can not give credits to the user',
|
||||
description:
|
||||
'That user has no credits, I can not give credits to the user',
|
||||
color: config.colors.error,
|
||||
timestamp: new Date(),
|
||||
footer: { iconURL: config.footer.icon, text: config.footer.text },
|
||||
|
@ -86,7 +90,9 @@ module.exports = async (interaction) => {
|
|||
// Send debug message
|
||||
|
||||
await logger.debug(
|
||||
`Guild: ${member.guild.id} User: ${member.id} gave ${user.id} ${creditNoun(amount)}.`
|
||||
`Guild: ${member.guild.id} User: ${member.id} gave ${
|
||||
user.id
|
||||
} ${creditNoun(amount)}.`
|
||||
);
|
||||
});
|
||||
};
|
||||
|
|
|
@ -45,14 +45,18 @@ module.exports = async (interaction) => {
|
|||
|
||||
// Get toUser object
|
||||
|
||||
const toUser = await credits.findOne({ userId: user.id, guildId: interaction.member.guild.id });
|
||||
const toUser = await credits.findOne({
|
||||
userId: user.id,
|
||||
guildId: interaction.member.guild.id,
|
||||
});
|
||||
|
||||
// Stop if user has zero or below credits
|
||||
|
||||
if (!toUser) {
|
||||
const embed = {
|
||||
title: 'Set',
|
||||
description: 'That user has no credits, I can not set credits to the user',
|
||||
description:
|
||||
'That user has no credits, I can not set credits to the user',
|
||||
color: config.colors.error,
|
||||
timestamp: new Date(),
|
||||
footer: { iconURL: config.footer.icon, text: config.footer.text },
|
||||
|
@ -86,7 +90,9 @@ module.exports = async (interaction) => {
|
|||
// Send debug message
|
||||
|
||||
await logger.debug(
|
||||
`Guild: ${member.guild.id} User: ${member.id} set ${user.id} to ${creditNoun(amount)}.`
|
||||
`Guild: ${member.guild.id} User: ${member.id} set ${
|
||||
user.id
|
||||
} to ${creditNoun(amount)}.`
|
||||
);
|
||||
});
|
||||
};
|
||||
|
|
|
@ -45,14 +45,18 @@ module.exports = async (interaction) => {
|
|||
|
||||
// Get toUser object
|
||||
|
||||
const toUser = await credits.findOne({ userId: user.id, guildId: interaction.member.guild.id });
|
||||
const toUser = await credits.findOne({
|
||||
userId: user.id,
|
||||
guildId: interaction.member.guild.id,
|
||||
});
|
||||
|
||||
// Stop if user has zero or below credits
|
||||
|
||||
if (!toUser) {
|
||||
const embed = {
|
||||
title: 'Take',
|
||||
description: 'That user has no credits, I can not take credits from the user',
|
||||
description:
|
||||
'That user has no credits, I can not take credits from the user',
|
||||
color: config.colors.error,
|
||||
timestamp: new Date(),
|
||||
footer: { iconURL: config.footer.icon, text: config.footer.text },
|
||||
|
@ -86,7 +90,9 @@ module.exports = async (interaction) => {
|
|||
// Send debug message
|
||||
|
||||
await logger.debug(
|
||||
`Guild: ${member.guild.id} User: ${member.id} took ${creditNoun(amount)} from ${user.id}.`
|
||||
`Guild: ${member.guild.id} User: ${member.id} took ${creditNoun(
|
||||
amount
|
||||
)} from ${user.id}.`
|
||||
);
|
||||
});
|
||||
};
|
||||
|
|
|
@ -34,18 +34,25 @@ module.exports = async (interaction) => {
|
|||
|
||||
// Get fromUser object
|
||||
|
||||
const fromUser = await credits.findOne({ userId: from.id, guildId: interaction.member.guild.id });
|
||||
const fromUser = await credits.findOne({
|
||||
userId: from.id,
|
||||
guildId: interaction.member.guild.id,
|
||||
});
|
||||
|
||||
// Get toUser object
|
||||
|
||||
const toUser = await credits.findOne({ userId: to.id, guildId: interaction.member.guild.id });
|
||||
const toUser = await credits.findOne({
|
||||
userId: to.id,
|
||||
guildId: interaction.member.guild.id,
|
||||
});
|
||||
|
||||
// Stop if fromUser has zero credits or below
|
||||
|
||||
if (!fromUser) {
|
||||
const embed = {
|
||||
title: 'Transfer',
|
||||
description: 'That user has no credits, I can not transfer credits from the user',
|
||||
description:
|
||||
'That user has no credits, I can not transfer credits from the user',
|
||||
color: config.colors.error,
|
||||
timestamp: new Date(),
|
||||
footer: { iconURL: config.footer.icon, text: config.footer.text },
|
||||
|
@ -58,7 +65,8 @@ module.exports = async (interaction) => {
|
|||
if (!toUser) {
|
||||
const embed = {
|
||||
title: 'Transfer',
|
||||
description: 'That user has no credits, I can not transfer credits to the user',
|
||||
description:
|
||||
'That user has no credits, I can not transfer credits to the user',
|
||||
color: config.colors.error,
|
||||
timestamp: new Date(),
|
||||
footer: { iconURL: config.footer.icon, text: config.footer.text },
|
||||
|
@ -115,9 +123,9 @@ module.exports = async (interaction) => {
|
|||
// Send debug message
|
||||
|
||||
await logger.debug(
|
||||
`Guild: ${member.guild.id} User: ${member.id} transferred ${creditNoun(amount)} from ${
|
||||
from.id
|
||||
} to ${to.id}.`
|
||||
`Guild: ${member.guild.id} User: ${member.id} transferred ${creditNoun(
|
||||
amount
|
||||
)} from ${from.id} to ${to.id}.`
|
||||
);
|
||||
});
|
||||
};
|
||||
|
|
|
@ -16,10 +16,16 @@ module.exports = {
|
|||
.setName('give')
|
||||
.setDescription('Give credits to a user')
|
||||
.addUserOption((option) =>
|
||||
option.setName('user').setDescription('The user you want to pay.').setRequired(true)
|
||||
option
|
||||
.setName('user')
|
||||
.setDescription('The user you want to pay.')
|
||||
.setRequired(true)
|
||||
)
|
||||
.addIntegerOption((option) =>
|
||||
option.setName('amount').setDescription('The amount you will pay.').setRequired(true)
|
||||
option
|
||||
.setName('amount')
|
||||
.setDescription('The amount you will pay.')
|
||||
.setRequired(true)
|
||||
)
|
||||
)
|
||||
.addSubcommand((command) =>
|
||||
|
@ -33,7 +39,10 @@ module.exports = {
|
|||
.setRequired(true)
|
||||
)
|
||||
.addIntegerOption((option) =>
|
||||
option.setName('amount').setDescription('The amount you will set.').setRequired(true)
|
||||
option
|
||||
.setName('amount')
|
||||
.setDescription('The amount you will set.')
|
||||
.setRequired(true)
|
||||
)
|
||||
)
|
||||
.addSubcommand((command) =>
|
||||
|
@ -47,7 +56,10 @@ module.exports = {
|
|||
.setRequired(true)
|
||||
)
|
||||
.addIntegerOption((option) =>
|
||||
option.setName('amount').setDescription('The amount you will take.').setRequired(true)
|
||||
option
|
||||
.setName('amount')
|
||||
.setDescription('The amount you will take.')
|
||||
.setRequired(true)
|
||||
)
|
||||
)
|
||||
.addSubcommand((command) =>
|
||||
|
|
|
@ -30,7 +30,9 @@ module.exports = async (interaction) => {
|
|||
|
||||
const embed = {
|
||||
title: 'Balance',
|
||||
description: `${user ? `${user} has` : 'You have'} ${creditNoun(balance)}.`,
|
||||
description: `${user ? `${user} has` : 'You have'} ${creditNoun(
|
||||
balance
|
||||
)}.`,
|
||||
color: config.colors.success,
|
||||
timestamp: new Date(),
|
||||
footer: { iconURL: config.footer.icon, text: config.footer.text },
|
||||
|
|
|
@ -52,12 +52,16 @@ module.exports = async (interaction) => {
|
|||
userId: interaction.user.id,
|
||||
guildId: interaction.member.guild.id,
|
||||
});
|
||||
const toUser = await credits.findOne({ userId: user.id, guildId: interaction.member.guild.id });
|
||||
const toUser = await credits.findOne({
|
||||
userId: user.id,
|
||||
guildId: interaction.member.guild.id,
|
||||
});
|
||||
|
||||
if (!toUser) {
|
||||
const embed = {
|
||||
title: 'Gift',
|
||||
description: 'That user has no credits, I can not gift credits to the user',
|
||||
description:
|
||||
'That user has no credits, I can not gift credits to the user',
|
||||
color: config.colors.error,
|
||||
timestamp: new Date(),
|
||||
footer: { iconURL: config.footer.icon, text: config.footer.text },
|
||||
|
@ -80,7 +84,9 @@ module.exports = async (interaction) => {
|
|||
};
|
||||
const dmEmbed = {
|
||||
title: 'Gift',
|
||||
description: `You received ${creditNoun(amount)} from ${interaction.user}${
|
||||
description: `You received ${creditNoun(amount)} from ${
|
||||
interaction.user
|
||||
}${
|
||||
reason ? ` with reason: ${reason}` : ''
|
||||
}. Your new balance is ${creditNoun(toUser.balance)}.`,
|
||||
color: 0x22bb33,
|
||||
|
@ -89,8 +95,13 @@ module.exports = async (interaction) => {
|
|||
};
|
||||
const dmUser = await interaction.client.users.cache.get(user.id);
|
||||
await dmUser.send({ embeds: [dmEmbed] });
|
||||
await logger.debug(`Gift sent from: ${interaction.user.username} to: ${user.username}`);
|
||||
return await interaction.editReply({ embeds: [interactionEmbed], ephemeral: true });
|
||||
await logger.debug(
|
||||
`Gift sent from: ${interaction.user.username} to: ${user.username}`
|
||||
);
|
||||
return await interaction.editReply({
|
||||
embeds: [interactionEmbed],
|
||||
ephemeral: true,
|
||||
});
|
||||
} catch (e) {
|
||||
await logger.error(e);
|
||||
}
|
||||
|
|
|
@ -27,7 +27,9 @@ module.exports = async (interaction) => {
|
|||
userId: interaction.user.id,
|
||||
guildId: interaction.member.guild.id,
|
||||
});
|
||||
const dmUser = interaction.client.users.cache.get(interaction.member.user.id);
|
||||
const dmUser = interaction.client.users.cache.get(
|
||||
interaction.member.user.id
|
||||
);
|
||||
|
||||
if ((amount || user.balance) < 100) {
|
||||
const embed = {
|
||||
|
@ -61,7 +63,9 @@ module.exports = async (interaction) => {
|
|||
}
|
||||
const code = uuidv4();
|
||||
|
||||
const apiCredentials = await apis.findOne({ guildId: interaction.member.guild.id });
|
||||
const apiCredentials = await apis.findOne({
|
||||
guildId: interaction.member.guild.id,
|
||||
});
|
||||
|
||||
const api = axios.create({
|
||||
baseURL: apiCredentials.url,
|
||||
|
@ -78,7 +82,9 @@ module.exports = async (interaction) => {
|
|||
.then(async () => {
|
||||
const dmEmbed = {
|
||||
title: 'Redeem',
|
||||
description: `Your new balance is ${user.balance - (amount || user.balance)}.`,
|
||||
description: `Your new balance is ${
|
||||
user.balance - (amount || user.balance)
|
||||
}.`,
|
||||
fields: [
|
||||
{ name: 'Code', value: `${code}`, inline: true },
|
||||
{
|
||||
|
@ -102,9 +108,14 @@ module.exports = async (interaction) => {
|
|||
|
||||
await user.save();
|
||||
|
||||
await logger.debug(`User: ${user.username} redeemed: ${creditNoun(amount)}`);
|
||||
await logger.debug(
|
||||
`User: ${user.username} redeemed: ${creditNoun(amount)}`
|
||||
);
|
||||
await dmUser.send({ embeds: [dmEmbed] });
|
||||
await interaction.editReply({ embeds: [interactionEmbed], ephemeral: true });
|
||||
await interaction.editReply({
|
||||
embeds: [interactionEmbed],
|
||||
ephemeral: true,
|
||||
});
|
||||
})
|
||||
.catch(async (e) => {
|
||||
await logger.error(e);
|
||||
|
|
|
@ -3,18 +3,25 @@ const credits = require('../../../helpers/database/models/creditSchema');
|
|||
const creditNoun = require('../../../helpers/creditNoun');
|
||||
|
||||
module.exports = async (interaction) => {
|
||||
await credits.find({ guildId: interaction.member.guild.id }).then(async (data) => {
|
||||
const topTen = data.sort((a, b) => (a.balance > b.balance ? -1 : 1)).slice(0, 10);
|
||||
await credits
|
||||
.find({ guildId: interaction.member.guild.id })
|
||||
.then(async (data) => {
|
||||
const topTen = data
|
||||
.sort((a, b) => (a.balance > b.balance ? -1 : 1))
|
||||
.slice(0, 10);
|
||||
|
||||
const item = (x, index) => `**Top ${index + 1}** - <@${x.userId}> ${creditNoun(x.balance)}`;
|
||||
const item = (x, index) =>
|
||||
`**Top ${index + 1}** - <@${x.userId}> ${creditNoun(x.balance)}`;
|
||||
|
||||
const embed = {
|
||||
title: 'Balance Top',
|
||||
description: `Below are the top ten.\n${topTen.map((x, index) => item(x, index)).join('\n')}`,
|
||||
color: 0x22bb33,
|
||||
timestamp: new Date(),
|
||||
footer: { iconURL: config.footer.icon, text: config.footer.text },
|
||||
};
|
||||
return interaction.editReply({ embeds: [embed], ephemeral: true });
|
||||
});
|
||||
const embed = {
|
||||
title: 'Balance Top',
|
||||
description: `Below are the top ten.\n${topTen
|
||||
.map((x, index) => item(x, index))
|
||||
.join('\n')}`,
|
||||
color: 0x22bb33,
|
||||
timestamp: new Date(),
|
||||
footer: { iconURL: config.footer.icon, text: config.footer.text },
|
||||
};
|
||||
return interaction.editReply({ embeds: [embed], ephemeral: true });
|
||||
});
|
||||
};
|
||||
|
|
|
@ -1,6 +1,10 @@
|
|||
const config = require('../../../../config.json');
|
||||
const logger = require('../../../handlers/logger');
|
||||
const { guilds, credits, timeouts } = require('../../../helpers/database/models');
|
||||
const {
|
||||
guilds,
|
||||
credits,
|
||||
timeouts,
|
||||
} = require('../../../helpers/database/models');
|
||||
const creditNoun = require('../../../helpers/creditNoun');
|
||||
|
||||
const workedRecently = new Set();
|
||||
|
@ -20,7 +24,9 @@ module.exports = async (interaction) => {
|
|||
// If user is not on timeout
|
||||
|
||||
if (!isTimeout) {
|
||||
const guild = await guilds.findOne({ guildId: interaction.member.guild.id });
|
||||
const guild = await guilds.findOne({
|
||||
guildId: interaction.member.guild.id,
|
||||
});
|
||||
|
||||
const creditsEarned = Math.floor(Math.random() * guild.credits.workRate);
|
||||
await credits
|
||||
|
@ -55,7 +61,9 @@ module.exports = async (interaction) => {
|
|||
|
||||
setTimeout(async () => {
|
||||
await logger.debug(
|
||||
`Guild: ${member.guild.id} User: ${member.id} has not worked within the last ${
|
||||
`Guild: ${member.guild.id} User: ${
|
||||
member.id
|
||||
} has not worked within the last ${
|
||||
guild.work.timeout / 1000
|
||||
} seconds, work can be done`
|
||||
);
|
||||
|
|
|
@ -30,7 +30,9 @@ module.exports = {
|
|||
.setName('redeem')
|
||||
.setDescription('Redeem your credits.')
|
||||
.addIntegerOption((option) =>
|
||||
option.setName('amount').setDescription('How much credit you want to withdraw.')
|
||||
option
|
||||
.setName('amount')
|
||||
.setDescription('How much credit you want to withdraw.')
|
||||
)
|
||||
)
|
||||
.addSubcommand((subcommand) =>
|
||||
|
@ -38,21 +40,36 @@ module.exports = {
|
|||
.setName('gift')
|
||||
.setDescription('Gift someone credits from your credits.')
|
||||
.addUserOption((option) =>
|
||||
option.setName('user').setDescription('The user you want to pay.').setRequired(true)
|
||||
option
|
||||
.setName('user')
|
||||
.setDescription('The user you want to pay.')
|
||||
.setRequired(true)
|
||||
)
|
||||
.addIntegerOption((option) =>
|
||||
option.setName('amount').setDescription('The amount you will pay.').setRequired(true)
|
||||
option
|
||||
.setName('amount')
|
||||
.setDescription('The amount you will pay.')
|
||||
.setRequired(true)
|
||||
)
|
||||
.addStringOption((option) =>
|
||||
option.setName('reason').setDescription('Your reason.')
|
||||
)
|
||||
.addStringOption((option) => option.setName('reason').setDescription('Your reason.'))
|
||||
)
|
||||
.addSubcommand((subcommand) =>
|
||||
subcommand.setName('top').setDescription('Check the top balance.')
|
||||
)
|
||||
.addSubcommand((subcommand) => subcommand.setName('work').setDescription('Work for credits.')),
|
||||
.addSubcommand((subcommand) =>
|
||||
subcommand.setName('work').setDescription('Work for credits.')
|
||||
),
|
||||
async execute(interaction) {
|
||||
const guild = await guilds.findOne({ guildId: interaction.member.guild.id });
|
||||
const guild = await guilds.findOne({
|
||||
guildId: interaction.member.guild.id,
|
||||
});
|
||||
|
||||
if (guild.credits.status === false && interaction.options.getSubcommand() !== 'settings') {
|
||||
if (
|
||||
guild.credits.status === false &&
|
||||
interaction.options.getSubcommand() !== 'settings'
|
||||
) {
|
||||
const embed = {
|
||||
title: 'Credits',
|
||||
description: 'Please enable credits by ``/credits settings``',
|
||||
|
|
27
src/helpers/database/models/profileSchema.js
Normal file
27
src/helpers/database/models/profileSchema.js
Normal file
|
@ -0,0 +1,27 @@
|
|||
const mongoose = require('mongoose');
|
||||
|
||||
const profileSchema = new mongoose.Schema(
|
||||
{
|
||||
userId: {
|
||||
type: mongoose.SchemaTypes.Decimal128,
|
||||
required: true,
|
||||
unique: false,
|
||||
index: true,
|
||||
},
|
||||
url: {
|
||||
type: mongoose.SchemaTypes.String,
|
||||
required: true,
|
||||
unique: false,
|
||||
index: true,
|
||||
},
|
||||
token: {
|
||||
type: mongoose.SchemaTypes.String,
|
||||
required: true,
|
||||
unique: false,
|
||||
index: true,
|
||||
},
|
||||
},
|
||||
{ timestamps: true }
|
||||
);
|
||||
|
||||
module.exports = mongoose.model('profile', profileSchema);
|
33
src/index.js
33
src/index.js
|
@ -1,16 +1,19 @@
|
|||
/* eslint-disable no-restricted-syntax */
|
||||
const fs = require('fs');
|
||||
const { Client, Collection, Intents } = require('discord.js');
|
||||
|
||||
require('./deploy-commands')();
|
||||
require('./helpers/database')();
|
||||
require('./handlers/locale')();
|
||||
|
||||
const fs = require('fs');
|
||||
const { Client, Collection, Intents } = require('discord.js');
|
||||
|
||||
const config = require('../config.json');
|
||||
|
||||
const client = new Client({ intents: [Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_MESSAGES] });
|
||||
const client = new Client({
|
||||
intents: [Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_MESSAGES],
|
||||
});
|
||||
|
||||
const eventFiles = fs.readdirSync('./src/events').filter((file) => file.endsWith('.js'));
|
||||
const eventFiles = fs
|
||||
.readdirSync('./src/events')
|
||||
.filter((file) => file.endsWith('.js'));
|
||||
|
||||
client.commands = new Collection();
|
||||
const commandFiles = fs.readdirSync('./src/commands');
|
||||
|
@ -21,24 +24,6 @@ for (const file of commandFiles) {
|
|||
client.commands.set(command.data.name, command);
|
||||
}
|
||||
|
||||
// client.buttons = new Collection();
|
||||
// const buttonFiles = fs.readdirSync('./src/buttons');
|
||||
|
||||
// for (const file of buttonFiles) {
|
||||
// // eslint-disable-next-line import/no-dynamic-require, global-require
|
||||
// const button = require(`./buttons/${file}`);
|
||||
// client.buttons.set(button.customId, button);
|
||||
// }
|
||||
|
||||
// client.menus = new Collection();
|
||||
// const menuFiles = fs.readdirSync('./src/menus');
|
||||
|
||||
// for (const file of menuFiles) {
|
||||
// // eslint-disable-next-line import/no-dynamic-require, global-require
|
||||
// const menu = require(`./menus/${file}`);
|
||||
// client.menus.set(menu.customId, menu);
|
||||
// }
|
||||
|
||||
for (const file of eventFiles) {
|
||||
// eslint-disable-next-line import/no-dynamic-require, global-require
|
||||
const event = require(`./events/${file}`);
|
||||
|
|
Loading…
Add table
Reference in a new issue