Api methods
This commit is contained in:
parent
2d95d001b6
commit
8520f1512d
23
js/main.js
23
js/main.js
|
@ -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);
|
||||
}
|
||||
});
|
||||
};
|
Loading…
Reference in New Issue