Api methods

This commit is contained in:
Jiiks 2015-12-12 14:53:07 +02:00
parent 2d95d001b6
commit 8520f1512d
1 changed files with 23 additions and 0 deletions

View File

@ -1342,4 +1342,27 @@ BdApi.getIpc = function() {
//Get BetterDiscord Core
BdApi.getCore = function() {
return mainCore;
};
BdApi.getUserIdByName = function(name, callback) {
$(".member-username").each(function() {
if($(this).text() == name) {
var avatarUrl = $(this).closest(".member").find(".avatar-small").css("background-image");
var uid = avatarUrl.match(/\d+/);
callback(uid);
}
});
};
BdApi.getUserNameById = function(id, callback) {
$(".avatar-small").each(function() {
var url = $(this).css("background-image");
var uid = url.match(/\d+/);
if(uid == id) {
var uname = $(this).parent().find(".member-username").text();
callback(uname);
}
});
};