@haelp/teto
Version:
A typescript-based controllable TETR.IO client.
55 lines (54 loc) • 1.76 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "relationship", {
enumerable: true,
get: function() {
return relationship;
}
});
const relationship = (get, post, __)=>{
const removeRelationship = async (id)=>{
const res = await post({
uri: "relationships/remove",
body: {
user: id
}
});
if (res.success === false) throw new Error("Failed to remove relationship");
return true;
};
return {
/** Block a user */ block: async (id)=>{
const res = await post({
uri: "relationships/block",
body: {
user: id
}
});
if (res.success === false) throw new Error(res.error.msg);
return res.success;
},
/** Unblock a user. Note: unblocking a user will unfriend them if they are friended. */ unblock: removeRelationship,
/** Friend a user */ friend: async (id)=>{
const res = await post({
uri: "relationships/friend",
body: {
user: id
}
});
if (res.success === false) throw new Error(res.error.msg);
return res.success;
},
/** Unfriend a user. Note: unfriending a user will unblock them if they are blocked. */ unfriend: removeRelationship,
dms: async (id)=>{
const res = await get({
uri: `dms/${id}`
});
if (res.success === false) throw new Error(res.error.msg);
return res.dms;
}
};
};
//# sourceMappingURL=relationship.js.map