mirror of
https://github.com/veganhacktivists/arabot.git
synced 2025-05-19 08:34:15 +02:00
feat(arabot): add extra check if guild/user not in cache
This commit is contained in:
parent
5a5afbfb02
commit
35de24399a
@ -27,18 +27,24 @@ export class VerifyUnblock extends ScheduledTask {
|
||||
|
||||
public async run(payload: { userId: string, guildId: string }) {
|
||||
// Get the guild where the user is in
|
||||
const guild = this.container.client.guilds.cache.get(payload.guildId);
|
||||
let guild = this.container.client.guilds.cache.get(payload.guildId);
|
||||
if (guild === undefined) {
|
||||
guild = await this.container.client.guilds.fetch(payload.guildId);
|
||||
if (guild === undefined) {
|
||||
console.error('verifyUnblock: Guild not found!');
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Find GuildMember for the user
|
||||
const user = guild.members.cache.get(payload.userId);
|
||||
let user = guild.members.cache.get(payload.userId);
|
||||
if (user === undefined) {
|
||||
user = await guild.members.fetch(payload.userId);
|
||||
if (user === undefined) {
|
||||
console.error('verifyUnblock: GuildMember not found!');
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Remove the 'verify block' role
|
||||
await user.roles.remove(IDs.roles.verifyBlock);
|
||||
|
Loading…
x
Reference in New Issue
Block a user