From 96cfc5bf7a184b5b8aec2084e2c34873be6b4415 Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Mon, 11 Apr 2022 22:25:52 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=9A=91=20fix=20crash=20from=20deleteOne()?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/handlers/schedules.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/handlers/schedules.ts b/src/handlers/schedules.ts index 273ed8a..d9e4fe2 100644 --- a/src/handlers/schedules.ts +++ b/src/handlers/schedules.ts @@ -1,13 +1,13 @@ import schedule from "node-schedule"; import users from "../helpers/database/models/userSchema"; -import shopRoles from "../helpers/database/models/shopRolesSchema"; +import shopRolesSchema from "../helpers/database/models/shopRolesSchema"; import guilds from "../helpers/database/models/guildSchema"; import logger from "./logger"; import { Client } from "discord.js"; export default async (client: Client) => { schedule.scheduleJob("*/5 * * * *", async () => { - shopRoles.find().then(async (shopRoles: any) => { + shopRolesSchema.find().then(async (shopRoles: any) => { shopRoles.map(async (shopRole: any) => { const payed = new Date(shopRole.lastPayed); @@ -37,7 +37,7 @@ export default async (client: Client) => { const rGuild = await client.guilds.cache.get(`${shopRole.guildId}`); const rMember = await rGuild?.members.fetch(`${shopRole.userId}`); - shopRoles.deleteOne({ _id: shopRole._id }); + shopRolesSchema.deleteOne({ _id: shopRole._id }); await rMember?.roles .remove(`${shopRole.roleId}`)