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'; |
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'; |
23 |
import ms from 'ms'; |
import ms from 'ms'; |
24 |
import DiscordClient from '../client/Client'; |
import DiscordClient from '../client/Client'; |
25 |
import Punishment, { IPunishment } from '../models/Punishment'; |
import { IPunishment } from '../models/Punishment'; |
26 |
import { timeProcess, timeSince } from '../utils/util'; |
import { timeSince } from '../utils/util'; |
27 |
|
|
28 |
class Logger { |
class Logger { |
29 |
client: DiscordClient; |
client: DiscordClient; |
352 |
}, member); |
}, member); |
353 |
} |
} |
354 |
|
|
355 |
logMute(member: GuildMember, reason: string, timeMs: number | null | undefined, d: User, hard: boolean = true) { |
logMute(member: GuildMember, reason: string, duration: number | null | undefined, d: User, hard: boolean = true) { |
356 |
this.channel(async (channel) => { |
this.channel(async (channel) => { |
357 |
await channel.send({ |
await channel.send({ |
358 |
embeds: [ |
embeds: [ |
365 |
}) |
}) |
366 |
.addField('Reason', reason) |
.addField('Reason', reason) |
367 |
.addField('Muted by', d.tag) |
.addField('Muted by', d.tag) |
368 |
.addField('Duration Until', typeof timeMs === 'number' ? `${new Date((timeMs / 1000) + Date.now()).toLocaleString()} (${timeProcess(timeMs / 1000)})` : "*No duration set*") |
.addField('Duration Until', duration ? `${(new Date(Date.now() + duration)).toLocaleString()} (${formatDuration(intervalToDuration({ start: 0, end: duration }))})` : "*No duration set*") |
369 |
.addField('User ID', member.user.id) |
.addField('User ID', member.user.id) |
370 |
.addField('Hardmute', hard ? 'Yes' : 'No') |
.addField('Hardmute', hard ? 'Yes' : 'No') |
371 |
.setFooter({ |
.setFooter({ |