Skip to content

Commit

Permalink
Add missing sent date tag (#332)
Browse files Browse the repository at this point in the history
* Adds missing date tag

* Forgotten string conversion

Co-authored-by: Romybron <>
  • Loading branch information
Romybron committed Feb 6, 2022
1 parent 96675eb commit c2753f7
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 0 deletions.
Expand Up @@ -15,6 +15,11 @@ export class ClearChat extends Message<ClearChat> {
})
user!: MessageParam;

get date(): Date {
const timestamp = this._tags.get('tmi-sent-ts')!;
return new Date(Number(timestamp));
}

get channelId(): string {
return this._tags.get('room-id')!;
}
Expand Down
Expand Up @@ -22,6 +22,11 @@ export class UserNotice extends Message<UserNotice> {
return this._tags.get('id')!;
}

get date(): Date {
const timestamp = this._tags.get('tmi-sent-ts')!;
return new Date(Number(timestamp));
}

get userInfo(): ChatUser {
return new ChatUser(this._tags.get('login')!, this._tags);
}
Expand Down
5 changes: 5 additions & 0 deletions packages/chat/src/caps/twitchTags/messageTypes/ClearMsg.ts
Expand Up @@ -17,6 +17,11 @@ export class ClearMsg extends Message<ClearMsg> {
})
message!: MessageParam;

get date(): Date {
const timestamp = this._tags.get('tmi-sent-ts')!;
return new Date(Number(timestamp));
}

get userName(): string {
return this._tags.get('login')!;
}
Expand Down
8 changes: 8 additions & 0 deletions packages/chat/src/commands/TwitchPrivateMessage.ts
Expand Up @@ -16,6 +16,14 @@ export class TwitchPrivateMessage extends MessageTypes.Commands.PrivateMessage {
return this._tags.get('id')!;
}

/**
* The date the message was sent at.
*/
get date(): Date {
const timestamp = this._tags.get('tmi-sent-ts')!;
return new Date(Number(timestamp));
}

/**
* Info about the user that send the message, like their user ID and their status in the current channel.
*/
Expand Down

0 comments on commit c2753f7

Please sign in to comment.