@twurple/easy-bot
Version:
A simplified framework to get a chat bot running easily.
53 lines (52 loc) • 1.48 kB
JavaScript
import { __decorate } from "tslib";
import { Enumerable } from '@d-fischer/shared-utils';
import { checkRelationAssertion, rtfm } from '@twurple/common';
import { SubEvent } from './SubEvent.js';
/**
* An event representing a user gifting a subscription to another user.
*
* @meta category events
*/
let SubGiftEvent = class SubGiftEvent extends SubEvent {
/** @internal */ _giftInfo;
/** @internal */
constructor(channel, userName, info, msg, bot) {
super(channel, userName, info, msg, bot);
this._giftInfo = info;
}
/**
* The ID of the user who sent the gift.
*/
get gifterId() {
return this._giftInfo.gifterUserId ?? null;
}
/**
* The name of the user who sent the gift.
*/
get gifterName() {
return this._giftInfo.gifter ?? null;
}
/**
* The display name of the user who sent the gift.
*/
get gifterDisplayName() {
return this._giftInfo.gifterDisplayName ?? null;
}
/**
* Gets more information about the user who sent the gift.
*/
async getGifter() {
const id = this.gifterId;
if (!id) {
return null;
}
return checkRelationAssertion(await this._bot.api.users.getUserById(id));
}
};
__decorate([
Enumerable(false)
], SubGiftEvent.prototype, "_giftInfo", void 0);
SubGiftEvent = __decorate([
rtfm('easy-bot', 'SubGiftEvent', 'userId')
], SubGiftEvent);
export { SubGiftEvent };