🚑 added back features

This commit is contained in:
Axel Olausson Holtenäs 2022-04-10 00:31:20 +02:00
parent 05699e6813
commit a577fb35bf
No known key found for this signature in database
GPG key ID: 9347A5E873995701
3 changed files with 16 additions and 13 deletions

View file

@ -43,6 +43,7 @@
"uuid": "^8.3.2"
},
"devDependencies": {
"@types/node-schedule": "^1.3.2",
"@types/uuid": "^8.3.4",
"@typescript-eslint/eslint-plugin": "^5.15.0",
"@typescript-eslint/parser": "^5.15.0",

View file

@ -1,16 +1,18 @@
import schedule from 'node-schedule';
import { shopRoles, users, guilds } from '../helpers/database/models';
import users from '../helpers/database/models/userSchema';
import shopRoles from '../helpers/database/models/shopRolesSchema';
import guilds from '../helpers/database/models/guildSchema';
import logger from './logger';
export default async (client) => {
import { Client } from 'discord.js';
export default async (client: Client) => {
schedule.scheduleJob('*/30 * * * *', async () => {
shopRoles.find().then(async (shopRoles) => {
shopRoles.map(async (shopRole) => {
shopRoles.find().then(async (shopRoles: any) => {
shopRoles.map(async (shopRole: any) => {
const payed = new Date(shopRole.lastPayed);
oneHourAfterPayed = payed.setHours(payed.getHours() + 1);
const oneHourAfterPayed = payed.setHours(payed.getHours() + 1);
if (new Date() > oneHourAfterPayed) {
if (new Date() > new Date(oneHourAfterPayed)) {
// Get guild object
const guild = await guilds.findOne({
guildId: shopRole.guildId,
@ -24,9 +26,9 @@ export default async (client) => {
if (userDB.credits < pricePerHour) {
const rGuild = await client.guilds.cache.get(`${shopRole.guildId}`);
const rMember = await rGuild.members.fetch(`${shopRole.userId}`);
const rMember = await rGuild?.members.fetch(`${shopRole.userId}`);
await rMember.roles
await rMember?.roles
.remove(`${shopRole.roleId}`)
.then(console.log)
.catch(console.error); // Removes all roles

View file

@ -4,8 +4,8 @@ import { Client, Intents } from 'discord.js'; // discord.js
import database from './helpers/database/index';
import events from './handlers/events';
import commands from './handlers/commands';
// import { database } from './helpers'; // helpers
// import { events, commands, locale, schedules } from './handlers'; // handlers
import locale from './handlers/locale';
import schedules from './handlers/schedules';
import config from '../config.json'; // config.json
@ -20,9 +20,9 @@ import config from '../config.json'; // config.json
});
await database();
// await locale();
await locale();
await events(client);
await commands(client);
// await schedules(client);
await schedules(client);
await client.login(config.bot.token);
})();