/[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 54 by rakin, Mon Jul 29 17:28:24 2024 UTC revision 65 by rakin, Mon Jul 29 17:28:27 2024 UTC
# Line 1  Line 1 
1  import { roleMention } from '@discordjs/builders';  import { roleMention } from '@discordjs/builders';
2  import { GuildBan, GuildMember, Message, MessageEmbed, TextChannel, User } from 'discord.js';  import { FileOptions, GuildBan, GuildMember, Message, MessageEmbed, TextChannel, User } from 'discord.js';
3  import DiscordClient from '../client/Client';  import DiscordClient from '../client/Client';
4  import { timeProcess, timeSince } from '../utils/util';  import { timeProcess, timeSince } from '../utils/util';
5    
# Line 19  class Logger { Line 19  class Logger {
19          }          }
20      }      }
21    
22      channelJoinLeft(callback: (channel: TextChannel) => any, msg: Message | GuildBan) {      channelJoinLeft(callback: (channel: TextChannel) => any, msg: any) {
23          let channelID = this.client.config.props[msg.guild!.id].logging_channel_join_leave;          let channelID = this.client.config.props[msg.guild!.id].logging_channel_join_leave;
24          let channel = msg.guild!.channels.cache.find(c => c.id === channelID) as TextChannel;          let channel = msg.guild!.channels.cache.find((c: any) => c.id === channelID) as TextChannel;
25    
26          if (channel) {          if (channel) {
27              return callback(channel);              return callback(channel);
# Line 65  class Logger { Line 65  class Logger {
65                      text: "Deleted",                      text: "Deleted",
66                  })                  })
67                  .setTimestamp();                  .setTimestamp();
68                
69                const files: FileOptions[] = [];
70    
71              if (msg.attachments.size > 0) {              if (msg.attachments.size > 0) {
72                  let str = '';                  let str = '';
73    
74                  msg.attachments.forEach(a => {                  msg.attachments.forEach(a => {
75                      str += `**${a.name}** ${a.url}\n`;                      str += `${a.name}\n`;
76                        files.push({
77                            name: a.name!,
78                            attachment: a.proxyURL
79                        });
80                  });                  });
81    
82                  embed.addField('Attachments', str);                  embed.addField('Attachments (top)', str);
83              }              }
84    
85              await channel.send({              await channel.send({
86                  embeds: [                  embeds: [
87                      embed                      embed
88                  ]                  ],
89                    files
90              });              });
91          }, msg);          }, msg);
92      }      }
# Line 88  class Logger { Line 95  class Logger {
95          this.channel(async (channel) => {          this.channel(async (channel) => {
96              let r = '*No reason provided*';              let r = '*No reason provided*';
97    
98                const auditLog = (await ban.guild.fetchAuditLogs({
99                    limit: 1,
100                    type: 'MEMBER_BAN_ADD',
101                })).entries.first();          
102          
103    
104              if (ban.reason) {              if (ban.reason) {
105                  r = ban.reason;                  r = ban.reason;
106              }              }
107                else if (auditLog) {
108                    console.log(auditLog);  
109                    const { target, reason } = await auditLog;
110    
111                    if (target!.id === ban.user.id && reason) {
112                        r = await reason;
113                    }
114                }
115    
116              await channel.send({              await channel.send({
117                  embeds: [                  embeds: [

Legend:
Removed from v.54  
changed lines
  Added in v.65

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26