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
|
// Extension identifier format: ${publisher}.${name}. Example: vscode.csharp
|
||||||
// List of extensions which should be recommended for users of this workspace.
|
// List of extensions which should be recommended for users of this workspace.
|
||||||
"recommendations": [
|
"recommendations": [
|
||||||
"2gua.rainbow-brackets",
|
|
||||||
"abrahamwilliam007.es7-javascript-class-snippets",
|
"abrahamwilliam007.es7-javascript-class-snippets",
|
||||||
"christian-kohler.npm-intellisense",
|
"christian-kohler.npm-intellisense",
|
||||||
"christian-kohler.path-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.bracketPairColorization.enabled": true,
|
||||||
"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.codeActionsOnSave": ["source.formatDocument", "source.fixAll.eslint"],
|
"editor.codeActionsOnSave": ["source.formatDocument", "source.fixAll.eslint"],
|
||||||
"cSpell.words": [
|
"editor.cursorBlinking": "phase",
|
||||||
"Controlpanel",
|
"editor.cursorSmoothCaretAnimation": true,
|
||||||
"discordjs",
|
"editor.defaultFormatter": "esbenp.prettier-vscode",
|
||||||
"hoster",
|
|
||||||
"pino",
|
|
||||||
"runned",
|
|
||||||
"Sifell",
|
|
||||||
"Timout",
|
|
||||||
"upsert",
|
|
||||||
"uuidv",
|
|
||||||
"Vermium",
|
|
||||||
"Xyter",
|
|
||||||
"Xyter's",
|
|
||||||
"Zyner"
|
|
||||||
],
|
|
||||||
"editor.fontFamily": "Cascadia Code",
|
"editor.fontFamily": "Cascadia Code",
|
||||||
"editor.fontLigatures": true,
|
"editor.fontLigatures": true,
|
||||||
"git.enableCommitSigning": true,
|
"editor.formatOnSave": true,
|
||||||
"typescript.tsdk": "node_modules\\typescript\\lib",
|
"editor.guides.bracketPairs": "active",
|
||||||
"[typescript]": {
|
"editor.minimap.maxColumn": 200,
|
||||||
"editor.defaultFormatter": "esbenp.prettier-vscode"
|
"editor.minimap.renderCharacters": false,
|
||||||
},
|
"editor.minimap.showSlider": "always",
|
||||||
"workbench.colorCustomizations": {
|
"editor.tabSize": 2,
|
||||||
"activityBar.activeBackground": "#407fbf",
|
"editor.wordWrapColumn": 100,
|
||||||
"activityBar.activeBorder": "#77284f",
|
"files.eol": "\n",
|
||||||
"activityBar.background": "#407fbf",
|
"files.trimTrailingWhitespace": true,
|
||||||
"activityBar.foreground": "#e7e7e7",
|
"cSpell.customDictionaries": {
|
||||||
"activityBar.inactiveForeground": "#e7e7e799",
|
"custom-dictionary-workspace": {
|
||||||
"activityBarBadge.background": "#77284f",
|
"name": "custom-dictionary-workspace",
|
||||||
"activityBarBadge.foreground": "#e7e7e7",
|
"path": "${workspaceFolder:xyter}/.cspell/custom-dictionary-workspace.txt",
|
||||||
"sash.hoverBorder": "#407fbf",
|
"addWords": true,
|
||||||
"statusBar.background": "#336699",
|
"scope": "workspace"
|
||||||
"statusBar.foreground": "#e7e7e7",
|
}
|
||||||
"statusBarItem.hoverBackground": "#407fbf",
|
|
||||||
"statusBarItem.remoteBackground": "#336699",
|
|
||||||
"statusBarItem.remoteForeground": "#e7e7e7",
|
|
||||||
"titleBar.activeBackground": "#336699",
|
|
||||||
"titleBar.activeForeground": "#e7e7e7",
|
|
||||||
"titleBar.inactiveBackground": "#33669999",
|
|
||||||
"titleBar.inactiveForeground": "#e7e7e799"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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);
|
const userDB = await fetchUser(user, guild);
|
||||||
|
|
||||||
if (userDB === null) return;
|
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;
|
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 { GuildMember } from "discord.js";
|
||||||
import updatePresence from "../../helpers/updatePresence";
|
import updatePresence from "../../helpers/updatePresence";
|
||||||
import fetchUser from "../../helpers/fetchUser";
|
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 { GuildMember } from "discord.js";
|
||||||
import updatePresence from "../../helpers/updatePresence";
|
import updatePresence from "../../helpers/updatePresence";
|
||||||
import dropUser from "../../helpers/dropUser";
|
import dropUser from "../../helpers/dropUser";
|
||||||
|
|
|
@ -1,10 +1,6 @@
|
||||||
// Dependencies
|
// Dependencies
|
||||||
import { Message } from "discord.js";
|
import { Message } from "discord.js";
|
||||||
|
|
||||||
// Models
|
|
||||||
import userSchema from "../../helpers/database/models/userSchema";
|
|
||||||
import guildSchema from "../../helpers/database/models/guildSchema";
|
|
||||||
|
|
||||||
// Modules
|
// Modules
|
||||||
import points from "./modules/points";
|
import points from "./modules/points";
|
||||||
import credits from "./modules/credits";
|
import credits from "./modules/credits";
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
import logger from "../../../handlers/logger";
|
|
||||||
import counters from "../../../helpers/database/models/counterSchema";
|
import counters from "../../../helpers/database/models/counterSchema";
|
||||||
|
|
||||||
import { Message } from "discord.js";
|
import { Message } from "discord.js";
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import logger from '../../../handlers/logger';
|
import logger from "../../../handlers/logger";
|
||||||
import timeouts from '../../../helpers/database/models/timeoutSchema';
|
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) => {
|
export default async (guildDB: any, userDB: any, message: Message) => {
|
||||||
const { guild, author, channel, content } = 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({
|
const isTimeout = await timeouts.findOne({
|
||||||
guildId: guild?.id,
|
guildId: guild?.id,
|
||||||
userId: author.id,
|
userId: author.id,
|
||||||
timeoutId: '2022-03-15-17-42',
|
timeoutId: "2022-03-15-17-42",
|
||||||
});
|
});
|
||||||
|
|
||||||
// If user is not on timeout
|
// If user is not on timeout
|
||||||
|
@ -37,7 +37,7 @@ export default async (guildDB: any, userDB: any, message: Message) => {
|
||||||
await timeouts.create({
|
await timeouts.create({
|
||||||
guildId: guild?.id,
|
guildId: guild?.id,
|
||||||
userId: author.id,
|
userId: author.id,
|
||||||
timeoutId: '2022-03-15-17-42',
|
timeoutId: "2022-03-15-17-42",
|
||||||
});
|
});
|
||||||
|
|
||||||
setTimeout(async () => {
|
setTimeout(async () => {
|
||||||
|
@ -54,7 +54,7 @@ export default async (guildDB: any, userDB: any, message: Message) => {
|
||||||
await timeouts.deleteOne({
|
await timeouts.deleteOne({
|
||||||
guildId: guild?.id,
|
guildId: guild?.id,
|
||||||
userId: author.id,
|
userId: author.id,
|
||||||
timeoutId: '2022-03-15-17-42',
|
timeoutId: "2022-03-15-17-42",
|
||||||
});
|
});
|
||||||
}, guildDB.credits.timeout);
|
}, guildDB.credits.timeout);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import logger from '../../../handlers/logger';
|
import logger from "../../../handlers/logger";
|
||||||
import timeouts from '../../../helpers/database/models/timeoutSchema';
|
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) => {
|
export default async (guildDB: any, userDB: any, message: Message) => {
|
||||||
const { author, guild, channel, content } = 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({
|
const isTimeout = await timeouts.findOne({
|
||||||
guildId: guild?.id,
|
guildId: guild?.id,
|
||||||
userId: author.id,
|
userId: author.id,
|
||||||
timeoutId: '2022-03-15-17-41',
|
timeoutId: "2022-03-15-17-41",
|
||||||
});
|
});
|
||||||
|
|
||||||
// If user is not on timeout
|
// If user is not on timeout
|
||||||
|
@ -37,7 +37,7 @@ export default async (guildDB: any, userDB: any, message: Message) => {
|
||||||
await timeouts.create({
|
await timeouts.create({
|
||||||
guildId: guild?.id,
|
guildId: guild?.id,
|
||||||
userId: author.id,
|
userId: author.id,
|
||||||
timeoutId: '2022-03-15-17-41',
|
timeoutId: "2022-03-15-17-41",
|
||||||
});
|
});
|
||||||
|
|
||||||
setTimeout(async () => {
|
setTimeout(async () => {
|
||||||
|
@ -54,7 +54,7 @@ export default async (guildDB: any, userDB: any, message: Message) => {
|
||||||
await timeouts.deleteOne({
|
await timeouts.deleteOne({
|
||||||
guildId: guild?.id,
|
guildId: guild?.id,
|
||||||
userId: author.id,
|
userId: author.id,
|
||||||
timeoutId: '2022-03-15-17-41',
|
timeoutId: "2022-03-15-17-41",
|
||||||
});
|
});
|
||||||
}, guildDB.points.timeout);
|
}, guildDB.points.timeout);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
import fs from 'fs'; // fs
|
import fs from "fs"; // fs
|
||||||
import { Collection } from 'discord.js'; // discord.js
|
import { Collection } from "discord.js"; // discord.js
|
||||||
import { Client } from '../types/common/discord';
|
import { Client } from "../types/common/discord";
|
||||||
export default async (client: Client) => {
|
export default async (client: Client) => {
|
||||||
client.commands = new Collection();
|
client.commands = new Collection();
|
||||||
const commandFiles = fs.readdirSync('./src/commands');
|
const commandFiles = fs.readdirSync("./src/commands");
|
||||||
|
|
||||||
for (const file of commandFiles) {
|
for (const file of commandFiles) {
|
||||||
const command = require(`../commands/${file}`);
|
const command = require(`../commands/${file}`);
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
import fs from 'fs'; // fs
|
import fs from "fs"; // fs
|
||||||
import { Client } from 'discord.js'; // discord.js
|
import { Client } from "discord.js"; // discord.js
|
||||||
|
|
||||||
export default async (client: Client) => {
|
export default async (client: Client) => {
|
||||||
const eventFiles = fs.readdirSync('./src/events');
|
const eventFiles = fs.readdirSync("./src/events");
|
||||||
|
|
||||||
for (const file of eventFiles) {
|
for (const file of eventFiles) {
|
||||||
const event = require(`../events/${file}`);
|
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 () => {
|
export default async () => {
|
||||||
await i18next.init({
|
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,
|
// debug: true,
|
||||||
fallbackLng: 'en',
|
fallbackLng: "en",
|
||||||
resources: {
|
resources: {
|
||||||
en: {
|
en: {
|
||||||
general: { not_available: 'Not Available' },
|
general: { not_available: "Not Available" },
|
||||||
commands: {
|
commands: {
|
||||||
credits: {
|
credits: {
|
||||||
general: {
|
general: {
|
||||||
credits_one: '{{count}} credit',
|
credits_one: "{{count}} credit",
|
||||||
credits_other: '{{count}} credits',
|
credits_other: "{{count}} credits",
|
||||||
},
|
},
|
||||||
addons: {
|
addons: {
|
||||||
balance: { embed: { title: 'Credits' } },
|
balance: { embed: { title: "Credits" } },
|
||||||
gift: { embed: { title: 'Gift' } },
|
gift: { embed: { title: "Gift" } },
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
reputation: {
|
reputation: {
|
||||||
|
@ -24,22 +24,22 @@ export default async () => {
|
||||||
give: {
|
give: {
|
||||||
version01: {
|
version01: {
|
||||||
embed: {
|
embed: {
|
||||||
title: ':medal: Reputation',
|
title: ":medal: Reputation",
|
||||||
description:
|
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: {
|
version02: {
|
||||||
embed: {
|
embed: {
|
||||||
title: ':medal: Reputation',
|
title: ":medal: Reputation",
|
||||||
description:
|
description:
|
||||||
'You have given {{user}} a {{type}} reputation!',
|
"You have given {{user}} a {{type}} reputation!",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
version03: {
|
version03: {
|
||||||
embed: {
|
embed: {
|
||||||
title: ':medal: Reputation',
|
title: ":medal: Reputation",
|
||||||
description: 'You can not repute yourself.',
|
description: "You can not repute yourself.",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -49,19 +49,19 @@ export default async () => {
|
||||||
addons: {
|
addons: {
|
||||||
view: {
|
view: {
|
||||||
embed: {
|
embed: {
|
||||||
title: 'Profile',
|
title: "Profile",
|
||||||
reputation: 'Reputation (Global)',
|
reputation: "Reputation (Global)",
|
||||||
level: 'Level (Guild)',
|
level: "Level (Guild)",
|
||||||
points: 'Points (Guild)',
|
points: "Points (Guild)",
|
||||||
credits: 'Credits (Guild)',
|
credits: "Credits (Guild)",
|
||||||
language_code: 'Language Code (Global)',
|
language_code: "Language Code (Global)",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
settings: {
|
settings: {
|
||||||
embed: {
|
embed: {
|
||||||
title: 'Profile',
|
title: "Profile",
|
||||||
description: 'Following settings is set',
|
description: "Following settings is set",
|
||||||
fields: { language: 'Language' },
|
fields: { language: "Language" },
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -69,16 +69,16 @@ export default async () => {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
sv: {
|
sv: {
|
||||||
general: { not_available: 'Otillgänglig' },
|
general: { not_available: "Otillgänglig" },
|
||||||
commands: {
|
commands: {
|
||||||
credits: {
|
credits: {
|
||||||
general: {
|
general: {
|
||||||
credits_one: '{{count}} krona',
|
credits_one: "{{count}} krona",
|
||||||
credits_other: '{{count}} kronor',
|
credits_other: "{{count}} kronor",
|
||||||
},
|
},
|
||||||
addons: {
|
addons: {
|
||||||
balance: { embed: { title: 'Krediter' } },
|
balance: { embed: { title: "Krediter" } },
|
||||||
gift: { embed: { title: 'Gåva' } },
|
gift: { embed: { title: "Gåva" } },
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
reputation: {
|
reputation: {
|
||||||
|
@ -86,21 +86,21 @@ export default async () => {
|
||||||
give: {
|
give: {
|
||||||
version01: {
|
version01: {
|
||||||
embed: {
|
embed: {
|
||||||
title: ':medal: Omdöme',
|
title: ":medal: Omdöme",
|
||||||
description:
|
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: {
|
version02: {
|
||||||
embed: {
|
embed: {
|
||||||
title: ':medal: Omdöme',
|
title: ":medal: Omdöme",
|
||||||
description: 'Du har gett {{user}} ett {{type}} omdöme!',
|
description: "Du har gett {{user}} ett {{type}} omdöme!",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
version03: {
|
version03: {
|
||||||
embed: {
|
embed: {
|
||||||
title: ':medal: Omdöme',
|
title: ":medal: Omdöme",
|
||||||
description: 'Du kan inte ge dig själv ett omdöme.',
|
description: "Du kan inte ge dig själv ett omdöme.",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -111,19 +111,19 @@ export default async () => {
|
||||||
addons: {
|
addons: {
|
||||||
view: {
|
view: {
|
||||||
embed: {
|
embed: {
|
||||||
title: 'Profil',
|
title: "Profil",
|
||||||
reputation: 'Omdöme (Globalt)',
|
reputation: "Omdöme (Globalt)",
|
||||||
level: 'Nivå (Server)',
|
level: "Nivå (Server)",
|
||||||
points: 'Poäng (Server)',
|
points: "Poäng (Server)",
|
||||||
credits: 'Krediter (Server)',
|
credits: "Krediter (Server)",
|
||||||
language_code: 'Språkkod (Globalt)',
|
language_code: "Språkkod (Globalt)",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
settings: {
|
settings: {
|
||||||
embed: {
|
embed: {
|
||||||
title: 'Profil',
|
title: "Profil",
|
||||||
description: 'Följande inställningar är satta',
|
description: "Följande inställningar är satta",
|
||||||
fields: { language: 'Språk' },
|
fields: { language: "Språk" },
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import pino from 'pino';
|
import pino from "pino";
|
||||||
import * as config from '../../config.json';
|
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 * as config from "../../../config.json";
|
||||||
import logger from '../../handlers/logger';
|
import logger from "../../handlers/logger";
|
||||||
|
|
||||||
export default async () =>
|
export default async () => {
|
||||||
{
|
await mongoose.connect(config.mongodb.url);
|
||||||
await mongoose.connect(config.mongodb.url);
|
logger.info("Connected to the database");
|
||||||
logger.info('Connected to the database');
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import mongoose from 'mongoose';
|
import mongoose from "mongoose";
|
||||||
|
|
||||||
const counterSchema = new mongoose.Schema(
|
const counterSchema = new mongoose.Schema(
|
||||||
{
|
{
|
||||||
|
@ -31,4 +31,4 @@ const counterSchema = new mongoose.Schema(
|
||||||
{ timestamps: true }
|
{ 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(
|
const guildSchema = new mongoose.Schema(
|
||||||
{
|
{
|
||||||
|
@ -68,4 +68,4 @@ const guildSchema = new mongoose.Schema(
|
||||||
{ timestamps: true }
|
{ 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(
|
const shopRoleSchema = new mongoose.Schema(
|
||||||
{
|
{
|
||||||
|
@ -36,4 +36,4 @@ const shopRoleSchema = new mongoose.Schema(
|
||||||
{ timestamps: true }
|
{ 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(
|
const timeoutSchema = new mongoose.Schema(
|
||||||
{
|
{
|
||||||
|
@ -19,4 +19,4 @@ const timeoutSchema = new mongoose.Schema(
|
||||||
{ timestamps: true }
|
{ 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"
|
// 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 apis from "./database/models/apiSchema";
|
||||||
import guilds from "./database/models/guildSchema"
|
import guilds from "./database/models/guildSchema";
|
||||||
|
|
||||||
import logger from '../handlers/logger';
|
import logger from "../handlers/logger";
|
||||||
import { Guild } from 'discord.js';
|
import { Guild } from "discord.js";
|
||||||
|
|
||||||
export default async (guild: Guild) =>
|
export default async (guild: Guild) => {
|
||||||
{
|
|
||||||
const api = await apis.findOne({ guildId: guild.id });
|
const api = await apis.findOne({ guildId: guild.id });
|
||||||
const guildData = await guilds.findOne({ guildId: guild.id });
|
const guildData = await guilds.findOne({ guildId: guild.id });
|
||||||
if (!api)
|
if (!api) {
|
||||||
{
|
|
||||||
apis.create({ guildId: guild.id });
|
apis.create({ guildId: guild.id });
|
||||||
logger.debug(`Guild: ${guild.id} added api collection`);
|
logger.debug(`Guild: ${guild.id} added api collection`);
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
logger.debug(`Guild: ${guild.id} already in api collection`);
|
logger.debug(`Guild: ${guild.id} already in api collection`);
|
||||||
}
|
}
|
||||||
if (!guildData)
|
if (!guildData) {
|
||||||
{
|
|
||||||
guilds.create({ guildId: guild.id });
|
guilds.create({ guildId: guild.id });
|
||||||
logger.debug(`Guild: ${guild.id} added guild collection`);
|
logger.debug(`Guild: ${guild.id} added guild collection`);
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
logger.debug(`Guild: ${guild.id} already in guild collection`);
|
logger.debug(`Guild: ${guild.id} already in guild collection`);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,27 +1,21 @@
|
||||||
import users from './database/models/userSchema';
|
import users from "./database/models/userSchema";
|
||||||
import logger from '../handlers/logger';
|
import logger from "../handlers/logger";
|
||||||
import { Guild, User } from 'discord.js';
|
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 });
|
const userData = await users.findOne({ userId: user.id, guildId: guild.id });
|
||||||
if (!userData)
|
if (!userData) {
|
||||||
{
|
|
||||||
users
|
users
|
||||||
.create({ userId: user.id, guildId: guild.id })
|
.create({ userId: user.id, guildId: guild.id })
|
||||||
.then(async () =>
|
.then(async () => {
|
||||||
{
|
|
||||||
await logger.debug(`User: ${user.id} added user collection`);
|
await logger.debug(`User: ${user.id} added user collection`);
|
||||||
})
|
})
|
||||||
.catch(async (e) =>
|
.catch(async (e) => {
|
||||||
{
|
|
||||||
await logger.error(
|
await logger.error(
|
||||||
`User: ${user.id} failed to added user collection ${e}`
|
`User: ${user.id} failed to added user collection ${e}`
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
logger.debug(`User: ${user.id} already in user collection`);
|
logger.debug(`User: ${user.id} already in user collection`);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,20 +1,20 @@
|
||||||
import config from '../../config.json';
|
import config from "../../config.json";
|
||||||
import logger from '../handlers/logger';
|
import logger from "../handlers/logger";
|
||||||
import fs from 'fs';
|
import fs from "fs";
|
||||||
import { REST } from '@discordjs/rest';
|
import { REST } from "@discordjs/rest";
|
||||||
import { Routes } from 'discord-api-types/v9';
|
import { Routes } from "discord-api-types/v9";
|
||||||
|
|
||||||
export default async () => {
|
export default async () => {
|
||||||
const commands = [];
|
const commands = [];
|
||||||
const commandFiles = fs.readdirSync('./src/commands');
|
const commandFiles = fs.readdirSync("./src/commands");
|
||||||
|
|
||||||
for (const file of commandFiles) {
|
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}`);
|
const command = require(`../commands/${file}`);
|
||||||
commands.push(command.default.data.toJSON());
|
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), {
|
await rest.put(Routes.applicationCommands(config.bot.clientId), {
|
||||||
body: commands,
|
body: commands,
|
||||||
|
@ -32,7 +32,7 @@ export default async () => {
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
.then(async () =>
|
.then(async () =>
|
||||||
logger.info('Successfully registered application commands.')
|
logger.info("Successfully registered application commands.")
|
||||||
)
|
)
|
||||||
.catch(async (err) => {
|
.catch(async (err) => {
|
||||||
await logger.error(err);
|
await logger.error(err);
|
||||||
|
|
|
@ -8,7 +8,6 @@ import timeouts from "../helpers/database/models/timeoutSchema";
|
||||||
import logger from "../handlers/logger";
|
import logger from "../handlers/logger";
|
||||||
|
|
||||||
import { Guild } from "discord.js";
|
import { Guild } from "discord.js";
|
||||||
import updatePresence from "../helpers/updatePresence";
|
|
||||||
|
|
||||||
export default async (guild: Guild) => {
|
export default async (guild: Guild) => {
|
||||||
guilds
|
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 sleep from "./sleep";
|
||||||
import logger from '../handlers/logger';
|
import logger from "../handlers/logger";
|
||||||
|
import Chance from "chance";
|
||||||
|
|
||||||
export default async function saveUser(data: any, data2: any) {
|
export default async function saveUser(data: any, data2: any) {
|
||||||
process.nextTick(
|
process.nextTick(
|
||||||
async () => {
|
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) =>
|
data.save((_: any) =>
|
||||||
_
|
_
|
||||||
? logger.error(
|
? logger.error(
|
||||||
`ERROR Occurred while saving data (saveUser) \n${'='.repeat(
|
`ERROR Occurred while saving data (saveUser) \n${"=".repeat(
|
||||||
50
|
50
|
||||||
)}\n${`${_}\n${'='.repeat(50)}`}`
|
)}\n${`${_}\n${"=".repeat(50)}`}`
|
||||||
)
|
)
|
||||||
: 'No Error'
|
: "No Error"
|
||||||
);
|
);
|
||||||
if (data2) {
|
if (data2) {
|
||||||
data2.save((_: any) =>
|
data2.save((_: any) =>
|
||||||
_
|
_
|
||||||
? logger.error(
|
? logger.error(
|
||||||
`ERROR Occurred while saving data (saveUser) \n${'='.repeat(
|
`ERROR Occurred while saving data (saveUser) \n${"=".repeat(
|
||||||
50
|
50
|
||||||
)}\n${`${_}\n${'='.repeat(50)}`}`
|
)}\n${`${_}\n${"=".repeat(50)}`}`
|
||||||
)
|
)
|
||||||
: 'No Error'
|
: "No Error"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
Loading…
Add table
Reference in a new issue