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:
parent
7f75d6d8d3
commit
b6c822e826
10 changed files with 262 additions and 0 deletions
28
backend/src/plugins/AFK/events/AFKNotificationEvt.ts
Normal file
28
backend/src/plugins/AFK/events/AFKNotificationEvt.ts
Normal 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);
|
||||
}
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue