Skip to content

Commit

Permalink
fix(sendMessage): Handle RunAttestationCommand in response actions (#…
Browse files Browse the repository at this point in the history
…859)

* fix(sendMessage): Handle `RunAttestationCommand` in response actions

Handle the case when `RunAttestationCommand` is included in the
`sendMessage()` response actions.

* style: trim trailing whitespace
  • Loading branch information
jonz94 authored Dec 27, 2024
1 parent 913dcc7 commit 826a954
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/parser/youtube/LiveChat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { InnertubeError, Platform, u8ToBase64 } from '../../utils/Utils.js';
import { LiveChatContinuation, Parser } from '../index.js';
import SmoothedQueue from './SmoothedQueue.js';

import RunAttestationCommand from '../classes/commands/RunAttestationCommand.js';
import AddChatItemAction from '../classes/livechat/AddChatItemAction.js';
import UpdateDateTextAction from '../classes/livechat/UpdateDateTextAction.js';
import UpdateDescriptionAction from '../classes/livechat/UpdateDescriptionAction.js';
Expand Down Expand Up @@ -251,15 +252,15 @@ export default class LiveChat extends EventEmitter {
* Sends a message.
* @param text - Text to send.
*/
async sendMessage(text: string): Promise<ObservedArray<AddChatItemAction>> {
async sendMessage(text: string): Promise<ObservedArray<AddChatItemAction | RunAttestationCommand>> {
const writer = LiveMessageParams.encode({
params: {
ids: {
videoId: this.#video_id,
channelId: this.#channel_id
}
},
number0: 1,
number0: 1,
number1: 4
});

Expand All @@ -276,7 +277,7 @@ export default class LiveChat extends EventEmitter {
if (!response.actions)
throw new InnertubeError('Unexpected response from send_message', response);

return response.actions.array().as(AddChatItemAction);
return response.actions.array().as(AddChatItemAction, RunAttestationCommand);
}

/**
Expand Down

0 comments on commit 826a954

Please sign in to comment.