Socket
Socket
Sign inDemoInstall

@twurple/api

Package Overview
Dependencies
Maintainers
1
Versions
146
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@twurple/api - npm Package Compare versions

Comparing version 7.1.0-pre.1 to 7.1.0-pre.2

es/endpoints/channel/HelixAdSchedule.mjs

14

lib/endpoints/channel/HelixChannelApi.d.ts

@@ -15,2 +15,4 @@ import { type CommercialLength, type UserIdResolvable } from '@twurple/common';

import { HelixFollowedChannel } from './HelixFollowedChannel';
import { HelixAdSchedule } from './HelixAdSchedule';
import { HelixSnoozeNextAdResult } from './HelixSnoozeNextAdResult';
/**

@@ -171,3 +173,15 @@ * The Helix API methods that deal with channels.

getFollowedChannelsPaginated(user: UserIdResolvable, broadcaster?: UserIdResolvable): HelixPaginatedRequestWithTotal<HelixFollowedChannelData, HelixFollowedChannel>;
/**
* Gets information about the broadcaster's ad schedule.
*
* @param broadcaster The broadcaster to get ad schedule information about.
*/
getAdSchedule(broadcaster: UserIdResolvable): Promise<HelixAdSchedule>;
/**
* Snoozes the broadcaster's next ad, if a snooze is available.
*
* @param broadcaster The broadcaster to get ad schedule information about.
*/
snoozeNextAd(broadcaster: UserIdResolvable): Promise<HelixSnoozeNextAdResult>;
}
//# sourceMappingURL=HelixChannelApi.d.ts.map

@@ -21,2 +21,4 @@ "use strict";

const HelixFollowedChannel_1 = require("./HelixFollowedChannel");
const HelixAdSchedule_1 = require("./HelixAdSchedule");
const HelixSnoozeNextAdResult_1 = require("./HelixSnoozeNextAdResult");
/**

@@ -337,2 +339,34 @@ * The Helix API methods that deal with channels.

}
/**
* Gets information about the broadcaster's ad schedule.
*
* @param broadcaster The broadcaster to get ad schedule information about.
*/
async getAdSchedule(broadcaster) {
const response = await this._client.callApi({
type: 'helix',
url: 'channels/ads',
method: 'GET',
userId: (0, common_1.extractUserId)(broadcaster),
scopes: ['channel:read:ads'],
query: (0, api_call_1.createBroadcasterQuery)(broadcaster),
});
return new HelixAdSchedule_1.HelixAdSchedule(response.data[0]);
}
/**
* Snoozes the broadcaster's next ad, if a snooze is available.
*
* @param broadcaster The broadcaster to get ad schedule information about.
*/
async snoozeNextAd(broadcaster) {
const response = await this._client.callApi({
type: 'helix',
url: 'channels/ads/schedule/snooze',
method: 'POST',
userId: (0, common_1.extractUserId)(broadcaster),
scopes: ['channel:manage:ads'],
query: (0, api_call_1.createBroadcasterQuery)(broadcaster),
});
return new HelixSnoozeNextAdResult_1.HelixSnoozeNextAdResult(response.data[0]);
}
};

