🚧 TypeScript rewrite
This commit is contained in:
parent
e05468b417
commit
0503b8d1ec
104 changed files with 3743 additions and 3755 deletions
16
.eslintrc
16
.eslintrc
|
@ -1,16 +0,0 @@
|
|||
{
|
||||
"env": {
|
||||
"es6": true,
|
||||
"browser": true,
|
||||
"es2021": true
|
||||
},
|
||||
"extends": ["airbnb-base", "prettier"],
|
||||
"parserOptions": {
|
||||
"ecmaVersion": 12,
|
||||
"sourceType": "module"
|
||||
},
|
||||
"rules": {
|
||||
"prettier/prettier": "error"
|
||||
},
|
||||
"plugins": ["prettier"]
|
||||
}
|
18
.eslintrc.json
Normal file
18
.eslintrc.json
Normal file
|
@ -0,0 +1,18 @@
|
|||
{
|
||||
"root": true,
|
||||
"parser": "@typescript-eslint/parser",
|
||||
"plugins": ["@typescript-eslint", "prettier"],
|
||||
"extends": [
|
||||
"eslint:recommended",
|
||||
"plugin:@typescript-eslint/eslint-recommended",
|
||||
"plugin:@typescript-eslint/recommended",
|
||||
"prettier"
|
||||
],
|
||||
"rules": {
|
||||
"@typescript-eslint/ban-ts-comment": 0,
|
||||
"@typescript-eslint/no-var-requires": 0,
|
||||
"@typescript-eslint/no-explicit-any": 0,
|
||||
"no-async-promise-executor": 0,
|
||||
"prettier/prettier": "error"
|
||||
}
|
||||
}
|
|
@ -1,7 +0,0 @@
|
|||
{
|
||||
"trailingComma": "es5",
|
||||
"tabWidth": 2,
|
||||
"tabs": true,
|
||||
"semi": true,
|
||||
"singleQuote": true
|
||||
}
|
30
.vscode/settings.json
vendored
30
.vscode/settings.json
vendored
|
@ -1,16 +1,14 @@
|
|||
{
|
||||
"editor.defaultFormatter": "esbenp.prettier-vscode",
|
||||
"editor.wordWrapColumn": 100,
|
||||
"editor.tabSize": 2,
|
||||
"editor.formatOnSave": true,
|
||||
"javascript.format.enable": false,
|
||||
"files.eol": "\n",
|
||||
"prettier.endOfLine": "lf",
|
||||
"prettier.singleQuote": true,
|
||||
"prettier.trailingComma": "es5",
|
||||
"peacock.color": "#369",
|
||||
"editor.codeActionsOnSave": {
|
||||
"source.fixAll.eslint": true
|
||||
},
|
||||
"editor.codeActionsOnSave": ["source.formatDocument", "source.fixAll.eslint"],
|
||||
"cSpell.words": [
|
||||
"Controlpanel",
|
||||
"discordjs",
|
||||
|
@ -28,7 +26,27 @@
|
|||
"editor.fontFamily": "Cascadia Code",
|
||||
"editor.fontLigatures": true,
|
||||
"git.enableCommitSigning": true,
|
||||
"files.associations": {
|
||||
"*.yaml": "home-assistant"
|
||||
"typescript.tsdk": "node_modules\\typescript\\lib",
|
||||
"[typescript]": {
|
||||
"editor.defaultFormatter": "esbenp.prettier-vscode"
|
||||
},
|
||||
"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",
|
||||
"statusBar.background": "#336699",
|
||||
"statusBar.foreground": "#e7e7e7",
|
||||
"statusBarItem.hoverBackground": "#407fbf",
|
||||
"statusBarItem.remoteBackground": "#336699",
|
||||
"statusBarItem.remoteForeground": "#e7e7e7",
|
||||
"titleBar.activeBackground": "#336699",
|
||||
"titleBar.activeForeground": "#e7e7e7",
|
||||
"titleBar.inactiveBackground": "#33669999",
|
||||
"titleBar.inactiveForeground": "#e7e7e799"
|
||||
}
|
||||
}
|
||||
|
|
15
package.json
15
package.json
|
@ -2,7 +2,7 @@
|
|||
"name": "xyter",
|
||||
"version": "3.1.0",
|
||||
"description": "Earn credits while chatting! And more",
|
||||
"main": "src/index.js",
|
||||
"main": "src/index.ts",
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1",
|
||||
"start": "nodemon | pino-pretty -i pid,hostname -t yyyy-mm-dd HH:MM:s"
|
||||
|
@ -28,6 +28,7 @@
|
|||
"@discordjs/rest": "^0.3.0",
|
||||
"axios": "^0.26.0",
|
||||
"better-sqlite3": "^7.5.0",
|
||||
"common": "^0.2.5",
|
||||
"dbd-dark-dashboard": "^1.6.45",
|
||||
"discord-api-types": "^0.28.0",
|
||||
"discord-dashboard": "^2.3.14",
|
||||
|
@ -42,9 +43,13 @@
|
|||
"uuid": "^8.3.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"eslint": "8.11.0",
|
||||
"eslint-config-airbnb-base": "15.0.0",
|
||||
"eslint-config-prettier": "8.5.0",
|
||||
"eslint-plugin-import": "2.25.4"
|
||||
"@typescript-eslint/eslint-plugin": "^5.15.0",
|
||||
"@typescript-eslint/parser": "^5.15.0",
|
||||
"eslint": "^8.11.0",
|
||||
"eslint-config-airbnb-base": "^15.0.0",
|
||||
"eslint-config-prettier": "^8.5.0",
|
||||
"eslint-plugin-import": "^2.25.4",
|
||||
"eslint-plugin-prettier": "^4.0.0",
|
||||
"prettier": "^2.6.0"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
const { Permissions } = require('discord.js');
|
||||
const config = require('../../../../../config.json');
|
||||
const logger = require('../../../../handlers/logger');
|
||||
import { Permissions } from 'discord.js';
|
||||
import config from '../../../../../config.json';
|
||||
import logger from '../../../../handlers/logger';
|
||||
|
||||
// Database models
|
||||
const { counters } = require('../../../../helpers/database/models');
|
||||
import { counters } from '../../../../helpers/database/models';
|
||||
|
||||
module.exports = async (interaction) => {
|
||||
export default async (interaction) => {
|
||||
// Destructure member
|
||||
const { member } = interaction;
|
||||
|
|
@ -1,4 +0,0 @@
|
|||
const add = require('./add');
|
||||
const remove = require('./remove');
|
||||
|
||||
module.exports = { add, remove };
|
4
src/commands/admin/counter/addons/index.ts
Normal file
4
src/commands/admin/counter/addons/index.ts
Normal file
|
@ -0,0 +1,4 @@
|
|||
import add from './add';
|
||||
import remove from './remove';
|
||||
|
||||
export default { add, remove };
|
|
@ -1,11 +1,11 @@
|
|||
const { Permissions } = require('discord.js');
|
||||
const config = require('../../../../../config.json');
|
||||
const logger = require('../../../../handlers/logger');
|
||||
import { Permissions } from 'discord.js';
|
||||
import config from '../../../../../config.json';
|
||||
import logger from '../../../../handlers/logger';
|
||||
|
||||
// Database models
|
||||
const { counters } = require('../../../../helpers/database/models');
|
||||
import { counters } from '../../../../helpers/database/models';
|
||||
|
||||
module.exports = async (interaction) => {
|
||||
export default async (interaction) => {
|
||||
// Destructure member
|
||||
const { member } = interaction;
|
||||
|
|
@ -1,10 +1,9 @@
|
|||
const { Permissions } = require('discord.js');
|
||||
const config = require('../../../../config.json');
|
||||
const logger = require('../../../handlers/logger');
|
||||
import { Permissions } from 'discord.js';
|
||||
import config from '../../../../config.json';
|
||||
import logger from '../../../handlers/logger';
|
||||
import { add, remove } from './addons';
|
||||
|
||||
const { add, remove } = require('./addons');
|
||||
|
||||
module.exports = async (interaction) => {
|
||||
export default async (interaction) => {
|
||||
// Destructure member
|
||||
const { member } = interaction;
|
||||
|
|
@ -1,13 +1,13 @@
|
|||
const { Permissions } = require('discord.js');
|
||||
const config = require('../../../../../config.json');
|
||||
const logger = require('../../../../handlers/logger');
|
||||
import { Permissions } from 'discord.js';
|
||||
import config from '../../../../../config.json';
|
||||
import logger from '../../../../handlers/logger';
|
||||
|
||||
// Database models
|
||||
const { users } = require('../../../../helpers/database/models');
|
||||
import { users } from '../../../../helpers/database/models';
|
||||
|
||||
const creditNoun = require('../../../../helpers/creditNoun');
|
||||
import creditNoun from '../../../../helpers/creditNoun';
|
||||
|
||||
module.exports = async (interaction) => {
|
||||
export default async (interaction) => {
|
||||
// Destructure member
|
||||
const { member } = interaction;
|
||||
const { guild } = member;
|
|
@ -1,11 +0,0 @@
|
|||
const give = require('./give');
|
||||
const set = require('./set');
|
||||
const take = require('./take');
|
||||
const transfer = require('./transfer');
|
||||
|
||||
module.exports = {
|
||||
give,
|
||||
set,
|
||||
take,
|
||||
transfer,
|
||||
};
|
11
src/commands/admin/credits/addons/index.ts
Normal file
11
src/commands/admin/credits/addons/index.ts
Normal file
|
@ -0,0 +1,11 @@
|
|||
import give from './give';
|
||||
import set from './set';
|
||||
import take from './take';
|
||||
import transfer from './transfer';
|
||||
|
||||
export default {
|
||||
give,
|
||||
set,
|
||||
take,
|
||||
transfer,
|
||||
};
|
|
@ -1,13 +1,14 @@
|
|||
const { Permissions } = require('discord.js');
|
||||
const config = require('../../../../../config.json');
|
||||
const logger = require('../../../../handlers/logger');
|
||||
import { Permissions } from 'discord.js';
|
||||
import config from '../../../../../config.json';
|
||||
import logger from '../../../../handlers/logger';
|
||||
|
||||
// Database models
|
||||
|
||||
const { users } = require('../../../../helpers/database/models');
|
||||
const creditNoun = require('../../../../helpers/creditNoun');
|
||||
import { users } from '../../../../helpers/database/models';
|
||||
|
||||
module.exports = async (interaction) => {
|
||||
import creditNoun from '../../../../helpers/creditNoun';
|
||||
|
||||
export default async (interaction) => {
|
||||
// Destructure member
|
||||
const { member } = interaction;
|
||||
|
|
@ -1,13 +1,14 @@
|
|||
const { Permissions } = require('discord.js');
|
||||
const config = require('../../../../../config.json');
|
||||
const logger = require('../../../../handlers/logger');
|
||||
import { Permissions } from 'discord.js';
|
||||
import config from '../../../../../config.json';
|
||||
import logger from '../../../../handlers/logger';
|
||||
|
||||
// Database models
|
||||
|
||||
const { users } = require('../../../../helpers/database/models');
|
||||
const creditNoun = require('../../../../helpers/creditNoun');
|
||||
import { users } from '../../../../helpers/database/models';
|
||||
|
||||
module.exports = async (interaction) => {
|
||||
import creditNoun from '../../../../helpers/creditNoun';
|
||||
|
||||
export default async (interaction) => {
|
||||
// Destructure member
|
||||
const { member } = interaction;
|
||||
|
|
@ -1,14 +1,15 @@
|
|||
const { Permissions } = require('discord.js');
|
||||
const config = require('../../../../../config.json');
|
||||
const logger = require('../../../../handlers/logger');
|
||||
import { Permissions } from 'discord.js';
|
||||
import config from '../../../../../config.json';
|
||||
import logger from '../../../../handlers/logger';
|
||||
|
||||
// Database models
|
||||
|
||||
const { users } = require('../../../../helpers/database/models');
|
||||
const creditNoun = require('../../../../helpers/creditNoun');
|
||||
const saveUser = require('../../../../helpers/saveUser');
|
||||
import { users } from '../../../../helpers/database/models';
|
||||
|
||||
module.exports = async (interaction) => {
|
||||
import creditNoun from '../../../../helpers/creditNoun';
|
||||
import saveUser from '../../../../helpers/saveUser';
|
||||
|
||||
export default async (interaction) => {
|
||||
// Destructure member
|
||||
const { member } = interaction;
|
||||
|
|
@ -1,10 +1,9 @@
|
|||
const { Permissions } = require('discord.js');
|
||||
const config = require('../../../../config.json');
|
||||
const logger = require('../../../handlers/logger');
|
||||
import { Permissions } from 'discord.js';
|
||||
import config from '../../../../config.json';
|
||||
import logger from '../../../handlers/logger';
|
||||
import { give, take, set, transfer } from './addons';
|
||||
|
||||
const { give, take, set, transfer } = require('./addons');
|
||||
|
||||
module.exports = async (interaction) => {
|
||||
export default async (interaction) => {
|
||||
// Destructure member
|
||||
const { member } = interaction;
|
||||
|
|
@ -1,9 +1,8 @@
|
|||
const { SlashCommandBuilder } = require('@discordjs/builders');
|
||||
import { SlashCommandBuilder } from '@discordjs/builders';
|
||||
import credits from './credits';
|
||||
import counter from './counter';
|
||||
|
||||
const credits = require('./credits');
|
||||
const counter = require('./counter');
|
||||
|
||||
module.exports = {
|
||||
export default {
|
||||
data: new SlashCommandBuilder()
|
||||
.setName('admin')
|
||||
.setDescription('Admin actions.')
|
|
@ -1,9 +1,8 @@
|
|||
const config = require('../../../../config.json');
|
||||
const logger = require('../../../handlers/logger');
|
||||
import config from '../../../../config.json';
|
||||
import logger from '../../../handlers/logger';
|
||||
import { counters } from '../../../helpers/database/models';
|
||||
|
||||
const { counters } = require('../../../helpers/database/models');
|
||||
|
||||
module.exports = async (interaction) => {
|
||||
export default async (interaction) => {
|
||||
try {
|
||||
// Destructure member
|
||||
const { member } = await interaction;
|
|
@ -1,8 +1,7 @@
|
|||
const { SlashCommandBuilder } = require('@discordjs/builders');
|
||||
import { SlashCommandBuilder } from '@discordjs/builders';
|
||||
import view from './addons/view';
|
||||
|
||||
const view = require('./addons/view');
|
||||
|
||||
module.exports = {
|
||||
export default {
|
||||
data: new SlashCommandBuilder()
|
||||
.setName('counter')
|
||||
.setDescription('Manage counters.')
|
|
@ -1,10 +1,9 @@
|
|||
const config = require('../../../../config.json');
|
||||
const logger = require('../../../handlers/logger');
|
||||
import config from '../../../../config.json';
|
||||
import logger from '../../../handlers/logger';
|
||||
import { users } from '../../../helpers/database/models';
|
||||
import creditNoun from '../../../helpers/creditNoun';
|
||||
|
||||
const { users } = require('../../../helpers/database/models');
|
||||
const creditNoun = require('../../../helpers/creditNoun');
|
||||
|
||||
module.exports = async (interaction) => {
|
||||
export default async (interaction) => {
|
||||
// Get options
|
||||
const user = await interaction.options.getUser('user');
|
||||
|
|
@ -1,11 +1,10 @@
|
|||
const config = require('../../../../config.json');
|
||||
const logger = require('../../../handlers/logger');
|
||||
import config from '../../../../config.json';
|
||||
import logger from '../../../handlers/logger';
|
||||
import { users } from '../../../helpers/database/models';
|
||||
import saveUser from '../../../helpers/saveUser';
|
||||
import creditNoun from '../../../helpers/creditNoun';
|
||||
|
||||
const { users } = require('../../../helpers/database/models');
|
||||
const saveUser = require('../../../helpers/saveUser');
|
||||
const creditNoun = require('../../../helpers/creditNoun');
|
||||
|
||||
module.exports = async (interaction) => {
|
||||
export default async (interaction) => {
|
||||
// Get options
|
||||
const user = await interaction.options.getUser('user');
|
||||
const amount = await interaction.options.getInteger('amount');
|
|
@ -1,6 +0,0 @@
|
|||
const balance = require('./balance');
|
||||
const gift = require('./gift');
|
||||
const top = require('./top');
|
||||
const work = require('./work');
|
||||
|
||||
module.exports = { balance, gift, top, work };
|
6
src/commands/credits/addons/index.ts
Normal file
6
src/commands/credits/addons/index.ts
Normal file
|
@ -0,0 +1,6 @@
|
|||
import balance from './balance';
|
||||
import gift from './gift';
|
||||
import top from './top';
|
||||
import work from './work';
|
||||
|
||||
export default { balance, gift, top, work };
|
|
@ -1,8 +1,8 @@
|
|||
const config = require('../../../../config.json');
|
||||
const { users } = require('../../../helpers/database/models');
|
||||
const creditNoun = require('../../../helpers/creditNoun');
|
||||
import config from '../../../../config.json';
|
||||
import { users } from '../../../helpers/database/models';
|
||||
import creditNoun from '../../../helpers/creditNoun';
|
||||
|
||||
module.exports = async (interaction) => {
|
||||
export default async (interaction) => {
|
||||
// Get all users in the guild
|
||||
|
||||
const usersDB = await users.find({ guildId: interaction.member.guild.id });
|
|
@ -1,9 +1,9 @@
|
|||
const config = require('../../../../config.json');
|
||||
const logger = require('../../../handlers/logger');
|
||||
const { guilds, users, timeouts } = require('../../../helpers/database/models');
|
||||
const creditNoun = require('../../../helpers/creditNoun');
|
||||
import config from '../../../../config.json';
|
||||
import logger from '../../../handlers/logger';
|
||||
import { guilds, users, timeouts } from '../../../helpers/database/models';
|
||||
import creditNoun from '../../../helpers/creditNoun';
|
||||
|
||||
module.exports = async (interaction) => {
|
||||
export default async (interaction) => {
|
||||
// Destructure member
|
||||
const { member } = interaction;
|
||||
const { guild } = member;
|
|
@ -1,8 +1,7 @@
|
|||
const { SlashCommandBuilder } = require('@discordjs/builders');
|
||||
import { SlashCommandBuilder } from '@discordjs/builders';
|
||||
import { balance, gift, top, work } from './addons';
|
||||
|
||||
const { balance, gift, top, work } = require('./addons');
|
||||
|
||||
module.exports = {
|
||||
export default {
|
||||
data: new SlashCommandBuilder()
|
||||
.setName('credits')
|
||||
.setDescription('Manage your credits.')
|
|
@ -1,14 +1,9 @@
|
|||
const i18next = require('i18next');
|
||||
const config = require('../../../../config.json');
|
||||
const logger = require('../../../handlers/logger');
|
||||
import i18next from 'i18next';
|
||||
import config from '../../../../config.json';
|
||||
import logger from '../../../handlers/logger';
|
||||
import { users, credits, experiences } from '../../../helpers/database/models';
|
||||
|
||||
const {
|
||||
users,
|
||||
credits,
|
||||
experiences,
|
||||
} = require('../../../helpers/database/models');
|
||||
|
||||
module.exports = async (interaction) => {
|
||||
export default async (interaction) => {
|
||||
try {
|
||||
// Destructure member
|
||||
const { member } = await interaction;
|
|
@ -1,8 +1,7 @@
|
|||
const { SlashCommandBuilder } = require('@discordjs/builders');
|
||||
import { SlashCommandBuilder } from '@discordjs/builders';
|
||||
import view from './addons/view';
|
||||
|
||||
const view = require('./addons/view');
|
||||
|
||||
module.exports = {
|
||||
export default {
|
||||
data: new SlashCommandBuilder()
|
||||
.setName('profile')
|
||||
.setDescription('Your profile.')
|
|
@ -1,10 +1,9 @@
|
|||
const i18next = require('i18next');
|
||||
const config = require('../../../../config.json');
|
||||
const logger = require('../../../handlers/logger');
|
||||
import i18next from 'i18next';
|
||||
import config from '../../../../config.json';
|
||||
import logger from '../../../handlers/logger';
|
||||
import { users, timeouts } from '../../../helpers/database/models';
|
||||
|
||||
const { users, timeouts } = require('../../../helpers/database/models');
|
||||
|
||||
module.exports = async (interaction) => {
|
||||
export default async (interaction) => {
|
||||
// Destructure member
|
||||
const { member } = interaction;
|
||||
const { guild } = member;
|
|
@ -1,10 +1,9 @@
|
|||
const { SlashCommandBuilder } = require('@discordjs/builders');
|
||||
const { Permissions } = require('discord.js');
|
||||
const logger = require('../../handlers/logger');
|
||||
import { SlashCommandBuilder } from '@discordjs/builders';
|
||||
import { Permissions } from 'discord.js';
|
||||
import logger from '../../handlers/logger';
|
||||
import give from './addons/give';
|
||||
|
||||
const give = require('./addons/give');
|
||||
|
||||
module.exports = {
|
||||
export default {
|
||||
data: new SlashCommandBuilder()
|
||||
.setName('reputation')
|
||||
.setDescription('Manage reputation.')
|
|
@ -1,11 +1,11 @@
|
|||
const { Permissions } = require('discord.js');
|
||||
const config = require('../../../../../config.json');
|
||||
const logger = require('../../../../handlers/logger');
|
||||
import { Permissions } from 'discord.js';
|
||||
import config from '../../../../../config.json';
|
||||
import logger from '../../../../handlers/logger';
|
||||
|
||||
// Database models
|
||||
const { guilds } = require('../../../../helpers/database/models');
|
||||
import { guilds } from '../../../../helpers/database/models';
|
||||
|
||||
module.exports = async (interaction) => {
|
||||
export default async (interaction) => {
|
||||
// Destructure member
|
||||
const { member } = interaction;
|
||||
const { guild } = member;
|
|
@ -1,5 +0,0 @@
|
|||
const pterodactyl = require('./pterodactyl');
|
||||
const credits = require('./credits');
|
||||
const points = require('./points');
|
||||
|
||||
module.exports = { pterodactyl, credits, points };
|
5
src/commands/settings/guild/addons/index.ts
Normal file
5
src/commands/settings/guild/addons/index.ts
Normal file
|
@ -0,0 +1,5 @@
|
|||
import pterodactyl from './pterodactyl';
|
||||
import credits from './credits';
|
||||
import points from './points';
|
||||
|
||||
export default { pterodactyl, credits, points };
|
|
@ -1,11 +1,11 @@
|
|||
const { Permissions } = require('discord.js');
|
||||
const config = require('../../../../../config.json');
|
||||
const logger = require('../../../../handlers/logger');
|
||||
import { Permissions } from 'discord.js';
|
||||
import config from '../../../../../config.json';
|
||||
import logger from '../../../../handlers/logger';
|
||||
|
||||
// Database models
|
||||
const { guilds } = require('../../../../helpers/database/models');
|
||||
import { guilds } from '../../../../helpers/database/models';
|
||||
|
||||
module.exports = async (interaction) => {
|
||||
export default async (interaction) => {
|
||||
// Destructure member
|
||||
const { member } = interaction;
|
||||
const { guild } = member;
|
|
@ -1,12 +1,12 @@
|
|||
const { Permissions } = require('discord.js');
|
||||
const config = require('../../../../../config.json');
|
||||
const logger = require('../../../../handlers/logger');
|
||||
import { Permissions } from 'discord.js';
|
||||
import config from '../../../../../config.json';
|
||||
import logger from '../../../../handlers/logger';
|
||||
|
||||
// Database models
|
||||
|
||||
const { apis } = require('../../../../helpers/database/models');
|
||||
import { apis } from '../../../../helpers/database/models';
|
||||
|
||||
module.exports = async (interaction) => {
|
||||
export default async (interaction) => {
|
||||
// Destructure member
|
||||
const { member } = interaction;
|
||||
const { guild } = member;
|
|
@ -1,10 +1,9 @@
|
|||
const { Permissions } = require('discord.js');
|
||||
const config = require('../../../../config.json');
|
||||
const logger = require('../../../handlers/logger');
|
||||
import { Permissions } from 'discord.js';
|
||||
import config from '../../../../config.json';
|
||||
import logger from '../../../handlers/logger';
|
||||
import { pterodactyl, credits, points } from './addons';
|
||||
|
||||
const { pterodactyl, credits, points } = require('./addons');
|
||||
|
||||
module.exports = async (interaction) => {
|
||||
export default async (interaction) => {
|
||||
// Destructure member
|
||||
const { member } = interaction;
|
||||
|
|
@ -1,10 +1,9 @@
|
|||
const { SlashCommandBuilder } = require('@discordjs/builders');
|
||||
const { Permissions } = require('discord.js');
|
||||
import { SlashCommandBuilder } from '@discordjs/builders';
|
||||
import { Permissions } from 'discord.js';
|
||||
import guild from './guild';
|
||||
import user from './user';
|
||||
|
||||
const guild = require('./guild');
|
||||
const user = require('./user');
|
||||
|
||||
module.exports = {
|
||||
export default {
|
||||
data: new SlashCommandBuilder()
|
||||
.setName('settings')
|
||||
.setDescription('Manage settings.')
|
|
@ -1,10 +1,10 @@
|
|||
const config = require('../../../../../config.json');
|
||||
const logger = require('../../../../handlers/logger');
|
||||
import config from '../../../../../config.json';
|
||||
import logger from '../../../../handlers/logger';
|
||||
|
||||
// Database models
|
||||
const { users } = require('../../../../helpers/database/models');
|
||||
import { users } from '../../../../helpers/database/models';
|
||||
|
||||
module.exports = async (interaction) => {
|
||||
export default async (interaction) => {
|
||||
// Destructure member
|
||||
const { member } = interaction;
|
||||
const { guild } = member;
|
|
@ -1,3 +0,0 @@
|
|||
const appearance = require('./appearance');
|
||||
|
||||
module.exports = { appearance };
|
3
src/commands/settings/user/addons/index.ts
Normal file
3
src/commands/settings/user/addons/index.ts
Normal file
|
@ -0,0 +1,3 @@
|
|||
import appearance from './appearance';
|
||||
|
||||
export default { appearance };
|
|
@ -1,10 +1,9 @@
|
|||
const { Permissions } = require('discord.js');
|
||||
const config = require('../../../../config.json');
|
||||
const logger = require('../../../handlers/logger');
|
||||
import { Permissions } from 'discord.js';
|
||||
import config from '../../../../config.json';
|
||||
import logger from '../../../handlers/logger';
|
||||
import { appearance } from './addons';
|
||||
|
||||
const { appearance } = require('./addons');
|
||||
|
||||
module.exports = async (interaction) => {
|
||||
export default async (interaction) => {
|
||||
// Destructure member
|
||||
const { member } = interaction;
|
||||
|
|
@ -1,12 +1,11 @@
|
|||
const { v4: uuidv4 } = require('uuid');
|
||||
const axios = require('axios');
|
||||
const config = require('../../../../config.json');
|
||||
const logger = require('../../../handlers/logger');
|
||||
import { v4 as uuidv4 } from 'uuid';
|
||||
import axios from 'axios';
|
||||
import config from '../../../../config.json';
|
||||
import logger from '../../../handlers/logger';
|
||||
import { credits, apis } from '../../../helpers/database/models';
|
||||
import creditNoun from '../../../helpers/creditNoun';
|
||||
|
||||
const { credits, apis } = require('../../../helpers/database/models');
|
||||
const creditNoun = require('../../../helpers/creditNoun');
|
||||
|
||||
module.exports = async (interaction) => {
|
||||
export default async (interaction) => {
|
||||
const { member } = interaction;
|
||||
const { guild } = member;
|
||||
|
|
@ -1,12 +1,11 @@
|
|||
const { v4: uuidv4 } = require('uuid');
|
||||
const axios = require('axios');
|
||||
const config = require('../../../../config.json');
|
||||
const logger = require('../../../handlers/logger');
|
||||
import { v4 as uuidv4 } from 'uuid';
|
||||
import axios from 'axios';
|
||||
import config from '../../../../config.json';
|
||||
import logger from '../../../handlers/logger';
|
||||
import { guilds, users } from '../../../helpers/database/models';
|
||||
import creditNoun from '../../../helpers/creditNoun';
|
||||
|
||||
const { guilds, users } = require('../../../helpers/database/models');
|
||||
const creditNoun = require('../../../helpers/creditNoun');
|
||||
|
||||
module.exports = async (interaction) => {
|
||||
export default async (interaction) => {
|
||||
const name = interaction.options.getString('name');
|
||||
|
||||
const { member } = interaction;
|
|
@ -1,12 +1,10 @@
|
|||
const { SlashCommandBuilder } = require('@discordjs/builders');
|
||||
const { Permissions } = require('discord.js');
|
||||
import { SlashCommandBuilder } from '@discordjs/builders';
|
||||
import { Permissions } from 'discord.js';
|
||||
import guilds from '../../helpers/database/models/guildSchema';
|
||||
import pterodactyl from './addons/pterodactyl';
|
||||
import roles from './roles';
|
||||
|
||||
const guilds = require('../../helpers/database/models/guildSchema');
|
||||
|
||||
const pterodactyl = require('./addons/pterodactyl');
|
||||
const roles = require('./roles');
|
||||
|
||||
module.exports = {
|
||||
export default {
|
||||
data: new SlashCommandBuilder()
|
||||
.setName('shop')
|
||||
.setDescription('Open our shop.')
|
|
@ -1,16 +1,11 @@
|
|||
const { v4: uuidv4 } = require('uuid');
|
||||
const axios = require('axios');
|
||||
const config = require('../../../../../config.json');
|
||||
const logger = require('../../../../handlers/logger');
|
||||
import { v4 as uuidv4 } from 'uuid';
|
||||
import axios from 'axios';
|
||||
import config from '../../../../../config.json';
|
||||
import logger from '../../../../handlers/logger';
|
||||
import { users, shopRoles, guilds } from '../../../../helpers/database/models';
|
||||
import creditNoun from '../../../../helpers/creditNoun';
|
||||
|
||||
const {
|
||||
users,
|
||||
shopRoles,
|
||||
guilds,
|
||||
} = require('../../../../helpers/database/models');
|
||||
const creditNoun = require('../../../../helpers/creditNoun');
|
||||
|
||||
module.exports = async (interaction) => {
|
||||
export default async (interaction) => {
|
||||
const { member } = interaction;
|
||||
const { guild } = member;
|
||||
|
|
@ -1,16 +1,11 @@
|
|||
const { v4: uuidv4 } = require('uuid');
|
||||
const axios = require('axios');
|
||||
const config = require('../../../../../config.json');
|
||||
const logger = require('../../../../handlers/logger');
|
||||
import { v4 as uuidv4 } from 'uuid';
|
||||
import axios from 'axios';
|
||||
import config from '../../../../../config.json';
|
||||
import logger from '../../../../handlers/logger';
|
||||
import { users, shopRoles, guilds } from '../../../../helpers/database/models';
|
||||
import creditNoun from '../../../../helpers/creditNoun';
|
||||
|
||||
const {
|
||||
users,
|
||||
shopRoles,
|
||||
guilds,
|
||||
} = require('../../../../helpers/database/models');
|
||||
const creditNoun = require('../../../../helpers/creditNoun');
|
||||
|
||||
module.exports = async (interaction) => {
|
||||
export default async (interaction) => {
|
||||
const { member } = interaction;
|
||||
const { guild } = member;
|
||||
|
|
@ -1,4 +0,0 @@
|
|||
const buy = require('./buy');
|
||||
const cancel = require('./cancel');
|
||||
|
||||
module.exports = { buy, cancel };
|
4
src/commands/shop/roles/addons/index.ts
Normal file
4
src/commands/shop/roles/addons/index.ts
Normal file
|
@ -0,0 +1,4 @@
|
|||
import buy from './buy';
|
||||
import cancel from './cancel';
|
||||
|
||||
export default { buy, cancel };
|
|
@ -1,8 +1,7 @@
|
|||
const logger = require('../../../handlers/logger');
|
||||
import logger from '../../../handlers/logger';
|
||||
import { buy, cancel } from './addons';
|
||||
|
||||
const { buy, cancel } = require('./addons');
|
||||
|
||||
module.exports = async (interaction) => {
|
||||
export default async (interaction) => {
|
||||
// Destructure member
|
||||
const { member } = interaction;
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
const config = require('../../../../config.json');
|
||||
import config from '../../../../config.json';
|
||||
|
||||
module.exports = async (interaction) => {
|
||||
export default async (interaction) => {
|
||||
const interactionEmbed = {
|
||||
title: ':hammer: Utilities - About',
|
||||
description: `This bot is hosted by ${
|
|
@ -1,5 +0,0 @@
|
|||
const lookup = require('./lookup');
|
||||
const about = require('./about');
|
||||
const stats = require('./stats');
|
||||
|
||||
module.exports = { lookup, about, stats };
|
5
src/commands/utilities/addons/index.ts
Normal file
5
src/commands/utilities/addons/index.ts
Normal file
|
@ -0,0 +1,5 @@
|
|||
import lookup from './lookup';
|
||||
import about from './about';
|
||||
import stats from './stats';
|
||||
|
||||
export default { lookup, about, stats };
|
|
@ -1,9 +1,8 @@
|
|||
const axios = require('axios');
|
||||
import axios from 'axios';
|
||||
import config from '../../../../config.json';
|
||||
import logger from '../../../handlers/logger';
|
||||
|
||||
const config = require('../../../../config.json');
|
||||
const logger = require('../../../handlers/logger');
|
||||
|
||||
module.exports = async (interaction) => {
|
||||
export default async (interaction) => {
|
||||
try {
|
||||
// Get lookup query
|
||||
const query = await interaction.options.getString('query');
|
|
@ -1,6 +1,6 @@
|
|||
const config = require('../../../../config.json');
|
||||
import config from '../../../../config.json';
|
||||
|
||||
module.exports = async (interaction) => {
|
||||
export default async (interaction) => {
|
||||
let totalSeconds = interaction.client.uptime / 1000;
|
||||
const days = Math.floor(totalSeconds / 86400);
|
||||
totalSeconds %= 86400;
|
|
@ -1,8 +1,7 @@
|
|||
const { SlashCommandBuilder } = require('@discordjs/builders');
|
||||
import { SlashCommandBuilder } from '@discordjs/builders';
|
||||
import { lookup, about, stats } from './addons';
|
||||
|
||||
const { lookup, about, stats } = require('./addons');
|
||||
|
||||
module.exports = {
|
||||
export default {
|
||||
data: new SlashCommandBuilder()
|
||||
.setName('utilities')
|
||||
.setDescription('Common utilities.')
|
0
src/configs/general.ts
Normal file
0
src/configs/general.ts
Normal file
|
@ -1,23 +1,26 @@
|
|||
const { dbGuildFix, dbMemberFix } = require('../helpers');
|
||||
import { Guild } from 'discord.js';
|
||||
import dbGuildFix from '../helpers/dbGuildFix';
|
||||
import dbMemberFix from '../helpers/dbMemberFix';
|
||||
|
||||
module.exports = {
|
||||
export default {
|
||||
name: 'guildCreate',
|
||||
async execute(guild) {
|
||||
async execute(guild: Guild) {
|
||||
// Destructure client
|
||||
const { client } = guild;
|
||||
|
||||
await guild.members.fetch().then(async (members) => {
|
||||
await members.forEach(async (member) => {
|
||||
members.forEach(async (member) => {
|
||||
const { user } = member;
|
||||
|
||||
dbMemberFix(user, guild);
|
||||
});
|
||||
});
|
||||
await dbGuildFix(guild);
|
||||
|
||||
// Set client status
|
||||
await client.user.setPresence({
|
||||
client?.user?.setPresence({
|
||||
activities: [
|
||||
{ type: 'WATCHING', name: `${client.guilds.cache.size} guilds` },
|
||||
{ type: 'WATCHING', name: `${client?.guilds?.cache?.size} guilds` },
|
||||
],
|
||||
status: 'online',
|
||||
});
|
|
@ -1,87 +0,0 @@
|
|||
const {
|
||||
guilds,
|
||||
users,
|
||||
apis,
|
||||
counters,
|
||||
shopRoles,
|
||||
timeouts,
|
||||
} = require('../helpers/database/models');
|
||||
|
||||
const logger = require('../handlers/logger');
|
||||
|
||||
module.exports = {
|
||||
name: 'guildDelete',
|
||||
async execute(guild) {
|
||||
// Destructure client
|
||||
const { client } = guild;
|
||||
|
||||
guilds
|
||||
.deleteMany({ guildId: guild.id })
|
||||
.then(async () => {
|
||||
await logger.debug(`Successfully deleted guild: ${guild.id}`);
|
||||
})
|
||||
.catch(async (e) => {
|
||||
await logger.error(`Failed to delete guild: ${guild.id} ${e}`);
|
||||
});
|
||||
users
|
||||
.deleteMany({ guildId: guild.id })
|
||||
.then(async () => {
|
||||
await logger.debug(`Successfully deleted guild: ${guild.id}'s users`);
|
||||
})
|
||||
.catch(async (e) => {
|
||||
await logger.error(`Failed to delete guild: ${guild.id}'s users ${e}`);
|
||||
});
|
||||
apis
|
||||
.deleteMany({ guildId: guild.id })
|
||||
.then(async () => {
|
||||
await logger.debug(`Successfully deleted guild: ${guild.id}'s apis`);
|
||||
})
|
||||
.catch(async (e) => {
|
||||
await logger.error(`Failed to delete guild: ${guild.id}'s apis ${e}`);
|
||||
});
|
||||
counters
|
||||
.deleteMany({ guildId: guild.id })
|
||||
.then(async () => {
|
||||
await logger.debug(
|
||||
`Successfully deleted guild: ${guild.id}'s counters`
|
||||
);
|
||||
})
|
||||
.catch(async (e) => {
|
||||
await logger.error(
|
||||
`Failed to delete guild: ${guild.id}'s counters ${e}`
|
||||
);
|
||||
});
|
||||
shopRoles
|
||||
.deleteMany({ guildId: guild.id })
|
||||
.then(async () => {
|
||||
await logger.debug(
|
||||
`Successfully deleted guild: ${guild.id}'s shop roles`
|
||||
);
|
||||
})
|
||||
.catch(async (e) => {
|
||||
await logger.error(
|
||||
`Failed to delete guild: ${guild.id}'s shop roles ${e}`
|
||||
);
|
||||
});
|
||||
timeouts
|
||||
.deleteMany({ guildId: guild.id })
|
||||
.then(async () => {
|
||||
await logger.debug(
|
||||
`Successfully deleted guild: ${guild.id}'s timeouts`
|
||||
);
|
||||
})
|
||||
.catch(async (e) => {
|
||||
await logger.error(
|
||||
`Failed to delete guild: ${guild.id}'s timeouts ${e}`
|
||||
);
|
||||
});
|
||||
|
||||
// Set client status
|
||||
await client.user.setPresence({
|
||||
activities: [
|
||||
{ type: 'WATCHING', name: `${client.guilds.cache.size} guilds` },
|
||||
],
|
||||
status: 'online',
|
||||
});
|
||||
},
|
||||
};
|
75
src/events/guildDelete.ts
Normal file
75
src/events/guildDelete.ts
Normal file
|
@ -0,0 +1,75 @@
|
|||
import guilds from '../helpers/database/models/guildSchema';
|
||||
import users from '../helpers/database/models/userSchema';
|
||||
import apis from '../helpers/database/models/apiSchema';
|
||||
import counters from '../helpers/database/models/counterSchema';
|
||||
import shopRoles from '../helpers/database/models/shopRolesSchema';
|
||||
import timeouts from '../helpers/database/models/timeoutSchema';
|
||||
|
||||
import logger from '../handlers/logger';
|
||||
|
||||
import { Guild } from 'discord.js';
|
||||
|
||||
export default {
|
||||
name: 'guildDelete',
|
||||
async execute(guild: Guild) {
|
||||
// Destructure client
|
||||
const { client } = guild;
|
||||
|
||||
guilds
|
||||
.deleteMany({ guildId: guild.id })
|
||||
.then(async () => {
|
||||
logger.debug(`Successfully deleted guild: ${guild.id}`);
|
||||
})
|
||||
.catch(async (e) => {
|
||||
logger.error(`Failed to delete guild: ${guild.id} ${e}`);
|
||||
});
|
||||
users
|
||||
.deleteMany({ guildId: guild.id })
|
||||
.then(async () => {
|
||||
logger.debug(`Successfully deleted guild: ${guild.id}'s users`);
|
||||
})
|
||||
.catch(async (e) => {
|
||||
logger.error(`Failed to delete guild: ${guild.id}'s users ${e}`);
|
||||
});
|
||||
apis
|
||||
.deleteMany({ guildId: guild.id })
|
||||
.then(async () => {
|
||||
logger.debug(`Successfully deleted guild: ${guild.id}'s apis`);
|
||||
})
|
||||
.catch(async (e) => {
|
||||
logger.error(`Failed to delete guild: ${guild.id}'s apis ${e}`);
|
||||
});
|
||||
counters
|
||||
.deleteMany({ guildId: guild.id })
|
||||
.then(async () => {
|
||||
logger.debug(`Successfully deleted guild: ${guild.id}'s counters`);
|
||||
})
|
||||
.catch(async (e) => {
|
||||
logger.error(`Failed to delete guild: ${guild.id}'s counters ${e}`);
|
||||
});
|
||||
shopRoles
|
||||
.deleteMany({ guildId: guild.id })
|
||||
.then(async () => {
|
||||
logger.debug(`Successfully deleted guild: ${guild.id}'s shop roles`);
|
||||
})
|
||||
.catch(async (e) => {
|
||||
logger.error(`Failed to delete guild: ${guild.id}'s shop roles ${e}`);
|
||||
});
|
||||
timeouts
|
||||
.deleteMany({ guildId: guild.id })
|
||||
.then(async () => {
|
||||
logger.debug(`Successfully deleted guild: ${guild.id}'s timeouts`);
|
||||
})
|
||||
.catch(async (e) => {
|
||||
logger.error(`Failed to delete guild: ${guild.id}'s timeouts ${e}`);
|
||||
});
|
||||
|
||||
// Set client status
|
||||
await client?.user?.setPresence({
|
||||
activities: [
|
||||
{ type: 'WATCHING', name: `${client.guilds.cache.size} guilds` },
|
||||
],
|
||||
status: 'online',
|
||||
});
|
||||
},
|
||||
};
|
|
@ -1,15 +0,0 @@
|
|||
const { users } = require('../helpers/database/models');
|
||||
const logger = require('../handlers/logger');
|
||||
|
||||
module.exports = {
|
||||
name: 'guildMemberAdd',
|
||||
async execute(member) {
|
||||
await users
|
||||
.create({ userId: member.id, guildId: member.guild.id })
|
||||
.then(
|
||||
logger.debug(
|
||||
`Guild: ${member.guild.id} User: ${member.id} created successfully`
|
||||
)
|
||||
);
|
||||
},
|
||||
};
|
17
src/events/guildMemberAdd.ts
Normal file
17
src/events/guildMemberAdd.ts
Normal file
|
@ -0,0 +1,17 @@
|
|||
import users from '../helpers/database/models/userSchema';
|
||||
import logger from '../handlers/logger';
|
||||
|
||||
import { GuildMember } from 'discord.js';
|
||||
|
||||
export default {
|
||||
name: 'guildMemberAdd',
|
||||
async execute(member: GuildMember) {
|
||||
await users
|
||||
.create({ userId: member?.id, guildId: member?.guild?.id })
|
||||
.then(async () =>
|
||||
logger.debug(
|
||||
`Guild: ${member?.guild?.id} User: ${member?.id} created successfully`
|
||||
)
|
||||
);
|
||||
},
|
||||
};
|
|
@ -1,15 +0,0 @@
|
|||
const { users } = require('../helpers/database/models');
|
||||
const logger = require('../handlers/logger');
|
||||
|
||||
module.exports = {
|
||||
name: 'guildMemberRemove',
|
||||
async execute(member) {
|
||||
await users
|
||||
.deleteOne({ userId: member.id, guildId: member.guild.id })
|
||||
.then(
|
||||
logger.debug(
|
||||
`Guild: ${member.guild.id} User: ${member.id} deleted successfully`
|
||||
)
|
||||
);
|
||||
},
|
||||
};
|
17
src/events/guildMemberRemove.ts
Normal file
17
src/events/guildMemberRemove.ts
Normal file
|
@ -0,0 +1,17 @@
|
|||
import users from '../helpers/database/models/userSchema';
|
||||
import logger from '../handlers/logger';
|
||||
|
||||
import { GuildMember } from 'discord.js';
|
||||
|
||||
export default {
|
||||
name: 'guildMemberRemove',
|
||||
async execute(member: GuildMember) {
|
||||
await users
|
||||
.deleteOne({ userId: member?.id, guildId: member?.guild?.id })
|
||||
.then(async () =>
|
||||
logger.debug(
|
||||
`Guild: ${member?.guild?.id} User: ${member?.id} deleted successfully`
|
||||
)
|
||||
);
|
||||
},
|
||||
};
|
|
@ -1,74 +0,0 @@
|
|||
const config = require('../../config.json');
|
||||
const logger = require('../handlers/logger');
|
||||
|
||||
const { guilds } = require('../helpers/database/models');
|
||||
|
||||
module.exports = {
|
||||
name: 'interactionCreate',
|
||||
async execute(interaction) {
|
||||
// Destructure member, client
|
||||
const { member, client } = interaction;
|
||||
|
||||
// If interaction is command
|
||||
if (interaction.isCommand()) {
|
||||
// Get command from collection
|
||||
const command = client.commands.get(interaction.commandName);
|
||||
|
||||
// If command do not exist
|
||||
if (!command) return;
|
||||
|
||||
// Create guild if it does not exist already
|
||||
await guilds.findOne(
|
||||
{ guildId: member.guild.id },
|
||||
{ new: true, upsert: true }
|
||||
);
|
||||
|
||||
try {
|
||||
// Defer reply
|
||||
await interaction.deferReply({
|
||||
embeds: [
|
||||
{
|
||||
author: {
|
||||
name: client.user.username,
|
||||
icon_url: client.user.displayAvatarURL(),
|
||||
url: 'https://bot.zyner.org/',
|
||||
},
|
||||
title: 'Check',
|
||||
description: 'Please wait...',
|
||||
color: config.colors.wait,
|
||||
timestamp: new Date(),
|
||||
},
|
||||
],
|
||||
ephemeral: true,
|
||||
});
|
||||
|
||||
// Execute command
|
||||
await command.execute(interaction);
|
||||
|
||||
// Send debug message
|
||||
await logger.debug(`Executing command: ${interaction.commandName}`);
|
||||
} catch (err) {
|
||||
// Send debug message
|
||||
await logger.error(err);
|
||||
|
||||
// Send interaction reply
|
||||
await interaction.reply({
|
||||
embeds: [
|
||||
{
|
||||
author: {
|
||||
name: client.user.username,
|
||||
icon_url: client.user.displayAvatarURL(),
|
||||
url: 'https://bot.zyner.org/',
|
||||
},
|
||||
title: 'Error',
|
||||
description: 'There was an error while executing this command!',
|
||||
color: config.colors.error,
|
||||
timestamp: new Date(),
|
||||
},
|
||||
],
|
||||
ephemeral: true,
|
||||
});
|
||||
}
|
||||
}
|
||||
},
|
||||
};
|
57
src/events/interactionCreate.ts
Normal file
57
src/events/interactionCreate.ts
Normal file
|
@ -0,0 +1,57 @@
|
|||
import config from '../../config.json';
|
||||
import logger from '../handlers/logger';
|
||||
import guilds from '../helpers/database/models/guildSchema';
|
||||
|
||||
import { Interaction, ColorResolvable } from 'discord.js';
|
||||
|
||||
export default {
|
||||
name: 'interactionCreate',
|
||||
async execute(interaction: Interaction) {
|
||||
// Destructure member, client
|
||||
const { client, guild } = interaction;
|
||||
|
||||
// If interaction is command
|
||||
if (interaction.isCommand()) {
|
||||
// Get command from collection
|
||||
const command = client.commands.get(interaction.commandName);
|
||||
|
||||
// If command do not exist
|
||||
if (!command) return;
|
||||
|
||||
// Create guild if it does not exist already
|
||||
await guilds.findOne({ guildId: guild?.id }, { new: true, upsert: true });
|
||||
|
||||
try {
|
||||
// Defer reply
|
||||
await interaction.deferReply();
|
||||
|
||||
// Execute command
|
||||
await command.execute(interaction);
|
||||
|
||||
// Send debug message
|
||||
logger.debug(`Executing command: ${interaction.commandName}`);
|
||||
} catch (e) {
|
||||
// Send debug message
|
||||
logger.error(e);
|
||||
|
||||
// Send interaction reply
|
||||
await interaction.reply({
|
||||
embeds: [
|
||||
{
|
||||
author: {
|
||||
name: client?.user?.username,
|
||||
icon_url: client?.user?.displayAvatarURL(),
|
||||
url: 'https://bot.zyner.org/',
|
||||
},
|
||||
title: 'Error',
|
||||
description: 'There was an error while executing this command!',
|
||||
color: config.colors.error as ColorResolvable,
|
||||
timestamp: new Date(),
|
||||
},
|
||||
],
|
||||
ephemeral: true,
|
||||
});
|
||||
}
|
||||
}
|
||||
},
|
||||
};
|
|
@ -1,8 +1,7 @@
|
|||
const { guilds, users } = require('../../helpers/database/models');
|
||||
import { guilds, users } from '../../helpers/database/models';
|
||||
import { points, credits, counter } from './modules';
|
||||
|
||||
const { points, credits, counter } = require('./modules');
|
||||
|
||||
module.exports = {
|
||||
export default {
|
||||
name: 'messageCreate',
|
||||
async execute(message) {
|
||||
const { guild, author } = message;
|
|
@ -1,15 +1,7 @@
|
|||
const logger = require('../../../handlers/logger');
|
||||
import logger from '../../../handlers/logger';
|
||||
import { users, guilds, experiences, credits, counters, timeouts } from '../../../helpers/database/models';
|
||||
|
||||
const {
|
||||
users,
|
||||
guilds,
|
||||
experiences,
|
||||
credits,
|
||||
counters,
|
||||
timeouts,
|
||||
} = require('../../../helpers/database/models');
|
||||
|
||||
module.exports = async (guildDB, userDB, message) => {
|
||||
export default async (guildDB, userDB, message) => {
|
||||
const { guild, channel, content } = message;
|
||||
|
||||
// Get counter object
|
|
@ -1,15 +1,7 @@
|
|||
const logger = require('../../../handlers/logger');
|
||||
import logger from '../../../handlers/logger';
|
||||
import { users, guilds, experiences, credits, counters, timeouts } from '../../../helpers/database/models';
|
||||
|
||||
const {
|
||||
users,
|
||||
guilds,
|
||||
experiences,
|
||||
credits,
|
||||
counters,
|
||||
timeouts,
|
||||
} = require('../../../helpers/database/models');
|
||||
|
||||
module.exports = async (guildDB, userDB, message) => {
|
||||
export default async (guildDB, userDB, message) => {
|
||||
const { guild, author, channel, content } = message;
|
||||
|
||||
// If message length is below guild minimum length
|
|
@ -1,5 +0,0 @@
|
|||
const points = require('./points');
|
||||
const credits = require('./credits');
|
||||
const counter = require('./counter');
|
||||
|
||||
module.exports = { points, credits, counter };
|
5
src/events/messageCreate/modules/index.ts
Normal file
5
src/events/messageCreate/modules/index.ts
Normal file
|
@ -0,0 +1,5 @@
|
|||
import points from './points';
|
||||
import credits from './credits';
|
||||
import counter from './counter';
|
||||
|
||||
export default { points, credits, counter };
|
|
@ -1,8 +1,7 @@
|
|||
const logger = require('../../../handlers/logger');
|
||||
import logger from '../../../handlers/logger';
|
||||
import { timeouts } from '../../../helpers/database/models';
|
||||
|
||||
const { timeouts } = require('../../../helpers/database/models');
|
||||
|
||||
module.exports = async (guildDB, userDB, message) => {
|
||||
export default async (guildDB, userDB, message) => {
|
||||
const { author, guild, channel, content } = message;
|
||||
|
||||
// If message length is below guild minimum length
|
|
@ -1,6 +1,6 @@
|
|||
const { counters } = require('../helpers/database/models');
|
||||
import { counters } from '../helpers/database/models';
|
||||
|
||||
module.exports = {
|
||||
export default {
|
||||
name: 'messageUpdate',
|
||||
async execute(oldMessage, newMessage) {
|
||||
// If message author is bot
|
|
@ -1,9 +1,8 @@
|
|||
const logger = require('../handlers/logger');
|
||||
const config = require('../../config.json');
|
||||
import logger from '../handlers/logger';
|
||||
import config from '../../config.json';
|
||||
import { deployCommands, dbGuildFix, dbMemberFix } from '../helpers';
|
||||
|
||||
const { deployCommands, dbGuildFix, dbMemberFix } = require('../helpers');
|
||||
|
||||
module.exports = {
|
||||
export default {
|
||||
name: 'ready',
|
||||
once: true,
|
||||
async execute(client) {
|
|
@ -1,12 +1,11 @@
|
|||
const fs = require('fs'); // fs
|
||||
const { Collection } = require('discord.js'); // discord.js
|
||||
import fs from 'fs'; // fs
|
||||
import { Collection, Client } from 'discord.js'; // discord.js
|
||||
|
||||
module.exports = async (client) => {
|
||||
export default async (client: Client) => {
|
||||
client.commands = new Collection();
|
||||
const commandFiles = fs.readdirSync('./src/commands');
|
||||
|
||||
for (const file of commandFiles) {
|
||||
// eslint-disable-next-line import/no-dynamic-require, global-require
|
||||
const command = require(`../commands/${file}`);
|
||||
client.commands.set(command.data.name, command);
|
||||
}
|
|
@ -1,6 +1,7 @@
|
|||
const fs = require('fs'); // fs
|
||||
import fs from 'fs'; // fs
|
||||
import { Client } from 'discord.js'; // discord.js
|
||||
|
||||
module.exports = async (client) => {
|
||||
export default async (client: Client) => {
|
||||
const eventFiles = fs.readdirSync('./src/events');
|
||||
|
||||
for (const file of eventFiles) {
|
|
@ -1,6 +0,0 @@
|
|||
const events = require('./events');
|
||||
const commands = require('./commands');
|
||||
const locale = require('./locale');
|
||||
const schedules = require('./schedules');
|
||||
|
||||
module.exports = { events, commands, locale, schedules };
|
6
src/handlers/index.ts
Normal file
6
src/handlers/index.ts
Normal file
|
@ -0,0 +1,6 @@
|
|||
import events from './events';
|
||||
import commands from './commands';
|
||||
import locale from './locale';
|
||||
import schedules from './schedules';
|
||||
|
||||
export default { events, commands, locale, schedules };
|
|
@ -1,6 +1,6 @@
|
|||
const i18next = require('i18next');
|
||||
import i18next from 'i18next';
|
||||
|
||||
module.exports = async () => {
|
||||
export default async () => {
|
||||
await i18next.init({
|
||||
lng: 'en', // if you're using a language detector, do not define the lng option
|
||||
// debug: true,
|
|
@ -1,6 +0,0 @@
|
|||
const pino = require('pino');
|
||||
|
||||
const config = require('../../config.json');
|
||||
|
||||
const logger = pino({ level: config.debug ? 'debug' : 'info' });
|
||||
module.exports = logger;
|
4
src/handlers/logger.ts
Normal file
4
src/handlers/logger.ts
Normal file
|
@ -0,0 +1,4 @@
|
|||
import pino from 'pino';
|
||||
import * as config from '../../config.json';
|
||||
|
||||
export default pino({ level: config.debug ? 'debug' : 'info' });
|
|
@ -1,8 +1,8 @@
|
|||
const schedule = require('node-schedule');
|
||||
const { shopRoles, users, guilds } = require('../helpers/database/models');
|
||||
const logger = require('./logger');
|
||||
import schedule from 'node-schedule';
|
||||
import { shopRoles, users, guilds } from '../helpers/database/models';
|
||||
import logger from './logger';
|
||||
|
||||
module.exports = async (client) => {
|
||||
export default async (client) => {
|
||||
schedule.scheduleJob('*/30 * * * *', async () => {
|
||||
shopRoles.find().then(async (shopRoles) => {
|
||||
shopRoles.map(async (shopRole) => {
|
|
@ -1,13 +0,0 @@
|
|||
const mongoose = require('mongoose');
|
||||
|
||||
const config = require('../../../config.json');
|
||||
const logger = require('../../handlers/logger');
|
||||
|
||||
module.exports = async () => {
|
||||
try {
|
||||
await mongoose.connect(config.mongodb.url);
|
||||
await logger.info('Connected to the database');
|
||||
} catch (err) {
|
||||
await logger.error(err);
|
||||
}
|
||||
};
|
10
src/helpers/database/index.ts
Normal file
10
src/helpers/database/index.ts
Normal file
|
@ -0,0 +1,10 @@
|
|||
import mongoose from 'mongoose';
|
||||
|
||||
import * as config from '../../../config.json';
|
||||
import logger from '../../handlers/logger';
|
||||
|
||||
export default async () =>
|
||||
{
|
||||
await mongoose.connect(config.mongodb.url);
|
||||
logger.info('Connected to the database');
|
||||
};
|
|
@ -1,4 +1,4 @@
|
|||
const mongoose = require('mongoose');
|
||||
import mongoose from 'mongoose';
|
||||
|
||||
const apiSchema = new mongoose.Schema(
|
||||
{
|
||||
|
@ -26,4 +26,4 @@ const apiSchema = new mongoose.Schema(
|
|||
{ timestamps: true }
|
||||
);
|
||||
|
||||
module.exports = mongoose.model('api', apiSchema);
|
||||
export default mongoose.model('api', apiSchema);
|
|
@ -1,4 +1,4 @@
|
|||
const mongoose = require('mongoose');
|
||||
import mongoose from 'mongoose';
|
||||
|
||||
const counterSchema = new mongoose.Schema(
|
||||
{
|
||||
|
@ -31,4 +31,4 @@ const counterSchema = new mongoose.Schema(
|
|||
{ timestamps: true }
|
||||
);
|
||||
|
||||
module.exports = mongoose.model('counter', counterSchema);
|
||||
export default mongoose.model('counter', counterSchema);
|
|
@ -1,4 +1,4 @@
|
|||
const mongoose = require('mongoose');
|
||||
import mongoose from 'mongoose';
|
||||
|
||||
const guildSchema = new mongoose.Schema(
|
||||
{
|
||||
|
@ -68,4 +68,4 @@ const guildSchema = new mongoose.Schema(
|
|||
{ timestamps: true }
|
||||
);
|
||||
|
||||
module.exports = mongoose.model('guild', guildSchema);
|
||||
export default mongoose.model('guild', guildSchema);
|
|
@ -1,15 +0,0 @@
|
|||
const users = require('./userSchema');
|
||||
const guilds = require('./guildSchema');
|
||||
const apis = require('./apiSchema');
|
||||
const timeouts = require('./timeoutSchema');
|
||||
const counters = require('./counterSchema');
|
||||
const shopRoles = require('./shopRolesSchema');
|
||||
|
||||
module.exports = {
|
||||
users,
|
||||
guilds,
|
||||
apis,
|
||||
timeouts,
|
||||
counters,
|
||||
shopRoles,
|
||||
};
|
15
src/helpers/database/models/index.ts
Normal file
15
src/helpers/database/models/index.ts
Normal file
|
@ -0,0 +1,15 @@
|
|||
import users from './userSchema';
|
||||
import guilds from './guildSchema';
|
||||
import apis from './apiSchema';
|
||||
import timeouts from './timeoutSchema';
|
||||
import counters from './counterSchema';
|
||||
import shopRoles from './shopRolesSchema';
|
||||
|
||||
export default {
|
||||
users,
|
||||
guilds,
|
||||
apis,
|
||||
timeouts,
|
||||
counters,
|
||||
shopRoles,
|
||||
};
|
|
@ -1,4 +1,4 @@
|
|||
const mongoose = require('mongoose');
|
||||
import mongoose from 'mongoose';
|
||||
|
||||
const shopRoleSchema = new mongoose.Schema(
|
||||
{
|
||||
|
@ -36,4 +36,4 @@ const shopRoleSchema = new mongoose.Schema(
|
|||
{ timestamps: true }
|
||||
);
|
||||
|
||||
module.exports = mongoose.model('shopRole', shopRoleSchema);
|
||||
export default mongoose.model('shopRole', shopRoleSchema);
|
|
@ -1,4 +1,4 @@
|
|||
const mongoose = require('mongoose');
|
||||
import mongoose from 'mongoose';
|
||||
|
||||
const timeoutSchema = new mongoose.Schema(
|
||||
{
|
||||
|
@ -19,4 +19,4 @@ const timeoutSchema = new mongoose.Schema(
|
|||
{ timestamps: true }
|
||||
);
|
||||
|
||||
module.exports = mongoose.model('timeout', timeoutSchema);
|
||||
export default mongoose.model('timeout', timeoutSchema);
|
|
@ -1,4 +1,4 @@
|
|||
const mongoose = require('mongoose');
|
||||
import mongoose from 'mongoose';
|
||||
|
||||
const userSchema = new mongoose.Schema(
|
||||
{
|
||||
|
@ -26,4 +26,4 @@ const userSchema = new mongoose.Schema(
|
|||
{ timestamps: true }
|
||||
);
|
||||
|
||||
module.exports = mongoose.model('user', userSchema);
|
||||
export default mongoose.model('user', userSchema);
|
|
@ -1,21 +1,31 @@
|
|||
// TODO This file will make sure that all guilds always has at least one entry in all collections with "guildId"
|
||||
|
||||
const { apis, guilds } = require('./database/models');
|
||||
const logger = require('../handlers/logger');
|
||||
import apis from "./database/models/apiSchema"
|
||||
import guilds from "./database/models/guildSchema"
|
||||
|
||||
module.exports = async (guild) => {
|
||||
import logger from '../handlers/logger';
|
||||
import { Guild } from 'discord.js';
|
||||
|
||||
export default async (guild: Guild) =>
|
||||
{
|
||||
const api = await apis.findOne({ guildId: guild.id });
|
||||
const guildData = await guilds.findOne({ guildId: guild.id });
|
||||
if (!api) {
|
||||
if (!api)
|
||||
{
|
||||
apis.create({ guildId: guild.id });
|
||||
logger.debug(`Guild: ${guild.id} added api collection`);
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
logger.debug(`Guild: ${guild.id} already in api collection`);
|
||||
}
|
||||
if (!guildData) {
|
||||
if (!guildData)
|
||||
{
|
||||
guilds.create({ guildId: guild.id });
|
||||
logger.debug(`Guild: ${guild.id} added guild collection`);
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
logger.debug(`Guild: ${guild.id} already in guild collection`);
|
||||
}
|
||||
};
|
|
@ -1,20 +1,27 @@
|
|||
const { users } = require('./database/models');
|
||||
const logger = require('../handlers/logger');
|
||||
import users from './database/models/userSchema';
|
||||
import logger from '../handlers/logger';
|
||||
import { Guild, User } from 'discord.js';
|
||||
|
||||
module.exports = async (user, guild) => {
|
||||
export default async (user: User, guild: Guild) =>
|
||||
{
|
||||
const userData = await users.findOne({ userId: user.id, guildId: guild.id });
|
||||
if (!userData) {
|
||||
if (!userData)
|
||||
{
|
||||
users
|
||||
.create({ userId: user.id, guildId: guild.id })
|
||||
.then(async () => {
|
||||
.then(async () =>
|
||||
{
|
||||
await logger.debug(`User: ${user.id} added user collection`);
|
||||
})
|
||||
.catch(async (e) => {
|
||||
.catch(async (e) =>
|
||||
{
|
||||
await logger.error(
|
||||
`User: ${user.id} failed to added user collection ${e}`
|
||||
);
|
||||
});
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
logger.debug(`User: ${user.id} already in user collection`);
|
||||
}
|
||||
|
|
@ -1,6 +0,0 @@
|
|||
const database = require('./database');
|
||||
const deployCommands = require('./deployCommands');
|
||||
const dbGuildFix = require('./dbGuildFix');
|
||||
const dbMemberFix = require('./dbMemberFix');
|
||||
|
||||
module.exports = { database, deployCommands, dbGuildFix, dbMemberFix };
|
6
src/helpers/index.ts
Normal file
6
src/helpers/index.ts
Normal file
|
@ -0,0 +1,6 @@
|
|||
import database from "./database.ts';
|
||||
import deployCommands from './deployCommands';
|
||||
import dbGuildFix from './dbGuildFix';
|
||||
import dbMemberFix from './dbMemberFix';
|
||||
|
||||
export default { database, deployCommands, dbGuildFix, dbMemberFix };
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Reference in a new issue