-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlogout.ts
47 lines (39 loc) · 1.09 KB
/
logout.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
/**
* Don't delete/edit this file directly!!
*/
import type { proto } from "@whiskeysockets/baileys";
import type createWhatsappSocket from "../lib/socket";
import utils from "@/lib/utils";
import logger from "@/lib/logger";
const pingCommand = {
name: "logout",
description: "Logout from the session",
execute: async (socket: ReturnType<typeof createWhatsappSocket>, {
jid,
msg,
args,
}: {
jid: string;
msg: proto.IWebMessageInfo,
args: string[];
}) =>
{
const sock = await socket
const phoneNumber = utils.jidToPhoneNumber(jid)
if (!sock.user?.id.includes(phoneNumber)) {
logger.warn({
senderJid: jid,
adminJid: sock.authState.creds.me?.id
}, "Forbidden command triggered!")
return;
};
await sock.sendMessage(jid, {
text: `Successfully disconnect for WhatsApp account`,
mentions: [jid]
}, {
quoted: msg
})
sock.logout()
}
}
export default pingCommand;