@haelp/teto
Version:
A typescript-based controllable TETR.IO client.
68 lines (67 loc) • 2.15 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "Relationship", {
enumerable: true,
get: function() {
return Relationship;
}
});
class Relationship {
social;
client;
/** ID of the account on the other side of the relationsihp */ id;
/** ID of the relationship */ relationshipID;
/** Username of the account on the other side of the relationship */ username;
/** Avatar ID of the account on the other side of the relationship */ avatar;
/** The DMs that have been sent and received. You may need to call `loadDms` to populate this information */ dms;
/** Promise that resolves when the dms have been loaded. This will not resovle if `Relationship.lazyLoadDms` is set to true. */ ready;
/** Whether or not the dms have been loaded */ dmsLoaded = false;
static lazyLoadDms = true;
constructor(options, social, client){
this.id = options.id;
this.relationshipID = options.relationshipID;
this.username = options.username;
this.avatar = options.avatar;
this.social = social;
this.client = client;
this.dms = [];
this.ready = Relationship.lazyLoadDms ? new Promise(()=>{}) : new Promise(async (resolve)=>{
await this.loadDms();
resolve();
});
}
/**
* Send a dm to the user.
* @example
* relationship.dm("Hello!");
*/ async dm(content) {
await this.social.dm(this.id, content);
}
/**
* Mark the dms as read
* @example
* relationship.markAsRead();
*/ markAsRead() {
this.client.emit("social.relation.ack", this.id);
}
/**
* Load the DMs for this relationship
* @example
* await relationship.loadDms();
*/ async loadDms() {
const dms = (await this.client.api.social.dms(this.id)).reverse();
this.dms = dms;
this.dmsLoaded = true;
return dms;
}
/**
* Invite the user to a game
* @example
* relationship.invite();
*/ invite() {
this.social.invite(this.id);
}
}
//# sourceMappingURL=relationship.js.map