Skip to content

Commit b6fa4fd

Browse files
authored
Add UserDb.createNewUser, fix FirebotUser attribute types (#31)
* Add UserDb.createNewUser, fix FireBotUser attribute types FirebotUser._id is now a string FirebotUser.onlineAt, FirebotUser.lastSeen, and FirebotUser.joinDate are raw timestamp values. * chore: run prettier
1 parent 9bb1cd0 commit b6fa4fd

1 file changed

Lines changed: 26 additions & 7 deletions

File tree

types/modules/user-db.d.ts

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,17 @@
11
type FirebotUser = {
2-
readonly _id: number;
2+
readonly _id: string;
33
username: string;
44
displayName: string;
55
profilePicUrl: string;
66
twitch: boolean;
77
twitchRoles: string[];
88
online: boolean;
9-
onlineAt: Date;
10-
lastSeen: Date;
11-
joinDate: Date;
9+
/** Timestamp value */
10+
onlineAt: number;
11+
/** Timestamp value */
12+
lastSeen: number;
13+
/** Timestamp value */
14+
joinDate: number;
1215
minutesInChannel: number;
1316
chatMessages: number;
1417
disableAutoStatAccrual: boolean;
@@ -24,9 +27,25 @@ type FirebotUser = {
2427
};
2528

2629
export type UserDb = {
27-
getTwitchUserByUsername: (
28-
username: string
29-
) => Promise<FirebotUser | undefined>;
30+
getTwitchUserByUsername: (username: string) => Promise<FirebotUser | null>;
31+
/**
32+
* Creates a new user in the database. Returns the created user if successful.
33+
*
34+
* @param userId User's Twitch account ID
35+
* @param username Twitch username
36+
* @param displayName Twitch display name
37+
* @param profilePicUrl Profile pic URL, if available
38+
* @param twitchRoles List of role strings, if applicable
39+
* @param isOnline Whether the user is currently online, defaults to false
40+
*/
41+
createNewUser: (
42+
userId: string,
43+
username: string,
44+
displayName: string,
45+
profilePicUrl?: string,
46+
twitchRoles?: string[],
47+
isOnline?: boolean
48+
) => Promise<FirebotUser | null>;
3049
/**
3150
* Updates the given user in the database. Returns true if successful.
3251
* @param user that should be updated.

0 commit comments

Comments
 (0)