3
0
Fork 0
mirror of https://github.com/ZeppelinBot/Zeppelin.git synced 2025-05-21 16:55:03 +00:00

feat: AFK Command

This commit is contained in:
Jonathan 2021-04-02 23:09:12 -04:00
parent 7f75d6d8d3
commit b6c822e826
No known key found for this signature in database
GPG key ID: 19B04E3CBE0885B1
10 changed files with 262 additions and 0 deletions

View file

@ -0,0 +1,28 @@
import { sendUserMentionMessage, sendWelcomeBackMessage } from "../functions/buildAFKMessages";
import { afkEvt } from "../types";
export const AFKNotificationEvt = afkEvt({
event: 'messageCreate',
listener: async ({ pluginData, args: { message } }) => {
// Mention Check (if someone mentions the AFK user)
if (message.mentions.length) {
const afk = await pluginData.state.afkUsers.getUserAFKStatus(message.mentions[0].id);
if (!afk) return;
sendUserMentionMessage(message, afk.status);
return;
}
// Self AFK Check (if user is the one that's AFK)
const afk = await pluginData.state.afkUsers.getUserAFKStatus(message.author.id);
if (!afk) return;
try {
await pluginData.state.afkUsers.clearAFKStatus(message.author.id);
} catch (err) {}
sendWelcomeBackMessage(message);
}
});