mirror of
https://github.com/danbulant/Shasha
synced 2026-07-06 03:21:00 +00:00
guildUpdate.js beta
This commit is contained in:
parent
dae9316933
commit
d410a594e9
1 changed files with 30 additions and 2 deletions
|
|
@ -1,6 +1,10 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const { Guild } = require("discord.js");
|
const { Guild } = require("discord.js");
|
||||||
|
const { Interval } = require("luxon");
|
||||||
|
const { intervalToDuration } = require("../../cmds/moderation/src/duration");
|
||||||
|
const { defaultEventLogEmbed, trySend } = require("../functions");
|
||||||
|
const getColor = require("../getColor");
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {Guild} oldGuild
|
* @param {Guild} oldGuild
|
||||||
|
|
@ -8,6 +12,30 @@ const { Guild } = require("discord.js");
|
||||||
*/
|
*/
|
||||||
module.exports = async (oldGuild, newGuild) => {
|
module.exports = async (oldGuild, newGuild) => {
|
||||||
if (!newGuild.DB) await newGuild.dbLoad();
|
if (!newGuild.DB) await newGuild.dbLoad();
|
||||||
let audit = (await newGuild.fetchAuditLogs({ "limit": 1, "type": "GUILD_UPDATE" })).entries.first();
|
if (newGuild.DB.eventChannels.guild) {
|
||||||
console.log(audit);
|
const logChannel = newGuild.channels.cache.get(newGuild.DB.eventChannels.guild);
|
||||||
|
if (!logChannel) return;
|
||||||
|
let audit = {};
|
||||||
|
if (newGuild.me.hasPermission("VIEW_AUDIT_LOG")) {
|
||||||
|
audit = (await newGuild.fetchAuditLogs({ "limit": 1, "type": "GUILD_UPDATE" })).entries.first();
|
||||||
|
} else audit.reason = "Unknown reason";
|
||||||
|
const emb = defaultEventLogEmbed(newGuild).setColor(getColor("cyan"));
|
||||||
|
if (oldGuild.afkChannelID !== newGuild.afkChannelID) {
|
||||||
|
emb.addField("Inactive Channel", "Changed from " + (oldGuild.afkChannelID ? "<#" + oldGuild.afkChannelID + ">" : "`[NONE]`") +
|
||||||
|
" to " + (newGuild.afkChannelID ? "<#" + newGuild.afkChannelID + ">" : "`[NONE]`"));
|
||||||
|
};
|
||||||
|
if (oldGuild.afkTimeout !== newGuild.afkTimeout) {
|
||||||
|
const newAfkTDuration = intervalToDuration(Interval.after(new Date(),
|
||||||
|
newGuild.afkTimeout * 1000)).strings.join(" ");
|
||||||
|
const oldAfkTDuration = intervalToDuration(Interval.after(new Date(),
|
||||||
|
oldGuild.afkTimeout * 1000)).strings.join(" ");
|
||||||
|
emb.addField("Inactive Timeout", "Changed from `" + oldAfkTDuration + "` to `" + newAfkTDuration + "`");
|
||||||
|
};
|
||||||
|
|
||||||
|
emb.setTitle(`Guild Settings Updated ${audit.executor ? "by `" + audit.executor.tag + "`" : ""}`)
|
||||||
|
.setDescription(audit.reason || "No reason provided");
|
||||||
|
if (audit.executor)
|
||||||
|
emb.setAuthor(emb.author.name, audit.executor.displayAvatarURL({ size: 128, format: "png", dynamic: true }));
|
||||||
|
return trySend(newGuild.client, logChannel, emb);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Loading…
Reference in a new issue