🚑 fix crash from deleteOne()

This commit is contained in:
Axel Olausson Holtenäs 2022-04-11 22:25:52 +02:00
parent 5cb1bf3d50
commit 96cfc5bf7a
No known key found for this signature in database
GPG key ID: 9347A5E873995701

View file

@ -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}`)