mirror of
https://github.com/veganhacktivists/arabot.git
synced 2025-11-03 15:49:50 +01:00
feat(arabot): remove temp ban if unban command is run
This commit is contained in:
parent
94f88d882d
commit
922dd7556e
@ -29,6 +29,7 @@ import type {
|
|||||||
import { EmbedBuilder } from 'discord.js';
|
import { EmbedBuilder } from 'discord.js';
|
||||||
import IDs from '#utils/ids';
|
import IDs from '#utils/ids';
|
||||||
import { removeBan, checkBan, addBan } from '#utils/database/ban';
|
import { removeBan, checkBan, addBan } from '#utils/database/ban';
|
||||||
|
import { checkTempBan, removeTempBan } from '#utils/database/tempBan';
|
||||||
import { addEmptyUser, addExistingUser, userExists } from '#utils/database/dbExistingUser';
|
import { addEmptyUser, addExistingUser, userExists } from '#utils/database/dbExistingUser';
|
||||||
|
|
||||||
export class UnbanCommand extends Command {
|
export class UnbanCommand extends Command {
|
||||||
@ -142,7 +143,10 @@ export class UnbanCommand extends Command {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!await checkBan(userId)) {
|
let dbBan = await checkBan(userId);
|
||||||
|
const dbTempBan = await checkTempBan(userId);
|
||||||
|
|
||||||
|
if (!dbBan && !dbTempBan) {
|
||||||
let ban: GuildBan;
|
let ban: GuildBan;
|
||||||
try {
|
try {
|
||||||
ban = await guild.bans.fetch(userId);
|
ban = await guild.bans.fetch(userId);
|
||||||
@ -167,14 +171,19 @@ export class UnbanCommand extends Command {
|
|||||||
|
|
||||||
// Add missing ban
|
// Add missing ban
|
||||||
await addBan(userId, modId, `(Mod who banned is not accurate) - ${reason}`);
|
await addBan(userId, modId, `(Mod who banned is not accurate) - ${reason}`);
|
||||||
|
dbBan = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Unban the user
|
// Unban the user
|
||||||
await guild.members.unban(user)
|
await guild.members.unban(user)
|
||||||
.catch(() => {});
|
.catch(() => {});
|
||||||
|
|
||||||
// Add unban to database
|
if (dbBan) {
|
||||||
await removeBan(user.id, mod.user.id);
|
// Add unban to database
|
||||||
|
await removeBan(user.id, mod.user.id);
|
||||||
|
} else if (dbTempBan) {
|
||||||
|
await removeTempBan(user.id, mod.user.id);
|
||||||
|
}
|
||||||
|
|
||||||
info.message = `${user} has been unbanned.`;
|
info.message = `${user} has been unbanned.`;
|
||||||
info.success = true;
|
info.success = true;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user