/[sudobot]/trunk/src/Logger.js
ViewVC logotype

Contents of /trunk/src/Logger.js

Parent Directory Parent Directory | Revision Log Revision Log


Revision 5 - (show annotations)
Mon Jul 29 17:28:11 2024 UTC (8 months ago) by rakin
File MIME type: text/javascript
File size: 1968 byte(s)
Added base commands
1 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 .addField('Before', oldMsg.content)
25 .addField('After', newMsg.content)
26 .addField('ID', newMsg.id)
27 .setAuthor({
28 name: newMsg.author.tag,
29 iconURL: newMsg.author.displayAvatarURL(),
30 })
31 .setFooter({
32 text: "Edited",
33 })
34 .setTimestamp()
35 ]
36 });
37 }, newMsg);
38 }
39
40 logDelete(msg) {
41 this.channel(async (channel) => {
42 await channel.send({
43 embeds: [
44 new MessageEmbed()
45 .setColor('#f14a60')
46 .setTitle('Message Deleted in #' + msg.channel.name + " (" + msg.channel.id + ")")
47 .setDescription(msg.content)
48 .setAuthor({
49 name: msg.author.tag,
50 iconURL: msg.author.displayAvatarURL(),
51 })
52 .addField('ID', msg.id)
53 .setFooter({
54 text: "Deleted",
55 })
56 .setTimestamp()
57 ]
58 });
59 }, msg);
60 }
61 }
62
63 module.exports = Logger;

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26