@twurple/easy-bot
Version:
A simplified framework to get a chat bot running easily.
58 lines (57 loc) • 1.81 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.SubGiftEvent = void 0;
const tslib_1 = require("tslib");
const shared_utils_1 = require("@d-fischer/shared-utils");
const common_1 = require("@twurple/common");
const SubEvent_1 = require("./SubEvent");
/**
* An event representing a user gifting a subscription to another user.
*
* @meta category events
*/
let SubGiftEvent = class SubGiftEvent extends SubEvent_1.SubEvent {
/** @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() {
var _a;
return (_a = this._giftInfo.gifterUserId) !== null && _a !== void 0 ? _a : null;
}
/**
* The name of the user who sent the gift.
*/
get gifterName() {
var _a;
return (_a = this._giftInfo.gifter) !== null && _a !== void 0 ? _a : null;
}
/**
* The display name of the user who sent the gift.
*/
get gifterDisplayName() {
var _a;
return (_a = this._giftInfo.gifterDisplayName) !== null && _a !== void 0 ? _a : null;
}
/**
* Gets more information about the user who sent the gift.
*/
async getGifter() {
const id = this.gifterId;
if (!id) {
return null;
}
return (0, common_1.checkRelationAssertion)(await this._bot.api.users.getUserById(id));
}
};
exports.SubGiftEvent = SubGiftEvent;
tslib_1.__decorate([
(0, shared_utils_1.Enumerable)(false)
], SubGiftEvent.prototype, "_giftInfo", void 0);
exports.SubGiftEvent = SubGiftEvent = tslib_1.__decorate([
(0, common_1.rtfm)('easy-bot', 'SubGiftEvent', 'userId')
], SubGiftEvent);