🚑 fix crash from deleteOne()
This commit is contained in:
parent
5cb1bf3d50
commit
96cfc5bf7a
1 changed files with 3 additions and 3 deletions
|
@ -1,13 +1,13 @@
|
||||||
import schedule from "node-schedule";
|
import schedule from "node-schedule";
|
||||||
import users from "../helpers/database/models/userSchema";
|
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 guilds from "../helpers/database/models/guildSchema";
|
||||||
import logger from "./logger";
|
import logger from "./logger";
|
||||||
import { Client } from "discord.js";
|
import { Client } from "discord.js";
|
||||||
|
|
||||||
export default async (client: Client) => {
|
export default async (client: Client) => {
|
||||||
schedule.scheduleJob("*/5 * * * *", async () => {
|
schedule.scheduleJob("*/5 * * * *", async () => {
|
||||||
shopRoles.find().then(async (shopRoles: any) => {
|
shopRolesSchema.find().then(async (shopRoles: any) => {
|
||||||
shopRoles.map(async (shopRole: any) => {
|
shopRoles.map(async (shopRole: any) => {
|
||||||
const payed = new Date(shopRole.lastPayed);
|
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 rGuild = await client.guilds.cache.get(`${shopRole.guildId}`);
|
||||||
const rMember = await rGuild?.members.fetch(`${shopRole.userId}`);
|
const rMember = await rGuild?.members.fetch(`${shopRole.userId}`);
|
||||||
|
|
||||||
shopRoles.deleteOne({ _id: shopRole._id });
|
shopRolesSchema.deleteOne({ _id: shopRole._id });
|
||||||
|
|
||||||
await rMember?.roles
|
await rMember?.roles
|
||||||
.remove(`${shopRole.roleId}`)
|
.remove(`${shopRole.roleId}`)
|
||||||
|
|
Loading…
Add table
Reference in a new issue