mirror of
https://github.com/veganhacktivists/arabot.git
synced 2025-05-19 12:44:17 +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 }) {
|
public async run(payload: { userId: string, guildId: string }) {
|
||||||
// Get the guild where the user is in
|
// 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) {
|
if (guild === undefined) {
|
||||||
console.error('verifyUnblock: Guild not found!');
|
console.error('verifyUnblock: Guild not found!');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Find GuildMember for the user
|
// 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) {
|
if (user === undefined) {
|
||||||
console.error('verifyUnblock: GuildMember not found!');
|
console.error('verifyUnblock: GuildMember not found!');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Remove the 'verify block' role
|
// Remove the 'verify block' role
|
||||||
await user.roles.remove(IDs.roles.verifyBlock);
|
await user.roles.remove(IDs.roles.verifyBlock);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user