From 12c709982815f5e0d3064ce28829b77e1c129d81 Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Mon, 11 Apr 2022 22:33:39 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20not=20removing=20role=20and=20ta?= =?UTF-8?q?king=20negative=20payed?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/handlers/schedules.ts | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/handlers/schedules.ts b/src/handlers/schedules.ts index d9e4fe2..143e056 100644 --- a/src/handlers/schedules.ts +++ b/src/handlers/schedules.ts @@ -34,12 +34,16 @@ export default async (client: Client) => { if (userDB === null) return; if (userDB.credits < pricePerHour) { - const rGuild = await client.guilds.cache.get(`${shopRole.guildId}`); - const rMember = await rGuild?.members.fetch(`${shopRole.userId}`); + const rGuild = client?.guilds?.cache?.get(`${shopRole.guildId}`); + const rMember = await rGuild?.members?.fetch(`${shopRole.userId}`); - shopRolesSchema.deleteOne({ _id: shopRole._id }); + shopRolesSchema + .deleteOne({ _id: shopRole._id }) + .then(async () => + logger.debug(`Removed ${shopRole._id} from shopRoles`) + ); - await rMember?.roles + return await rMember?.roles .remove(`${shopRole.roleId}`) .then(async (test) => console.log("4", test)) .catch(async (test) => console.log("5", test)); // Removes all roles