Compare commits

...

2 commits

Author SHA1 Message Date
3ef01779be
start logging, only feature changes for now 2025-04-23 18:52:50 -06:00
31120b2fd8
update dysnomia 2025-04-23 18:41:51 -06:00
2 changed files with 59 additions and 4 deletions

8
pnpm-lock.yaml generated
View file

@ -16,7 +16,7 @@ importers:
version: 1.7.0 version: 1.7.0
'@projectdysnomia/dysnomia': '@projectdysnomia/dysnomia':
specifier: github:projectdysnomia/dysnomia#dev specifier: github:projectdysnomia/dysnomia#dev
version: https://codeload.github.com/projectdysnomia/dysnomia/tar.gz/450795bb5b38c8dc6940eec7f2ef6655138e0600 version: https://codeload.github.com/projectdysnomia/dysnomia/tar.gz/487248df32d9a11e1b23e638504ab427604ce9a4
dumpy: dumpy:
specifier: github:Cynosphere/dumpy.js specifier: github:Cynosphere/dumpy.js
version: https://codeload.github.com/Cynosphere/dumpy.js/tar.gz/5fc22353cdcb97084bab572266390e780d9f7a7b(encoding@0.1.13) version: https://codeload.github.com/Cynosphere/dumpy.js/tar.gz/5fc22353cdcb97084bab572266390e780d9f7a7b(encoding@0.1.13)
@ -462,8 +462,8 @@ packages:
resolution: {integrity: sha512-aGQIwo6/sWtyyqhVK4e1MtxYz4N1X8CNt6SOtCc+Wnczs5S5ONaLHDDR8LYaGn0MgOwvGgXyuZ5sJIfd7iyoUw==} resolution: {integrity: sha512-aGQIwo6/sWtyyqhVK4e1MtxYz4N1X8CNt6SOtCc+Wnczs5S5ONaLHDDR8LYaGn0MgOwvGgXyuZ5sJIfd7iyoUw==}
engines: {node: '>=0.10'} engines: {node: '>=0.10'}
'@projectdysnomia/dysnomia@https://codeload.github.com/projectdysnomia/dysnomia/tar.gz/450795bb5b38c8dc6940eec7f2ef6655138e0600': '@projectdysnomia/dysnomia@https://codeload.github.com/projectdysnomia/dysnomia/tar.gz/487248df32d9a11e1b23e638504ab427604ce9a4':
resolution: {tarball: https://codeload.github.com/projectdysnomia/dysnomia/tar.gz/450795bb5b38c8dc6940eec7f2ef6655138e0600} resolution: {tarball: https://codeload.github.com/projectdysnomia/dysnomia/tar.gz/487248df32d9a11e1b23e638504ab427604ce9a4}
version: 0.2.2 version: 0.2.2
engines: {node: '>=18.0.0'} engines: {node: '>=18.0.0'}
peerDependencies: peerDependencies:
@ -2146,7 +2146,7 @@ snapshots:
jsprim: 1.4.2 jsprim: 1.4.2
sshpk: 1.17.0 sshpk: 1.17.0
'@projectdysnomia/dysnomia@https://codeload.github.com/projectdysnomia/dysnomia/tar.gz/450795bb5b38c8dc6940eec7f2ef6655138e0600': '@projectdysnomia/dysnomia@https://codeload.github.com/projectdysnomia/dysnomia/tar.gz/487248df32d9a11e1b23e638504ab427604ce9a4':
dependencies: dependencies:
ws: 8.18.0 ws: 8.18.0
optionalDependencies: optionalDependencies:

55
src/modules/logging.js Normal file
View 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,
},
],
});
});