@@ -339,0 +373,0 @@ tslib_1.__decorate([

34

lib/endpoints/chat/HelixChatApi.d.ts
import { type UserIdResolvable } from '@twurple/common';
import { type HelixChatChatterData, type HelixChatUserColor } from '../../interfaces/endpoints/chat.external';
import { type HelixSendChatAnnouncementParams, type HelixUpdateChatSettingsParams } from '../../interfaces/endpoints/chat.input';
import { type HelixSendChatAnnouncementParams, type HelixSendChatMessageParams, type HelixUpdateChatSettingsParams } from '../../interfaces/endpoints/chat.input';
import { HelixPaginatedRequestWithTotal } from '../../utils/pagination/HelixPaginatedRequestWithTotal';

@@ -15,2 +15,3 @@ import { type HelixPaginatedResultWithTotal } from '../../utils/pagination/HelixPaginatedResult';

import { HelixPrivilegedChatSettings } from './HelixPrivilegedChatSettings';
import { HelixSentChatMessage } from './HelixSentChatMessage';
/**

@@ -112,2 +113,33 @@ * The Helix API methods that deal with chat.

/**
* Sends a chat message to a broadcaster's chat.
*
* This uses the token of the broadcaster by default.
* If you want to execute this in the context of another user
* you can do so using [user context overrides](/docs/auth/concepts/context-switching).
*
* @expandParams
*
* @param broadcaster The broadcaster the chat belongs to.
* @param message The message to send.
* @param params
*/
sendChatMessage(broadcaster: UserIdResolvable, message: string, params?: HelixSendChatMessageParams): Promise<HelixSentChatMessage>;
/**
* Sends a chat message to a broadcaster's chat, using an app token.
*
* This requires the scopes `user:write:chat` and `user:bot` for the `user` and `channel:bot` for the `broadcaster`.
* `channel:bot` is not required if the `user` has moderator privileges in the `broadcaster`'s channel.
*
* These scope requirements can not be checked by the library, so they are just assumed.
* Make sure to catch authorization errors yourself.
*
* @expandParams
*
* @param user The user to send the chat message from.
* @param broadcaster The broadcaster the chat belongs to.
* @param message The message to send.
* @param params
*/
sendChatMessageAsApp(user: UserIdResolvable, broadcaster: UserIdResolvable, message: string, params?: HelixSendChatMessageParams): Promise<HelixSentChatMessage>;
/**
* Sends an announcement to a broadcaster's chat.

@@ -114,0 +146,0 @@ *

@@ -20,2 +20,3 @@ "use strict";

const HelixPrivilegedChatSettings_1 = require("./HelixPrivilegedChatSettings");
const HelixSentChatMessage_1 = require("./HelixSentChatMessage");
/**

@@ -207,2 +208,58 @@ * The Helix API methods that deal with chat.

/**
* Sends a chat message to a broadcaster's chat.
*
* This uses the token of the broadcaster by default.
* If you want to execute this in the context of another user
* you can do so using [user context overrides](/docs/auth/concepts/context-switching).
*
* @expandParams
*
* @param broadcaster The broadcaster the chat belongs to.
* @param message The message to send.
* @param params
*/
async sendChatMessage(broadcaster, message, params) {
const broadcasterId = (0, common_1.extractUserId)(broadcaster);
const result = await this._client.callApi({
type: 'helix',
url: 'chat/messages',
method: 'POST',
userId: broadcasterId,
canOverrideScopedUserContext: true,
scopes: ['user:write:chat'],
query: (0, chat_external_1.createSendChatMessageQuery)(broadcasterId, this._getUserContextIdWithDefault(broadcasterId)),
jsonBody: (0, chat_external_1.createSendChatMessageBody)(message, params),
});
return new HelixSentChatMessage_1.HelixSentChatMessage(result.data[0]);
}
/**
* Sends a chat message to a broadcaster's chat, using an app token.
*
* This requires the scopes `user:write:chat` and `user:bot` for the `user` and `channel:bot` for the `broadcaster`.
* `channel:bot` is not required if the `user` has moderator privileges in the `broadcaster`'s channel.
*
* These scope requirements can not be checked by the library, so they are just assumed.
* Make sure to catch authorization errors yourself.
*
* @expandParams
*
* @param user The user to send the chat message from.
* @param broadcaster The broadcaster the chat belongs to.
* @param message The message to send.
* @param params
*/
async sendChatMessageAsApp(user, broadcaster, message, params) {
const userId = (0, common_1.extractUserId)(user);
const broadcasterId = (0, common_1.extractUserId)(broadcaster);
const result = await this._client.callApi({
type: 'helix',
url: 'chat/messages',
method: 'POST',
forceType: 'app',
query: (0, chat_external_1.createSendChatMessageQuery)(broadcasterId, userId),
jsonBody: (0, chat_external_1.createSendChatMessageBody)(message, params),
});
return new HelixSentChatMessage_1.HelixSentChatMessage(result.data[0]);
}
/**
* Sends an announcement to a broadcaster's chat.

@@ -209,0 +266,0 @@ *

@@ -437,2 +437,30 @@ import { type UserIdResolvable } from '@twurple/common';

/**
* Subscribe to events that represent an ad break beginning in a channel.
*
* @param broadcaster The broadcaster for which you want to listen to ad break begin events.
* @param transport The transport options.
*/
subscribeToChannelAdBreakBeginEvents(broadcaster: UserIdResolvable, transport: HelixEventSubTransportOptions): Promise<HelixEventSubSubscription>;
/**
* Subscribe to events that represent a channel's chat being cleared.
*
* @param broadcaster The broadcaster for which you want to listen to chat clear events.
* @param transport The transport options.
*/
subscribeToChannelChatClearEvents(broadcaster: UserIdResolvable, transport: HelixEventSubTransportOptions): Promise<HelixEventSubSubscription>;
/**
* Subscribe to events that represent a user's chat messages being cleared in a channel.
*
* @param broadcaster The broadcaster for which you want to listen to user chat message clear events.
* @param transport The transport options.
*/
subscribeToChannelChatClearUserMessagesEvents(broadcaster: UserIdResolvable, transport: HelixEventSubTransportOptions): Promise<HelixEventSubSubscription>;
/**
* Subscribe to events that represent a chat message being deleted in a channel.
*
* @param broadcaster The broadcaster for which you want to listen to chat message delete events.
* @param transport The transport options.
*/
subscribeToChannelChatMessageDeleteEvents(broadcaster: UserIdResolvable, transport: HelixEventSubTransportOptions): Promise<HelixEventSubSubscription>;
/**
* Subscribe to events that represent an extension Bits transaction.

@@ -439,0 +467,0 @@ *

@@ -639,2 +639,38 @@ "use strict";

/**
* Subscribe to events that represent an ad break beginning in a channel.
*
* @param broadcaster The broadcaster for which you want to listen to ad break begin events.
* @param transport The transport options.
*/
async subscribeToChannelAdBreakBeginEvents(broadcaster, transport) {
return await this.createSubscription('channel.ad_break.begin', '1', (0, eventSub_external_1.createEventSubBroadcasterCondition)(broadcaster), transport, broadcaster, ['channel:read:ads']);
}
/**
* Subscribe to events that represent a channel's chat being cleared.
*
* @param broadcaster The broadcaster for which you want to listen to chat clear events.
* @param transport The transport options.
*/
async subscribeToChannelChatClearEvents(broadcaster, transport) {
return await this.createSubscription('channel.chat.clear', '1', (0, eventSub_external_1.createEventSubBroadcasterCondition)(broadcaster), transport, broadcaster, ['user:read:chat']);
}
/**
* Subscribe to events that represent a user's chat messages being cleared in a channel.
*
* @param broadcaster The broadcaster for which you want to listen to user chat message clear events.
* @param transport The transport options.
*/
async subscribeToChannelChatClearUserMessagesEvents(broadcaster, transport) {
return await this.createSubscription('channel.chat.clear_user_messages', '1', (0, eventSub_external_1.createEventSubBroadcasterCondition)(broadcaster), transport, broadcaster, ['user:read:chat']);
}
/**
* Subscribe to events that represent a chat message being deleted in a channel.
*
* @param broadcaster The broadcaster for which you want to listen to chat message delete events.
* @param transport The transport options.
*/
async subscribeToChannelChatMessageDeleteEvents(broadcaster, transport) {
return await this.createSubscription('channel.chat.message_delete', '1', (0, eventSub_external_1.createEventSubBroadcasterCondition)(broadcaster), transport, broadcaster, ['user:read:chat']);
}
/**
* Subscribe to events that represent an extension Bits transaction.

@@ -641,0 +677,0 @@ *

3

lib/index.d.ts

@@ -34,4 +34,5 @@ export { ApiClient } from './client/ApiClient';

export { HelixPrivilegedChatSettings } from './endpoints/chat/HelixPrivilegedChatSettings';
export { HelixSentChatMessage } from './endpoints/chat/HelixSentChatMessage';
export type { HelixChannelEmoteSubscriptionTier, HelixEmoteImageScale, HelixEmoteScale, HelixEmoteFormat, HelixEmoteThemeMode, HelixChatUserColor, HelixChatAnnouncementColor, } from './interfaces/endpoints/chat.external';
export type { HelixUpdateChatSettingsParams, HelixSendChatAnnouncementParams, HelixChatBadgeScale, } from './interfaces/endpoints/chat.input';
export type { HelixUpdateChatSettingsParams, HelixSendChatMessageParams, HelixSendChatAnnouncementParams, HelixChatBadgeScale, } from './interfaces/endpoints/chat.input';
export { HelixClipApi } from './endpoints/clip/HelixClipApi';

@@ -38,0 +39,0 @@ export { HelixClip } from './endpoints/clip/HelixClip';

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.HelixBanUser = exports.HelixModerator = exports.HelixBan = exports.HelixModerationApi = exports.HelixHypeTrainEvent = exports.HelixHypeTrainContribution = exports.HelixHypeTrainApi = exports.HelixGoal = exports.HelixGoalApi = exports.HelixGame = exports.HelixGameApi = exports.HelixExtensionTransaction = exports.HelixExtensionBitsProduct = exports.HelixExtensionsApi = exports.HelixPaginatedEventSubSubscriptionsRequest = exports.HelixEventSubSubscription = exports.HelixEventSubApi = exports.HelixDropsEntitlement = exports.HelixEntitlementApi = exports.HelixContentClassificationLabel = exports.HelixContentClassificationLabelApi = exports.HelixClip = exports.HelixClipApi = exports.HelixPrivilegedChatSettings = exports.HelixEmoteFromSet = exports.HelixChannelEmote = exports.HelixEmote = exports.HelixChatChatter = exports.HelixChatSettings = exports.HelixChatBadgeVersion = exports.HelixChatBadgeSet = exports.HelixChatApi = exports.HelixCharityCampaignAmount = exports.HelixCharityCampaignDonation = exports.HelixCharityCampaign = exports.HelixCharityApi = exports.HelixCustomRewardRedemption = exports.HelixCustomReward = exports.HelixChannelPointsApi = exports.HelixChannelReference = exports.HelixFollowedChannel = exports.HelixChannelFollower = exports.HelixChannelEditor = exports.HelixChannel = exports.HelixChannelApi = exports.HelixCheermoteList = exports.HelixBitsLeaderboardEntry = exports.HelixBitsLeaderboard = exports.HelixBitsApi = exports.ApiClient = void 0;
exports.HellFreezesOverError = exports.HelixExtension = exports.extractUserName = exports.extractUserId = exports.HelixPaginatedRequestWithTotal = exports.HelixPaginatedRequest = exports.ApiReportedRequest = exports.StreamNotLiveError = exports.ConfigError = exports.HelixWhisperApi = exports.HelixVideo = exports.HelixVideoApi = exports.HelixUserExtension = exports.HelixInstalledExtensionList = exports.HelixInstalledExtension = exports.HelixBaseExtension = exports.HelixUser = exports.HelixPrivilegedUser = exports.HelixFollow = exports.HelixUserBlock = exports.HelixUserApi = exports.HelixTeamWithUsers = exports.HelixTeam = exports.HelixTeamApi = exports.HelixUserSubscription = exports.HelixSubscription = exports.HelixSubscriptionApi = exports.HelixPaginatedSubscriptionsRequest = exports.HelixStreamMarkerWithVideo = exports.HelixStreamMarker = exports.HelixStream = exports.HelixStreamApi = exports.HelixChannelSearchResult = exports.HelixSearchApi = exports.HelixPaginatedScheduleSegmentRequest = exports.HelixScheduleSegment = exports.HelixSchedule = exports.HelixScheduleApi = exports.HelixUserRelation = exports.HelixRaid = exports.HelixRaidApi = exports.HelixPredictor = exports.HelixPredictionOutcome = exports.HelixPrediction = exports.HelixPredictionApi = exports.HelixPollChoice = exports.HelixPoll = exports.HelixPollApi = exports.HelixShieldModeStatus = exports.HelixBlockedTerm = void 0;
exports.HelixModerator = exports.HelixBan = exports.HelixModerationApi = exports.HelixHypeTrainEvent = exports.HelixHypeTrainContribution = exports.HelixHypeTrainApi = exports.HelixGoal = exports.HelixGoalApi = exports.HelixGame = exports.HelixGameApi = exports.HelixExtensionTransaction = exports.HelixExtensionBitsProduct = exports.HelixExtensionsApi = exports.HelixPaginatedEventSubSubscriptionsRequest = exports.HelixEventSubSubscription = exports.HelixEventSubApi = exports.HelixDropsEntitlement = exports.HelixEntitlementApi = exports.HelixContentClassificationLabel = exports.HelixContentClassificationLabelApi = exports.HelixClip = exports.HelixClipApi = exports.HelixSentChatMessage = exports.HelixPrivilegedChatSettings = exports.HelixEmoteFromSet = exports.HelixChannelEmote = exports.HelixEmote = exports.HelixChatChatter = exports.HelixChatSettings = exports.HelixChatBadgeVersion = exports.HelixChatBadgeSet = exports.HelixChatApi = exports.HelixCharityCampaignAmount = exports.HelixCharityCampaignDonation = exports.HelixCharityCampaign = exports.HelixCharityApi = exports.HelixCustomRewardRedemption = exports.HelixCustomReward = exports.HelixChannelPointsApi = exports.HelixChannelReference = exports.HelixFollowedChannel = exports.HelixChannelFollower = exports.HelixChannelEditor = exports.HelixChannel = exports.HelixChannelApi = exports.HelixCheermoteList = exports.HelixBitsLeaderboardEntry = exports.HelixBitsLeaderboard = exports.HelixBitsApi = exports.ApiClient = void 0;
exports.HelixExtension = exports.extractUserName = exports.extractUserId = exports.HelixPaginatedRequestWithTotal = exports.HelixPaginatedRequest = exports.ApiReportedRequest = exports.StreamNotLiveError = exports.ConfigError = exports.HelixWhisperApi = exports.HelixVideo = exports.HelixVideoApi = exports.HelixUserExtension = exports.HelixInstalledExtensionList = exports.HelixInstalledExtension = exports.HelixBaseExtension = exports.HelixUser = exports.HelixPrivilegedUser = exports.HelixFollow = exports.HelixUserBlock = exports.HelixUserApi = exports.HelixTeamWithUsers = exports.HelixTeam = exports.HelixTeamApi = exports.HelixUserSubscription = exports.HelixSubscription = exports.HelixSubscriptionApi = exports.HelixPaginatedSubscriptionsRequest = exports.HelixStreamMarkerWithVideo = exports.HelixStreamMarker = exports.HelixStream = exports.HelixStreamApi = exports.HelixChannelSearchResult = exports.HelixSearchApi = exports.HelixPaginatedScheduleSegmentRequest = exports.HelixScheduleSegment = exports.HelixSchedule = exports.HelixScheduleApi = exports.HelixUserRelation = exports.HelixRaid = exports.HelixRaidApi = exports.HelixPredictor = exports.HelixPredictionOutcome = exports.HelixPrediction = exports.HelixPredictionApi = exports.HelixPollChoice = exports.HelixPoll = exports.HelixPollApi = exports.HelixShieldModeStatus = exports.HelixBlockedTerm = exports.HelixBanUser = void 0;
exports.HellFreezesOverError = void 0;
var ApiClient_1 = require("./client/ApiClient");

@@ -59,2 +60,4 @@ Object.defineProperty(exports, "ApiClient", { enumerable: true, get: function () { return ApiClient_1.ApiClient; } });

Object.defineProperty(exports, "HelixPrivilegedChatSettings", { enumerable: true, get: function () { return HelixPrivilegedChatSettings_1.HelixPrivilegedChatSettings; } });
var HelixSentChatMessage_1 = require("./endpoints/chat/HelixSentChatMessage");
Object.defineProperty(exports, "HelixSentChatMessage", { enumerable: true, get: function () { return HelixSentChatMessage_1.HelixSentChatMessage; } });
var HelixClipApi_1 = require("./endpoints/clip/HelixClipApi");

@@ -61,0 +64,0 @@ Object.defineProperty(exports, "HelixClipApi", { enumerable: true, get: function () { return HelixClipApi_1.HelixClipApi; } });

@@ -43,2 +43,17 @@ /** @private */

}
/** @private */
export interface HelixAdScheduleData {
snooze_count: number;
snooze_refresh_at: number;
next_ad_at: number;
duration: number;
last_ad_at: number;
preroll_free_time: number;
}
/** @private */
export interface HelixSnoozeNextAdData {
snooze_count: number;
snooze_refresh_at: number;
next_ad_at: number;
}
//# sourceMappingURL=channel.external.d.ts.map

@@ -56,2 +56,11 @@ /**

}
/** @private */
export interface HelixSentChatMessageData {
message_id: string;
is_sent: boolean;
drop_reason?: {
code: string;
message: string;
};
}
/**

@@ -58,0 +67,0 @@ * The color used to highlight an announcement.

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.createShoutoutQuery = exports.createChatColorUpdateQuery = exports.createChatSettingsUpdateBody = void 0;
exports.createSendChatMessageBody = exports.createSendChatMessageQuery = exports.createShoutoutQuery = exports.createChatColorUpdateQuery = exports.createChatSettingsUpdateBody = void 0;
const common_1 = require("@twurple/common");

@@ -37,1 +37,17 @@ /** @internal */

exports.createShoutoutQuery = createShoutoutQuery;
/** @internal */
function createSendChatMessageQuery(broadcaster, sender) {
return {
broadcaster_id: broadcaster,
sender_id: sender,
};
}
exports.createSendChatMessageQuery = createSendChatMessageQuery;
/** @internal */
function createSendChatMessageBody(message, params) {
return {
message,
reply_parent_message_id: params === null || params === void 0 ? void 0 : params.replyParentMessageId,
};
}
exports.createSendChatMessageBody = createSendChatMessageBody;

@@ -44,2 +44,11 @@ import { type HelixChatAnnouncementColor } from './chat.external';

/**
* A request to send a message to a broadcaster's chat.
*/
export interface HelixSendChatMessageParams {
/**
* The ID of the chat message being replied to. If this is not set, message will not be sent as a reply.
*/
replyParentMessageId?: string;
}
/**
* A request to send an announcement to a broadcaster's chat.

@@ -46,0 +55,0 @@ */

@@ -123,3 +123,4 @@ "use strict";

_processResult(result) {
this._currentCursor = result.pagination ? result.pagination.cursor : undefined;
var _a;
this._currentCursor = typeof result.pagination === 'string' ? result.pagination : (_a = result.pagination) === null || _a === void 0 ? void 0 : _a.cursor;
if (this._currentCursor === undefined) {

@@ -126,0 +127,0 @@ this._isFinished = true;

@@ -12,3 +12,3 @@ "use strict";

},
cursor: (_a = response.pagination) === null || _a === void 0 ? void 0 : _a.cursor,
cursor: typeof response.pagination === 'string' ? response.pagination : (_a = response.pagination) === null || _a === void 0 ? void 0 : _a.cursor,
};

@@ -15,0 +15,0 @@ }

{
"name": "@twurple/api",
"version": "7.1.0-pre.1",
"version": "7.1.0-pre.2",
"publishConfig": {

@@ -43,4 +43,4 @@ "access": "public"

"@d-fischer/typed-event-emitter": "^3.3.1",
"@twurple/api-call": "7.1.0-pre.1",
"@twurple/common": "7.1.0-pre.1",
"@twurple/api-call": "7.1.0-pre.2",
"@twurple/common": "7.1.0-pre.2",
"retry": "^0.13.1",

@@ -50,7 +50,7 @@ "tslib": "^2.0.3"

"devDependencies": {
"@twurple/auth": "7.1.0-pre.1",
"@twurple/auth": "7.1.0-pre.2",
"@types/retry": "^0.12.2"
},
"peerDependencies": {
"@twurple/auth": "7.1.0-pre.1"
"@twurple/auth": "7.1.0-pre.2"
},

@@ -57,0 +57,0 @@ "files": [

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc