Skip to content

Commit a90b4d8

Browse files
committed
updated
1 parent fa4dcaf commit a90b4d8

3 files changed

Lines changed: 258 additions & 187 deletions

File tree

README.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,42 @@ RegisterCommand('getusers', function(source, args, rawCommand)
4848
end
4949
end)
5050
end, false)
51+
52+
53+
Mongo:FindOne({
54+
collection = "developers",
55+
query = { steamhex = identifier }
56+
}, function(err, existingUser)
57+
if (err) then
58+
print("Error searching developer whitelist:", err)
59+
return cb(false)
60+
end
61+
62+
63+
64+
if (existingUser) then
65+
-- User found in whitelist
66+
print("User already in whitelist:", json.encode(existingUser))
67+
cb(true) -- Already whitelisted, treat as success
68+
elseif (not existingUser) then
69+
-- User not found, insert new whitelist entry
70+
Mongo:InsertOne({
71+
collection = "developers",
72+
document = {
73+
steamhex = identifier,
74+
addedAt = os.date("!%Y-%m-%dT%H:%M:%SZ") -- ISO 8601 UTC timestamp
75+
}
76+
}, function(err, result)
77+
if (err) then
78+
print("Failed to add user to developer list:", identifier, err)
79+
cb(false)
80+
else
81+
print("User added to developer list:", identifier)
82+
cb(true)
83+
end
84+
end)
85+
end
86+
end)
5187
```
5288

5389

src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,4 @@ for (const [name, fn] of Object.entries(TheQueries)) {
1717
setTimeout(() => {
1818
console.log("^2MongoDB module loaded and ready^7");
1919
}, 500);
20+

0 commit comments

Comments
 (0)