1 |
|
/** |
2 |
|
* This file is part of SudoBot. |
3 |
|
* |
4 |
|
* Copyright (C) 2021-2022 OSN Inc. |
5 |
|
* |
6 |
|
* SudoBot is free software; you can redistribute it and/or modify it |
7 |
|
* under the terms of the GNU Affero General Public License as published by |
8 |
|
* the Free Software Foundation, either version 3 of the License, or |
9 |
|
* (at your option) any later version. |
10 |
|
* |
11 |
|
* SudoBot is distributed in the hope that it will be useful, but |
12 |
|
* WITHOUT ANY WARRANTY; without even the implied warranty of |
13 |
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14 |
|
* GNU Affero General Public License for more details. |
15 |
|
* |
16 |
|
* You should have received a copy of the GNU Affero General Public License |
17 |
|
* along with SudoBot. If not, see <https://www.gnu.org/licenses/>. |
18 |
|
*/ |
19 |
|
|
20 |
import { roleMention } from '@discordjs/builders'; |
import { roleMention } from '@discordjs/builders'; |
21 |
import { formatDuration, intervalToDuration } from 'date-fns'; |
import { formatDuration, intervalToDuration } from 'date-fns'; |
22 |
import { BanOptions, CommandInteraction, FileOptions, Guild, GuildBan, GuildMember, Message, MessageEmbed, MessageOptions, MessagePayload, TextChannel, User } from 'discord.js'; |
import { BanOptions, CommandInteraction, FileOptions, Guild, GuildBan, GuildMember, Message, MessageEmbed, MessageOptions, MessagePayload, TextChannel, User } from 'discord.js'; |
27 |
|
|
28 |
class Logger { |
class Logger { |
29 |
client: DiscordClient; |
client: DiscordClient; |
30 |
|
pause = false; |
31 |
|
pauseBan = false; |
32 |
|
|
33 |
|
pauseAll(p = true) { |
34 |
|
this.pause = p; |
35 |
|
} |
36 |
|
|
37 |
constructor(client: DiscordClient) { |
constructor(client: DiscordClient) { |
38 |
this.client = client; |
this.client = client; |
39 |
} |
} |
40 |
|
|
41 |
channel(callback: (channel: TextChannel) => any, msg: any) { |
channel(callback: (channel: TextChannel) => any, msg: any) { |
42 |
|
if (this.pause) { |
43 |
|
return; |
44 |
|
} |
45 |
|
|
46 |
let channelID = this.client.config.props[msg.guild!.id].logging_channel; |
let channelID = this.client.config.props[msg.guild!.id].logging_channel; |
47 |
let channel = msg.guild!.channels.cache.find((c: any) => c.id === channelID) as TextChannel; |
let channel = msg.guild!.channels.cache.find((c: any) => c.id === channelID) as TextChannel; |
48 |
|
|
145 |
type: 'MEMBER_BAN_ADD', |
type: 'MEMBER_BAN_ADD', |
146 |
})).entries.first(); |
})).entries.first(); |
147 |
|
|
|
|
|
148 |
if (ban.reason) { |
if (ban.reason) { |
149 |
r = ban.reason; |
r = ban.reason; |
150 |
} |
} |
153 |
const { target, reason } = await auditLog; |
const { target, reason } = await auditLog; |
154 |
|
|
155 |
if (target!.id === ban.user.id && reason) { |
if (target!.id === ban.user.id && reason) { |
156 |
r = await reason; |
r = reason.replace(/^\[BAN\]/, ''); |
157 |
|
} |
158 |
|
|
159 |
|
if (auditLog.executor?.id === this.client.user!.id && (r.startsWith("[TEMPBAN]") || r.startsWith("[SOFTBAN]"))) { |
160 |
|
return; |
161 |
} |
} |
162 |
} |
} |
163 |
|
|
198 |
const { target, reason } = await auditLog; |
const { target, reason } = await auditLog; |
199 |
|
|
200 |
if (target!.id === user.id && reason) { |
if (target!.id === user.id && reason) { |
201 |
r = await reason; |
r = reason.replace(/^\[SOFTBAN\]/, ''); |
202 |
} |
} |
203 |
} |
} |
204 |
|
|
242 |
const { target, reason } = await auditLog; |
const { target, reason } = await auditLog; |
243 |
|
|
244 |
if (target!.id === user.id && reason) { |
if (target!.id === user.id && reason) { |
245 |
r = await reason; |
r = reason.replace(/^\[TEMPBAN\]/, ''); |
246 |
} |
} |
247 |
} |
} |
248 |
|
|