start logging, only feature changes for now
This commit is contained in:
		
							parent
							
								
									31120b2fd8
								
							
						
					
					
						commit
						3ef01779be
					
				
					 1 changed files with 55 additions and 0 deletions
				
			
		
							
								
								
									
										55
									
								
								src/modules/logging.js
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										55
									
								
								src/modules/logging.js
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
					@ -0,0 +1,55 @@
 | 
				
			||||||
 | 
					const {getGuildData} = require("#lib/guildData.js");
 | 
				
			||||||
 | 
					const events = require("#lib/events.js");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					//const {AuditLogActions} = require("#util/dconstants.js");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					//const COLOR_ADDED = 0x399d53;
 | 
				
			||||||
 | 
					//const COLOR_REMOVED = 0xe55152;
 | 
				
			||||||
 | 
					const COLOR_CHANGED = 0x3c8cec;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					async function getLoggingChannel(guild) {
 | 
				
			||||||
 | 
					  const channelId = await getGuildData(guild.id, "logging_channel", "");
 | 
				
			||||||
 | 
					  return guild.channels.get(channelId) ?? guild.threads.get(channelId);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/*events.add("guildAuditLogEntryCreate", "logging", async function (entry) {
 | 
				
			||||||
 | 
					  const channel = await getLoggingChannel(entry.guild);
 | 
				
			||||||
 | 
					  if (!channel) return;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  switch (entry.actionType) {
 | 
				
			||||||
 | 
					    case AuditLogActions.GUILD_UPDATE: {
 | 
				
			||||||
 | 
					      break;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					});*/
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					events.add("guildUpdate", "logging", async function (guild, oldGuild) {
 | 
				
			||||||
 | 
					  const channel = await getLoggingChannel(guild);
 | 
				
			||||||
 | 
					  if (!channel) return;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  const featuresAdded = oldGuild.features.filter((f) => !guild.features.includes(f));
 | 
				
			||||||
 | 
					  const featuresRemoved = guild.features.filter((f) => !oldGuild.features.includes(f));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  if (featuresAdded.length === 0 && featuresRemoved.length === 0) return;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  let diff = "```diff\n";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  if (featuresAdded.length > 0) diff += "+ " + featuresAdded.join("\n+ ");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  if (featuresRemoved.length > 0) {
 | 
				
			||||||
 | 
					    if (featuresAdded.length > 0) diff += "\n";
 | 
				
			||||||
 | 
					    diff += "- " + featuresAdded.join("\n- ");
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  diff += "```";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  channel.createMessage({
 | 
				
			||||||
 | 
					    embeds: [
 | 
				
			||||||
 | 
					      {
 | 
				
			||||||
 | 
					        color: COLOR_CHANGED,
 | 
				
			||||||
 | 
					        title: "Features Updated",
 | 
				
			||||||
 | 
					        content: diff,
 | 
				
			||||||
 | 
					      },
 | 
				
			||||||
 | 
					    ],
 | 
				
			||||||
 | 
					  });
 | 
				
			||||||
 | 
					});
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue