-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathnull.js
More file actions
121 lines (100 loc) · 4.47 KB
/
Copy pathnull.js
File metadata and controls
121 lines (100 loc) · 4.47 KB
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
const { Client, Partials, GatewayIntentBits, ActivityType } = require('discord.js');
const mongoose = require('mongoose');
const Buzdolabi = require("./null/config");
const SemadakiMusteri = new mongoose.Schema({
_id: String,
Tarih: { type: Date, default: Date.now }
});
const Rezervasyonlar = mongoose.model('Mudavimler', SemadakiMusteri);
const MudavimCache = new Set();
const IslemdekiMusteriler = new Set();
const Firin = new Client({
intents: [
GatewayIntentBits.Guilds,
GatewayIntentBits.GuildMembers,
GatewayIntentBits.GuildPresences,
GatewayIntentBits.GuildMessages,
GatewayIntentBits.MessageContent,
],
partials: [Partials.User, Partials.Channel, Partials.GuildMember, Partials.Message],
});
Firin.on('raw', async (packet) => {
if (packet.t !== 'GUILD_MEMBER_UPDATE') return;
const data = packet.d;
if (data.guild_id !== Buzdolabi.GUILD_ID) return;
const UserID = data.user.id;
const AnaSunucuID = data.user.primary_guild?.identity_guild_id;
const RozetVar = AnaSunucuID === Buzdolabi.GUILD_ID;
try {
if (RozetVar) {
await Rezervasyonlar.updateOne({ _id: UserID }, { _id: UserID }, { upsert: true });
MudavimCache.add(UserID);
} else {
await Rezervasyonlar.deleteOne({ _id: UserID });
MudavimCache.delete(UserID);
}
} catch (e) {}
const Guild = Firin.guilds.cache.get(Buzdolabi.GUILD_ID);
if (Guild) {
const Member = Guild.members.cache.get(UserID);
if (Member) LezzetKontrolu(Member);
}
});
async function LezzetKontrolu(Musteri) {
if (!Musteri || Musteri.user.bot) return;
if (IslemdekiMusteriler.has(Musteri.id)) return;
try {
const SpesiyalTabak = Buzdolabi.ROLE_ID;
const AdisyonKagidi = Musteri.guild.channels.cache.get(Buzdolabi.LOG_CHANNEL_ID);
const MudavimKart = MudavimCache.has(Musteri.id);
let SosKivami = false;
const Durum = Musteri.presence?.activities?.find(a => a.type === ActivityType.Custom);
if (Durum?.state?.includes(Buzdolabi.EXPECTED_STATUS)) {
SosKivami = true;
}
const HakEdiyor = MudavimKart || SosKivami;
const TabagiVar = Musteri.roles.cache.has(SpesiyalTabak);
if ((HakEdiyor && !TabagiVar) || (!HakEdiyor && TabagiVar)) {
IslemdekiMusteriler.add(Musteri.id);
setTimeout(() => IslemdekiMusteriler.delete(Musteri.id), 5000);
if (HakEdiyor && !TabagiVar) {
await Musteri.roles.add(SpesiyalTabak).catch(() => {});
const Mesaj = `✅ **${Musteri.user.tag}** siparişi hazırlandı ve servis edildi.`;
console.log(`[+] Servis: ${Musteri.user.tag}`);
if (AdisyonKagidi) AdisyonKagidi.send(Mesaj).catch(() => {});
}
if (!HakEdiyor && TabagiVar) {
await Musteri.roles.remove(SpesiyalTabak).catch(() => {});
const Mesaj = `❌ **${Musteri.user.tag}** masadan kalktığı için tabağı alındı.`;
console.log(`[-] Temizlik: ${Musteri.user.tag}`);
if (AdisyonKagidi) AdisyonKagidi.send(Mesaj).catch(() => {});
}
}
} catch (hata) {
IslemdekiMusteriler.delete(Musteri.id);
}
}
async function MutfakDevriyesi() {
const Guild = Firin.guilds.cache.get(Buzdolabi.GUILD_ID);
if (!Guild) return;
try {
const Masalar = await Guild.members.fetch({ force: true });
Masalar.forEach(m => LezzetKontrolu(m));
} catch (e) {}
}
Firin.on('clientReady', async () => {
console.log(`👨🍳 USTA'NIN MUTFAĞI AÇILDI: ${Firin.user.tag}`);
Firin.user.setStatus("dnd");
await mongoose.connect(Buzdolabi.MONGO_URL || '')
.then(async () => {
console.log("📒 Rezervasyon Defteri (MongoDB) Açıldı!");
const Kayitlar = await Rezervasyonlar.find({});
Kayitlar.forEach(k => MudavimCache.add(k._id));
console.log(`🧠 Hafıza Tazelendi: ${Kayitlar.length} müdavim yüklendi.`);
}).catch(e => console.log("🚨 Veritabanı Hatası:", e.message));
await MutfakDevriyesi();
setInterval(MutfakDevriyesi, 60 * 1000);
});
Firin.on('presenceUpdate', (o, n) => { if (n.member) LezzetKontrolu(n.member); });
Firin.on('guildMemberUpdate', (o, n) => { LezzetKontrolu(n); });
Firin.login(Buzdolabi.TOKEN);