/[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 393 by rakin, Mon Jul 29 17:29:59 2024 UTC revision 559 by rakin, Mon Jul 29 17:30:49 2024 UTC
# Line 27  import { timeSince } from '../utils/util Line 27  import { timeSince } from '../utils/util
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    
# Line 135  class Logger { Line 145  class Logger {
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              }              }
# Line 144  class Logger { Line 153  class Logger {
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    
# Line 159  class Logger { Line 172  class Logger {
172                      })                      })
173                      .addField('Reason', r)                      .addField('Reason', r)
174                      .addField('User ID', ban.user.id)                      .addField('User ID', ban.user.id)
175                        .addFields({
176                            name: 'Banned by',
177                            value: auditLog?.executor ? `${auditLog.executor.tag} (${auditLog.executor.id})` : 'Unknown'
178                        })
179                      .setFooter({                      .setFooter({
180                          text: "Banned",                          text: "Banned",
181                      })                      })
# Line 185  class Logger { Line 202  class Logger {
202                  const { target, reason } = await auditLog;                  const { target, reason } = await auditLog;
203    
204                  if (target!.id === user.id && reason) {                  if (target!.id === user.id && reason) {
205                      r = await reason;                      r = reason.replace(/^\[SOFTBAN\]/, '');
206                  }                  }
207              }              }
208    
# Line 229  class Logger { Line 246  class Logger {
246                  const { target, reason } = await auditLog;                  const { target, reason } = await auditLog;
247    
248                  if (target!.id === user.id && reason) {                  if (target!.id === user.id && reason) {
249                      r = await reason;                      r = reason.replace(/^\[TEMPBAN\]/, '');
250                  }                  }
251              }              }
252    

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

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26