/[sudobot]/trunk/src/automod/Logger.ts
ViewVC logotype

Diff of /trunk/src/automod/Logger.ts

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 336 by rakin, Mon Jul 29 17:29:36 2024 UTC revision 393 by rakin, Mon Jul 29 17:29:59 2024 UTC
# Line 1  Line 1 
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;
# Line 332  class Logger { Line 352  class Logger {
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: [
# Line 345  class Logger { Line 365  class Logger {
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({

Legend:
Removed from v.336  
changed lines
  Added in v.393

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26