Compare commits

...

2 Commits

Author SHA1 Message Date
523f057ea3 enable pinging deactivated members by role 2022-03-31 13:20:46 -07:00
a0a9383d32 undot am pm 2022-03-31 12:27:54 -07:00
2 changed files with 12 additions and 4 deletions

View File

@ -55,9 +55,9 @@ module.exports.interval = setInterval(async () => {
async function deactivateMember(member) {
//if (ds.get(member.id + "deactivated")) return "member is already deactivated";
await member.roles.add(config.inactive_role);
ds.put(member.id + "deactivated");
ds.put(member.id, Date.now());
var magic_channel = client.channels.resolve(ds.get(member.id + "magicchannelid"));
if (!magic_channel) {
@ -96,7 +96,6 @@ async function deactivateMember(member) {
}
async function reactivateMember(member) {
//if (!ds.get(member.id + "deactivated")) return "member is not deactivated";
await member.roles.remove(config.inactive_role);
ds.del(member.id + "deactivated");
var magic_channel = client.channels.resolve(ds.get(member.id + "magicchannelid"));
@ -104,4 +103,14 @@ async function reactivateMember(member) {
}
module.exports.deactivateMember = deactivateMember;
module.exports.reactivateMember = reactivateMember;
module.exports.reactivateMember = reactivateMember;
client.on("messageCreate", message => {
if (message.guildId != config.guild) return;
let deactivatedMembersMentionedViaRoles = [...new Set(message.mentions.roles.flatMap(r => r.members).values())].filter(x => ds.get(x.id + "deactivated"));
if (deactivatedMembersMentionedViaRoles.length) {
for (let m of deactivatedMembersMentionedViaRoles) await reactivateMember(m);
await message.reply({content: deactivatedMembersMentionedViaRoles.map(String).join(' '), allowedMentions:{repliedUser: false}});
}
});

View File

@ -13,7 +13,6 @@ client.once("ready", () => {
hour12: true
}).format(d);
t = t.replace(/[a-z]+(?: |$)/g, ''); // most of the abbrv are GMT+n >:(
t = t.replace("AM", "A.M.").replace("PM", "P.M.");
client.channels.resolve(x.channel)?.setName(t);
}
d.setMinutes(60);