Merge pull request #209 from VermiumSifell/dev
Refactoring code and updated vscode configurations
This commit is contained in:
commit
1313d8c0fa
29 changed files with 606 additions and 684 deletions
28
.cspell/custom-dictionary-workspace.txt
Normal file
28
.cspell/custom-dictionary-workspace.txt
Normal file
|
@ -0,0 +1,28 @@
|
|||
# Custom Dictionary Words
|
||||
Controlpanel
|
||||
dagen
|
||||
discordjs
|
||||
Följande
|
||||
gett
|
||||
Globalt
|
||||
Gåva
|
||||
hoster
|
||||
inom
|
||||
inställningar
|
||||
inte
|
||||
Krediter
|
||||
Nivå
|
||||
omdöme
|
||||
Omdöme
|
||||
Otillgänglig
|
||||
pino
|
||||
Poäng
|
||||
Profil
|
||||
satta
|
||||
senaste
|
||||
själv
|
||||
Språk
|
||||
Språkkod
|
||||
upsert
|
||||
uuidv
|
||||
Zyner
|
1
.vscode/extensions.json
vendored
1
.vscode/extensions.json
vendored
|
@ -3,7 +3,6 @@
|
|||
// Extension identifier format: ${publisher}.${name}. Example: vscode.csharp
|
||||
// List of extensions which should be recommended for users of this workspace.
|
||||
"recommendations": [
|
||||
"2gua.rainbow-brackets",
|
||||
"abrahamwilliam007.es7-javascript-class-snippets",
|
||||
"christian-kohler.npm-intellisense",
|
||||
"christian-kohler.path-intellisense",
|
||||
|
|
67
.vscode/settings.json
vendored
67
.vscode/settings.json
vendored
|
@ -1,53 +1,26 @@
|
|||
{
|
||||
"editor.defaultFormatter": "esbenp.prettier-vscode",
|
||||
"editor.wordWrapColumn": 100,
|
||||
"editor.tabSize": 2,
|
||||
"editor.formatOnSave": true,
|
||||
"files.eol": "\n",
|
||||
"prettier.endOfLine": "lf",
|
||||
"prettier.singleQuote": true,
|
||||
"prettier.trailingComma": "es5",
|
||||
"peacock.color": "#369",
|
||||
"editor.bracketPairColorization.enabled": true,
|
||||
"editor.codeActionsOnSave": ["source.formatDocument", "source.fixAll.eslint"],
|
||||
"cSpell.words": [
|
||||
"Controlpanel",
|
||||
"discordjs",
|
||||
"hoster",
|
||||
"pino",
|
||||
"runned",
|
||||
"Sifell",
|
||||
"Timout",
|
||||
"upsert",
|
||||
"uuidv",
|
||||
"Vermium",
|
||||
"Xyter",
|
||||
"Xyter's",
|
||||
"Zyner"
|
||||
],
|
||||
"editor.cursorBlinking": "phase",
|
||||
"editor.cursorSmoothCaretAnimation": true,
|
||||
"editor.defaultFormatter": "esbenp.prettier-vscode",
|
||||
"editor.fontFamily": "Cascadia Code",
|
||||
"editor.fontLigatures": true,
|
||||
"git.enableCommitSigning": true,
|
||||
"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"
|
||||
"editor.formatOnSave": true,
|
||||
"editor.guides.bracketPairs": "active",
|
||||
"editor.minimap.maxColumn": 200,
|
||||
"editor.minimap.renderCharacters": false,
|
||||
"editor.minimap.showSlider": "always",
|
||||
"editor.tabSize": 2,
|
||||
"editor.wordWrapColumn": 100,
|
||||
"files.eol": "\n",
|
||||
"files.trimTrailingWhitespace": true,
|
||||
"cSpell.customDictionaries": {
|
||||
"custom-dictionary-workspace": {
|
||||
"name": "custom-dictionary-workspace",
|
||||
"path": "${workspaceFolder:xyter}/.cspell/custom-dictionary-workspace.txt",
|
||||
"addWords": true,
|
||||
"scope": "workspace"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
theme: jekyll-theme-cayman
|
|
@ -1,37 +0,0 @@
|
|||
## Welcome to GitHub Pages
|
||||
|
||||
You can use the [editor on GitHub](https://github.com/ZynerOrg/xyter/edit/main/docs/index.md) to maintain and preview the content for your website in Markdown files.
|
||||
|
||||
Whenever you commit to this repository, GitHub Pages will run [Jekyll](https://jekyllrb.com/) to rebuild the pages in your site, from the content in your Markdown files.
|
||||
|
||||
### Markdown
|
||||
|
||||
Markdown is a lightweight and easy-to-use syntax for styling your writing. It includes conventions for
|
||||
|
||||
```markdown
|
||||
Syntax highlighted code block
|
||||
|
||||
# Header 1
|
||||
## Header 2
|
||||
### Header 3
|
||||
|
||||
- Bulleted
|
||||
- List
|
||||
|
||||
1. Numbered
|
||||
2. List
|
||||
|
||||
**Bold** and _Italic_ and `Code` text
|
||||
|
||||
[Link](url) and 
|
||||
```
|
||||
|
||||
For more details see [Basic writing and formatting syntax](https://docs.github.com/en/github/writing-on-github/getting-started-with-writing-and-formatting-on-github/basic-writing-and-formatting-syntax).
|
||||
|
||||
### Jekyll Themes
|
||||
|
||||
Your Pages site will use the layout and styles from the Jekyll theme you have selected in your [repository settings](https://github.com/ZynerOrg/xyter/settings/pages). The name of this theme is saved in the Jekyll `_config.yml` configuration file.
|
||||
|
||||
### Support or Contact
|
||||
|
||||
Having trouble with Pages? Check out our [documentation](https://docs.github.com/categories/github-pages-basics/) or [contact support](https://support.github.com/contact) and we’ll help you sort it out.
|
|
@ -56,8 +56,10 @@ export default async (interaction: CommandInteraction) => {
|
|||
const userDB = await fetchUser(user, guild);
|
||||
|
||||
if (userDB === null) return;
|
||||
if (guildDB === null) return;
|
||||
if (guildDB.shop === null) return;
|
||||
|
||||
const { pricePerHour } = guildDB?.shop?.roles;
|
||||
const { pricePerHour } = guildDB.shop.roles;
|
||||
|
||||
userDB.credits -= pricePerHour;
|
||||
|
||||
|
|
|
@ -1,6 +1,3 @@
|
|||
import users from "../../helpers/database/models/userSchema";
|
||||
import logger from "../../handlers/logger";
|
||||
|
||||
import { GuildMember } from "discord.js";
|
||||
import updatePresence from "../../helpers/updatePresence";
|
||||
import fetchUser from "../../helpers/fetchUser";
|
||||
|
|
|
@ -1,6 +1,3 @@
|
|||
import users from "../../helpers/database/models/userSchema";
|
||||
import logger from "../../handlers/logger";
|
||||
|
||||
import { GuildMember } from "discord.js";
|
||||
import updatePresence from "../../helpers/updatePresence";
|
||||
import dropUser from "../../helpers/dropUser";
|
||||
|
|
|
@ -1,10 +1,6 @@
|
|||
// Dependencies
|
||||
import { Message } from "discord.js";
|
||||
|
||||
// Models
|
||||
import userSchema from "../../helpers/database/models/userSchema";
|
||||
import guildSchema from "../../helpers/database/models/guildSchema";
|
||||
|
||||
// Modules
|
||||
import points from "./modules/points";
|
||||
import credits from "./modules/credits";
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
import logger from "../../../handlers/logger";
|
||||
import counters from "../../../helpers/database/models/counterSchema";
|
||||
|
||||
import { Message } from "discord.js";
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import logger from '../../../handlers/logger';
|
||||
import timeouts from '../../../helpers/database/models/timeoutSchema';
|
||||
import { Message } from 'discord.js';
|
||||
import logger from "../../../handlers/logger";
|
||||
import timeouts from "../../../helpers/database/models/timeoutSchema";
|
||||
import { Message } from "discord.js";
|
||||
export default async (guildDB: any, userDB: any, message: Message) => {
|
||||
const { guild, author, channel, content } = message;
|
||||
|
||||
|
@ -11,7 +11,7 @@ export default async (guildDB: any, userDB: any, message: Message) => {
|
|||
const isTimeout = await timeouts.findOne({
|
||||
guildId: guild?.id,
|
||||
userId: author.id,
|
||||
timeoutId: '2022-03-15-17-42',
|
||||
timeoutId: "2022-03-15-17-42",
|
||||
});
|
||||
|
||||
// If user is not on timeout
|
||||
|
@ -37,7 +37,7 @@ export default async (guildDB: any, userDB: any, message: Message) => {
|
|||
await timeouts.create({
|
||||
guildId: guild?.id,
|
||||
userId: author.id,
|
||||
timeoutId: '2022-03-15-17-42',
|
||||
timeoutId: "2022-03-15-17-42",
|
||||
});
|
||||
|
||||
setTimeout(async () => {
|
||||
|
@ -54,7 +54,7 @@ export default async (guildDB: any, userDB: any, message: Message) => {
|
|||
await timeouts.deleteOne({
|
||||
guildId: guild?.id,
|
||||
userId: author.id,
|
||||
timeoutId: '2022-03-15-17-42',
|
||||
timeoutId: "2022-03-15-17-42",
|
||||
});
|
||||
}, guildDB.credits.timeout);
|
||||
} else {
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import logger from '../../../handlers/logger';
|
||||
import timeouts from '../../../helpers/database/models/timeoutSchema';
|
||||
import logger from "../../../handlers/logger";
|
||||
import timeouts from "../../../helpers/database/models/timeoutSchema";
|
||||
|
||||
import { Message } from 'discord.js';
|
||||
import { Message } from "discord.js";
|
||||
export default async (guildDB: any, userDB: any, message: Message) => {
|
||||
const { author, guild, channel, content } = message;
|
||||
|
||||
|
@ -12,7 +12,7 @@ export default async (guildDB: any, userDB: any, message: Message) => {
|
|||
const isTimeout = await timeouts.findOne({
|
||||
guildId: guild?.id,
|
||||
userId: author.id,
|
||||
timeoutId: '2022-03-15-17-41',
|
||||
timeoutId: "2022-03-15-17-41",
|
||||
});
|
||||
|
||||
// If user is not on timeout
|
||||
|
@ -37,7 +37,7 @@ export default async (guildDB: any, userDB: any, message: Message) => {
|
|||
await timeouts.create({
|
||||
guildId: guild?.id,
|
||||
userId: author.id,
|
||||
timeoutId: '2022-03-15-17-41',
|
||||
timeoutId: "2022-03-15-17-41",
|
||||
});
|
||||
|
||||
setTimeout(async () => {
|
||||
|
@ -54,7 +54,7 @@ export default async (guildDB: any, userDB: any, message: Message) => {
|
|||
await timeouts.deleteOne({
|
||||
guildId: guild?.id,
|
||||
userId: author.id,
|
||||
timeoutId: '2022-03-15-17-41',
|
||||
timeoutId: "2022-03-15-17-41",
|
||||
});
|
||||
}, guildDB.points.timeout);
|
||||
} else {
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
import fs from 'fs'; // fs
|
||||
import { Collection } from 'discord.js'; // discord.js
|
||||
import { Client } from '../types/common/discord';
|
||||
import fs from "fs"; // fs
|
||||
import { Collection } from "discord.js"; // discord.js
|
||||
import { Client } from "../types/common/discord";
|
||||
export default async (client: Client) => {
|
||||
client.commands = new Collection();
|
||||
const commandFiles = fs.readdirSync('./src/commands');
|
||||
const commandFiles = fs.readdirSync("./src/commands");
|
||||
|
||||
for (const file of commandFiles) {
|
||||
const command = require(`../commands/${file}`);
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
import fs from 'fs'; // fs
|
||||
import { Client } from 'discord.js'; // discord.js
|
||||
import fs from "fs"; // fs
|
||||
import { Client } from "discord.js"; // discord.js
|
||||
|
||||
export default async (client: Client) => {
|
||||
const eventFiles = fs.readdirSync('./src/events');
|
||||
const eventFiles = fs.readdirSync("./src/events");
|
||||
|
||||
for (const file of eventFiles) {
|
||||
const event = require(`../events/${file}`);
|
||||
|
|
|
@ -1,6 +0,0 @@
|
|||
import events from './events';
|
||||
import commands from './commands';
|
||||
import locale from './locale';
|
||||
import schedules from './schedules';
|
||||
|
||||
export default { events, commands, locale, schedules };
|
|
@ -1,22 +1,22 @@
|
|||
import i18next from 'i18next';
|
||||
import i18next from "i18next";
|
||||
|
||||
export default async () => {
|
||||
await i18next.init({
|
||||
lng: 'en', // if you're using a language detector, do not define the lng option
|
||||
lng: "en", // if you're using a language detector, do not define the lng option
|
||||
// debug: true,
|
||||
fallbackLng: 'en',
|
||||
fallbackLng: "en",
|
||||
resources: {
|
||||
en: {
|
||||
general: { not_available: 'Not Available' },
|
||||
general: { not_available: "Not Available" },
|
||||
commands: {
|
||||
credits: {
|
||||
general: {
|
||||
credits_one: '{{count}} credit',
|
||||
credits_other: '{{count}} credits',
|
||||
credits_one: "{{count}} credit",
|
||||
credits_other: "{{count}} credits",
|
||||
},
|
||||
addons: {
|
||||
balance: { embed: { title: 'Credits' } },
|
||||
gift: { embed: { title: 'Gift' } },
|
||||
balance: { embed: { title: "Credits" } },
|
||||
gift: { embed: { title: "Gift" } },
|
||||
},
|
||||
},
|
||||
reputation: {
|
||||
|
@ -24,22 +24,22 @@ export default async () => {
|
|||
give: {
|
||||
version01: {
|
||||
embed: {
|
||||
title: ':medal: Reputation',
|
||||
title: ":medal: Reputation",
|
||||
description:
|
||||
'You have given reputation within the last day, you can not repute now!',
|
||||
"You have given reputation within the last day, you can not repute now!",
|
||||
},
|
||||
},
|
||||
version02: {
|
||||
embed: {
|
||||
title: ':medal: Reputation',
|
||||
title: ":medal: Reputation",
|
||||
description:
|
||||
'You have given {{user}} a {{type}} reputation!',
|
||||
"You have given {{user}} a {{type}} reputation!",
|
||||
},
|
||||
},
|
||||
version03: {
|
||||
embed: {
|
||||
title: ':medal: Reputation',
|
||||
description: 'You can not repute yourself.',
|
||||
title: ":medal: Reputation",
|
||||
description: "You can not repute yourself.",
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -49,19 +49,19 @@ export default async () => {
|
|||
addons: {
|
||||
view: {
|
||||
embed: {
|
||||
title: 'Profile',
|
||||
reputation: 'Reputation (Global)',
|
||||
level: 'Level (Guild)',
|
||||
points: 'Points (Guild)',
|
||||
credits: 'Credits (Guild)',
|
||||
language_code: 'Language Code (Global)',
|
||||
title: "Profile",
|
||||
reputation: "Reputation (Global)",
|
||||
level: "Level (Guild)",
|
||||
points: "Points (Guild)",
|
||||
credits: "Credits (Guild)",
|
||||
language_code: "Language Code (Global)",
|
||||
},
|
||||
},
|
||||
settings: {
|
||||
embed: {
|
||||
title: 'Profile',
|
||||
description: 'Following settings is set',
|
||||
fields: { language: 'Language' },
|
||||
title: "Profile",
|
||||
description: "Following settings is set",
|
||||
fields: { language: "Language" },
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -69,16 +69,16 @@ export default async () => {
|
|||
},
|
||||
},
|
||||
sv: {
|
||||
general: { not_available: 'Otillgänglig' },
|
||||
general: { not_available: "Otillgänglig" },
|
||||
commands: {
|
||||
credits: {
|
||||
general: {
|
||||
credits_one: '{{count}} krona',
|
||||
credits_other: '{{count}} kronor',
|
||||
credits_one: "{{count}} krona",
|
||||
credits_other: "{{count}} kronor",
|
||||
},
|
||||
addons: {
|
||||
balance: { embed: { title: 'Krediter' } },
|
||||
gift: { embed: { title: 'Gåva' } },
|
||||
balance: { embed: { title: "Krediter" } },
|
||||
gift: { embed: { title: "Gåva" } },
|
||||
},
|
||||
},
|
||||
reputation: {
|
||||
|
@ -86,21 +86,21 @@ export default async () => {
|
|||
give: {
|
||||
version01: {
|
||||
embed: {
|
||||
title: ':medal: Omdöme',
|
||||
title: ":medal: Omdöme",
|
||||
description:
|
||||
'Du har redan gett omdöme inom den senaste dagen, du kan inte ge ett omdöme just nu!',
|
||||
"Du har redan gett omdöme inom den senaste dagen, du kan inte ge ett omdöme just nu!",
|
||||
},
|
||||
},
|
||||
version02: {
|
||||
embed: {
|
||||
title: ':medal: Omdöme',
|
||||
description: 'Du har gett {{user}} ett {{type}} omdöme!',
|
||||
title: ":medal: Omdöme",
|
||||
description: "Du har gett {{user}} ett {{type}} omdöme!",
|
||||
},
|
||||
},
|
||||
version03: {
|
||||
embed: {
|
||||
title: ':medal: Omdöme',
|
||||
description: 'Du kan inte ge dig själv ett omdöme.',
|
||||
title: ":medal: Omdöme",
|
||||
description: "Du kan inte ge dig själv ett omdöme.",
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -111,19 +111,19 @@ export default async () => {
|
|||
addons: {
|
||||
view: {
|
||||
embed: {
|
||||
title: 'Profil',
|
||||
reputation: 'Omdöme (Globalt)',
|
||||
level: 'Nivå (Server)',
|
||||
points: 'Poäng (Server)',
|
||||
credits: 'Krediter (Server)',
|
||||
language_code: 'Språkkod (Globalt)',
|
||||
title: "Profil",
|
||||
reputation: "Omdöme (Globalt)",
|
||||
level: "Nivå (Server)",
|
||||
points: "Poäng (Server)",
|
||||
credits: "Krediter (Server)",
|
||||
language_code: "Språkkod (Globalt)",
|
||||
},
|
||||
},
|
||||
settings: {
|
||||
embed: {
|
||||
title: 'Profil',
|
||||
description: 'Följande inställningar är satta',
|
||||
fields: { language: 'Språk' },
|
||||
title: "Profil",
|
||||
description: "Följande inställningar är satta",
|
||||
fields: { language: "Språk" },
|
||||
},
|
||||
},
|
||||
},
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import pino from 'pino';
|
||||
import * as config from '../../config.json';
|
||||
import pino from "pino";
|
||||
import * as config from "../../config.json";
|
||||
|
||||
export default pino({ level: config.debug ? 'debug' : 'info' });
|
||||
export default pino({ level: config.debug ? "debug" : "info" });
|
||||
|
|
|
@ -1,10 +1,9 @@
|
|||
import mongoose from 'mongoose';
|
||||
import mongoose from "mongoose";
|
||||
|
||||
import * as config from '../../../config.json';
|
||||
import logger from '../../handlers/logger';
|
||||
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');
|
||||
export default async () => {
|
||||
await mongoose.connect(config.mongodb.url);
|
||||
logger.info("Connected to the database");
|
||||
};
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import mongoose from 'mongoose';
|
||||
import mongoose from "mongoose";
|
||||
|
||||
const counterSchema = new mongoose.Schema(
|
||||
{
|
||||
|
@ -31,4 +31,4 @@ const counterSchema = new mongoose.Schema(
|
|||
{ timestamps: true }
|
||||
);
|
||||
|
||||
export default mongoose.model('counter', counterSchema);
|
||||
export default mongoose.model("counter", counterSchema);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import mongoose from 'mongoose';
|
||||
import mongoose from "mongoose";
|
||||
|
||||
const guildSchema = new mongoose.Schema(
|
||||
{
|
||||
|
@ -68,4 +68,4 @@ const guildSchema = new mongoose.Schema(
|
|||
{ timestamps: true }
|
||||
);
|
||||
|
||||
export default mongoose.model('guild', guildSchema);
|
||||
export default mongoose.model("guild", guildSchema);
|
||||
|
|
|
@ -1,15 +0,0 @@
|
|||
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 @@
|
|||
import mongoose from 'mongoose';
|
||||
import mongoose from "mongoose";
|
||||
|
||||
const shopRoleSchema = new mongoose.Schema(
|
||||
{
|
||||
|
@ -36,4 +36,4 @@ const shopRoleSchema = new mongoose.Schema(
|
|||
{ timestamps: true }
|
||||
);
|
||||
|
||||
export default mongoose.model('shopRole', shopRoleSchema);
|
||||
export default mongoose.model("shopRole", shopRoleSchema);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import mongoose from 'mongoose';
|
||||
import mongoose from "mongoose";
|
||||
|
||||
const timeoutSchema = new mongoose.Schema(
|
||||
{
|
||||
|
@ -19,4 +19,4 @@ const timeoutSchema = new mongoose.Schema(
|
|||
{ timestamps: true }
|
||||
);
|
||||
|
||||
export default mongoose.model('timeout', timeoutSchema);
|
||||
export default mongoose.model("timeout", timeoutSchema);
|
||||
|
|
|
@ -1,31 +1,24 @@
|
|||
// TODO This file will make sure that all guilds always has at least one entry in all collections with "guildId"
|
||||
|
||||
import apis from "./database/models/apiSchema"
|
||||
import guilds from "./database/models/guildSchema"
|
||||
import apis from "./database/models/apiSchema";
|
||||
import guilds from "./database/models/guildSchema";
|
||||
|
||||
import logger from '../handlers/logger';
|
||||
import { Guild } from 'discord.js';
|
||||
import logger from "../handlers/logger";
|
||||
import { Guild } from "discord.js";
|
||||
|
||||
export default async (guild: Guild) =>
|
||||
{
|
||||
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,27 +1,21 @@
|
|||
import users from './database/models/userSchema';
|
||||
import logger from '../handlers/logger';
|
||||
import { Guild, User } from 'discord.js';
|
||||
import users from "./database/models/userSchema";
|
||||
import logger from "../handlers/logger";
|
||||
import { Guild, User } from "discord.js";
|
||||
|
||||
export default async (user: User, guild: 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,20 +1,20 @@
|
|||
import config from '../../config.json';
|
||||
import logger from '../handlers/logger';
|
||||
import fs from 'fs';
|
||||
import { REST } from '@discordjs/rest';
|
||||
import { Routes } from 'discord-api-types/v9';
|
||||
import config from "../../config.json";
|
||||
import logger from "../handlers/logger";
|
||||
import fs from "fs";
|
||||
import { REST } from "@discordjs/rest";
|
||||
import { Routes } from "discord-api-types/v9";
|
||||
|
||||
export default async () => {
|
||||
const commands = [];
|
||||
const commandFiles = fs.readdirSync('./src/commands');
|
||||
const commandFiles = fs.readdirSync("./src/commands");
|
||||
|
||||
for (const file of commandFiles) {
|
||||
// eslint-disable-next-line import/no-dynamic-require, global-require
|
||||
// eslint-disable-next-line global-require
|
||||
const command = require(`../commands/${file}`);
|
||||
commands.push(command.default.data.toJSON());
|
||||
}
|
||||
|
||||
const rest = new REST({ version: '9' }).setToken(config.bot.token);
|
||||
const rest = new REST({ version: "9" }).setToken(config.bot.token);
|
||||
|
||||
await rest.put(Routes.applicationCommands(config.bot.clientId), {
|
||||
body: commands,
|
||||
|
@ -32,7 +32,7 @@ export default async () => {
|
|||
}
|
||||
)
|
||||
.then(async () =>
|
||||
logger.info('Successfully registered application commands.')
|
||||
logger.info("Successfully registered application commands.")
|
||||
)
|
||||
.catch(async (err) => {
|
||||
await logger.error(err);
|
||||
|
|
|
@ -8,7 +8,6 @@ import timeouts from "../helpers/database/models/timeoutSchema";
|
|||
import logger from "../handlers/logger";
|
||||
|
||||
import { Guild } from "discord.js";
|
||||
import updatePresence from "../helpers/updatePresence";
|
||||
|
||||
export default async (guild: Guild) => {
|
||||
guilds
|
||||
|
|
|
@ -1,6 +0,0 @@
|
|||
import database from "./database";
|
||||
import deployCommands from "./deployCommands";
|
||||
import dbGuildFix from "./dbGuildFix";
|
||||
import dbMemberFix from "./dbMemberFix";
|
||||
|
||||
export default { database, deployCommands, dbGuildFix, dbMemberFix };
|
|
@ -1,28 +1,39 @@
|
|||
import sleep from './sleep';
|
||||
import logger from '../handlers/logger';
|
||||
import sleep from "./sleep";
|
||||
import logger from "../handlers/logger";
|
||||
import Chance from "chance";
|
||||
|
||||
export default async function saveUser(data: any, data2: any) {
|
||||
process.nextTick(
|
||||
async () => {
|
||||
await sleep(Math.floor(Math.random() * 10 + 1) * 100); // 100 - 1000 random Number generator
|
||||
// Chance module
|
||||
const chance = new Chance();
|
||||
|
||||
await sleep(
|
||||
chance.integer({
|
||||
min: 0,
|
||||
max: 1,
|
||||
}) *
|
||||
10 +
|
||||
1 * 100
|
||||
); // 100 - 1000 random Number generator
|
||||
data.save((_: any) =>
|
||||
_
|
||||
? logger.error(
|
||||
`ERROR Occurred while saving data (saveUser) \n${'='.repeat(
|
||||
`ERROR Occurred while saving data (saveUser) \n${"=".repeat(
|
||||
50
|
||||
)}\n${`${_}\n${'='.repeat(50)}`}`
|
||||
)}\n${`${_}\n${"=".repeat(50)}`}`
|
||||
)
|
||||
: 'No Error'
|
||||
: "No Error"
|
||||
);
|
||||
if (data2) {
|
||||
data2.save((_: any) =>
|
||||
_
|
||||
? logger.error(
|
||||
`ERROR Occurred while saving data (saveUser) \n${'='.repeat(
|
||||
`ERROR Occurred while saving data (saveUser) \n${"=".repeat(
|
||||
50
|
||||
)}\n${`${_}\n${'='.repeat(50)}`}`
|
||||
)}\n${`${_}\n${"=".repeat(50)}`}`
|
||||
)
|
||||
: 'No Error'
|
||||
: "No Error"
|
||||
);
|
||||
}
|
||||
},
|
||||
|
|
Loading…
Add table
Reference in a new issue