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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 24 - (hide annotations)
Mon Jul 29 17:28:15 2024 UTC (8 months, 1 week ago) by rakin
Original Path: trunk/src/Logger.js
File MIME type: text/javascript
File size: 1962 byte(s)
Fixed crash logging when sending long messages
1 rakin 5 const { MessageEmbed } = require('discord.js');
2    
3     class Logger {
4     constructor() {
5    
6     }
7    
8     channel(callback, msg) {
9     let channelID = app.config.get('logging_channel');
10     let channel = msg.guild.channels.cache.find(c => c.id === channelID);
11    
12     if (channel) {
13     return callback(channel);
14     }
15     }
16    
17     logEdit(oldMsg, newMsg) {
18     this.channel(async (channel) => {
19     await channel.send({
20     embeds: [
21     new MessageEmbed()
22     .setColor('#007bff')
23     .setTitle('Message Edited in #' + newMsg.channel.name + " (" + newMsg.channel.id + ")")
24 rakin 24 .setDescription('**Before**\n' + oldMsg.content + '\n\**nAfter**\n', newMsg.content)
25 rakin 5 .addField('ID', newMsg.id)
26     .setAuthor({
27     name: newMsg.author.tag,
28     iconURL: newMsg.author.displayAvatarURL(),
29     })
30     .setFooter({
31     text: "Edited",
32     })
33     .setTimestamp()
34     ]
35     });
36     }, newMsg);
37     }
38    
39     logDelete(msg) {
40     this.channel(async (channel) => {
41     await channel.send({
42     embeds: [
43     new MessageEmbed()
44     .setColor('#f14a60')
45     .setTitle('Message Deleted in #' + msg.channel.name + " (" + msg.channel.id + ")")
46     .setDescription(msg.content)
47     .setAuthor({
48     name: msg.author.tag,
49     iconURL: msg.author.displayAvatarURL(),
50     })
51     .addField('ID', msg.id)
52     .setFooter({
53     text: "Deleted",
54     })
55     .setTimestamp()
56     ]
57     });
58     }, msg);
59     }
60     }
61    
62     module.exports = Logger;

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26