-
Notifications
You must be signed in to change notification settings - Fork 0
/
bot.js
44 lines (39 loc) · 1.41 KB
/
bot.js
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
require("dotenv").config(); //to start process from .env file
// get client and Intents
const { Client, GatewayIntentBits } = require('discord.js')
const client = new Client({
intents: [
GatewayIntentBits.Guilds,
GatewayIntentBits.GuildMessages,
GatewayIntentBits.GuildPresences,
GatewayIntentBits.MessageContent,
]
});
// Check that bot is online
client.on("ready", () => {
console.log("NazarCheker is online!"); // message when bot is online
client.user.setActivity('Терабонькає');
});
// Nazar command
client.on("messageCreate", (message) => {
if (message.content === "Назар") {
client.channels.cache.get('935587206343581740').send('Прошу не турбувати Назара!');
}
});
// check for Nazar online status
client.on('presenceUpdate', (oldPresence, newPresence) => {
// if other user update status, just return
if (newPresence.userId !== '966282072144613417') return;
// no changes, just return
if (oldPresence.status === newPresence.status) return;
// if new status != online, again, just return
if (newPresence.status !== 'online') return;
//send message if no errors
try {
client.channels.cache.get('935587206343581740').send('@everyone @everyone Назар появився онлайн!');
} catch (error) {
console.log(error);
}
});
// Run a bot
client.login(process.env.TOKEN);