Update 0BDFDB.plugin.js
This commit is contained in:
parent
3f3655261a
commit
a0977ff96c
|
@ -1506,7 +1506,7 @@ module.exports = (_ => {
|
|||
if (BDFDB.ObjectUtils.is(config.guild)) {
|
||||
let streamOwnerIds = LibraryModules.StreamUtils.getAllApplicationStreams().filter(app => app.guildId === config.guild.id).map(app => app.ownerId) || [];
|
||||
let streamOwners = streamOwnerIds.map(ownerId => LibraryModules.UserStore.getUser(ownerId)).filter(n => n);
|
||||
let connectedUsers = Object.keys(LibraryModules.VoiceUtils.getVoiceStates(config.guild.id)).map(userId => !streamOwnerIds.includes(userId) && BDFDB.LibraryModules.UserStore.getUser(userId)).filter(n => n);
|
||||
let connectedUsers = Object.keys(LibraryModules.VoiceUtils.getVoiceStates(config.guild.id)).map(userId => !streamOwnerIds.includes(userId) && LibraryModules.UserStore.getUser(userId)).filter(n => n);
|
||||
let tooltipText = config.guild.toString();
|
||||
if (fontColorIsGradient) tooltipText = `<span style="pointer-events: none; -webkit-background-clip: text !important; color: transparent !important; background-image: ${BDFDB.ColorUtils.createGradient(config.fontColor)} !important;">${BDFDB.StringUtils.htmlEscape(tooltipText)}</span>`;
|
||||
BDFDB.ReactUtils.render(BDFDB.ReactUtils.createElement(BDFDB.ReactUtils.Fragment, {
|
||||
|
@ -2650,7 +2650,7 @@ module.exports = (_ => {
|
|||
BDFDB.MessageUtils.rerenderAll = function (instant) {
|
||||
BDFDB.TimeUtils.clear(BDFDB.MessageUtils.rerenderAll.timeout);
|
||||
BDFDB.MessageUtils.rerenderAll.timeout = BDFDB.TimeUtils.timeout(_ => {
|
||||
let channel = BDFDB.LibraryModules.ChannelStore.getChannel(BDFDB.LibraryModules.LastChannelStore.getChannelId());
|
||||
let channel = LibraryModules.ChannelStore.getChannel(LibraryModules.LastChannelStore.getChannelId());
|
||||
if (channel) {
|
||||
if (BDFDB.DMUtils.isDMChannel(channel)) BDFDB.DMUtils.markAsRead(channel);
|
||||
else BDFDB.ChannelUtils.markAsRead(channel);
|
||||
|
@ -2713,7 +2713,7 @@ module.exports = (_ => {
|
|||
return null;
|
||||
};
|
||||
BDFDB.UserUtils.getAvatar = function (id = BDFDB.UserUtils.me.id) {
|
||||
let user = LibraryModules.UserStore.getUser(typeof id == "number" ? id.toFixed() : id);
|
||||
let user = LibraryModules.UserStore.getUser(id);
|
||||
if (!user) return window.location.origin + "/assets/322c936a8c8be1b803cd94861bdfa868.png";
|
||||
else return ((user.avatar ? "" : window.location.origin) + LibraryModules.IconUtils.getUserAvatarURL(user)).split("?")[0];
|
||||
};
|
||||
|
@ -2725,10 +2725,8 @@ module.exports = (_ => {
|
|||
}
|
||||
return false;
|
||||
};
|
||||
BDFDB.UserUtils.openMenu = function (id, guildId, e = mousePosition) {
|
||||
if (!id || !guildId) return;
|
||||
let user = LibraryModules.UserStore.getUser(id);
|
||||
if (user) LibraryModules.ContextMenuUtils.openContextMenu(e, function (e) {
|
||||
BDFDB.UserUtils.openMenu = function (user, guildId, e = mousePosition) {
|
||||
if (user && guildId) LibraryModules.ContextMenuUtils.openContextMenu(e, function (e) {
|
||||
return BDFDB.ReactUtils.createElement((BDFDB.ModuleUtils.findByName("GuildChannelUserContextMenu", false) || {exports: {}}).exports.default, Object.assign({}, e, {
|
||||
user: user,
|
||||
guildId: guildId
|
||||
|
@ -2743,106 +2741,28 @@ module.exports = (_ => {
|
|||
return guild instanceof BDFDB.DiscordObjects.Guild || Object.keys(new BDFDB.DiscordObjects.Guild({})).every(key => keys.indexOf(key) > -1);
|
||||
};
|
||||
BDFDB.GuildUtils.getIcon = function (id) {
|
||||
let guild = LibraryModules.GuildStore.getGuild(typeof id == "number" ? id.toFixed() : id);
|
||||
if (!guild || !guild.icon) return null;
|
||||
let guild = LibraryModules.GuildStore.getGuild(id);
|
||||
if (!guild || !guild.icon) return "";
|
||||
return LibraryModules.IconUtils.getGuildIconURL(guild).split("?")[0];
|
||||
};
|
||||
BDFDB.GuildUtils.getBanner = function (id) {
|
||||
let guild = LibraryModules.GuildStore.getGuild(typeof id == "number" ? id.toFixed() : id);
|
||||
if (!guild || !guild.banner) return null;
|
||||
let guild = LibraryModules.GuildStore.getGuild(id);
|
||||
if (!guild || !guild.banner) return "";
|
||||
return LibraryModules.IconUtils.getGuildBannerURL(guild).split("?")[0];
|
||||
};
|
||||
BDFDB.GuildUtils.getFolder = function (id) {
|
||||
return BDFDB.LibraryModules.FolderStore.guildFolders.filter(n => n.folderId).find(n => n.guildIds.includes(id));
|
||||
return LibraryModules.FolderStore.guildFolders.filter(n => n.folderId).find(n => n.guildIds.includes(id));
|
||||
};
|
||||
BDFDB.GuildUtils.getId = function (div) {
|
||||
if (!Node.prototype.isPrototypeOf(div) || !BDFDB.ReactUtils.getInstance(div)) return;
|
||||
let guilddiv = BDFDB.DOMUtils.getParent(BDFDB.dotCN.guildouter, div);
|
||||
if (!guilddiv) return;
|
||||
let iconWrap = guilddiv.querySelector(BDFDB.dotCN.guildiconwrapper);
|
||||
let id = iconWrap && iconWrap.href ? iconWrap.href.split("/").slice(-2)[0] : null;
|
||||
return id && !isNaN(parseInt(id)) ? id.toString() : null;
|
||||
};
|
||||
BDFDB.GuildUtils.getData = function (eleOrInfoOrId) {
|
||||
if (!eleOrInfoOrId) return null;
|
||||
let id = Node.prototype.isPrototypeOf(eleOrInfoOrId) ? BDFDB.GuildUtils.getId(eleOrInfoOrId) : (typeof eleOrInfoOrId == "object" ? eleOrInfoOrId.id : eleOrInfoOrId);
|
||||
id = typeof id == "number" ? id.toFixed() : id;
|
||||
for (let info of BDFDB.GuildUtils.getAll()) if (info && info.id == id) return info;
|
||||
return null;
|
||||
};
|
||||
BDFDB.GuildUtils.getAll = function () {
|
||||
let found = [], objs = [];
|
||||
for (let ins of BDFDB.ReactUtils.findOwner(document.querySelector(BDFDB.dotCN.guilds), {name: ["Guild","GuildIcon"], all: true, unlimited: true})) {
|
||||
if (ins.props && ins.props.guild) objs.push(Object.assign(new ins.props.guild.constructor(ins.props.guild), {div: ins.handleContextMenu && BDFDB.ReactUtils.findDOMNode(ins), instance: ins}));
|
||||
}
|
||||
for (let id of BDFDB.LibraryModules.FolderStore.getFlattenedGuildIds()) {
|
||||
let foundobj = null;
|
||||
for (let obj of objs) if (obj.id == id) {
|
||||
foundobj = obj
|
||||
break;
|
||||
}
|
||||
if (foundobj) found.push(foundobj);
|
||||
else {
|
||||
let guild = BDFDB.LibraryModules.GuildStore.getGuild(id);
|
||||
if (guild) found.push(Object.assign(new guild.constructor(guild), {div: null, instance: null}))
|
||||
}
|
||||
}
|
||||
return found;
|
||||
};
|
||||
BDFDB.GuildUtils.getUnread = function (servers) {
|
||||
let found = [];
|
||||
for (let eleOrInfoOrId of servers === undefined || !BDFDB.ArrayUtils.is(servers) ? BDFDB.GuildUtils.getAll() : servers) {
|
||||
if (!eleOrInfoOrId) return null;
|
||||
let id = Node.prototype.isPrototypeOf(eleOrInfoOrId) ? BDFDB.GuildUtils.getId(eleOrInfoOrId) : (typeof eleOrInfoOrId == "object" ? eleOrInfoOrId.id : eleOrInfoOrId);
|
||||
id = typeof id == "number" ? id.toFixed() : id;
|
||||
if (id && (LibraryModules.UnreadGuildUtils.hasUnread(id) || LibraryModules.UnreadGuildUtils.getMentionCount(id) > 0)) found.push(eleOrInfoOrId);
|
||||
}
|
||||
return found;
|
||||
};
|
||||
BDFDB.GuildUtils.getPinged = function (servers) {
|
||||
let found = [];
|
||||
for (let eleOrInfoOrId of servers === undefined || !BDFDB.ArrayUtils.is(servers) ? BDFDB.GuildUtils.getAll() : servers) {
|
||||
if (!eleOrInfoOrId) return null;
|
||||
let id = Node.prototype.isPrototypeOf(eleOrInfoOrId) ? BDFDB.GuildUtils.getId(eleOrInfoOrId) : (typeof eleOrInfoOrId == "object" ? eleOrInfoOrId.id : eleOrInfoOrId);
|
||||
id = typeof id == "number" ? id.toFixed() : id;
|
||||
if (id && LibraryModules.UnreadGuildUtils.getMentionCount(id) > 0) found.push(eleOrInfoOrId);
|
||||
}
|
||||
return found;
|
||||
};
|
||||
BDFDB.GuildUtils.getMuted = function (servers) {
|
||||
let found = [];
|
||||
for (let eleOrInfoOrId of servers === undefined || !BDFDB.ArrayUtils.is(servers) ? BDFDB.GuildUtils.getAll() : servers) {
|
||||
if (!eleOrInfoOrId) return null;
|
||||
let id = Node.prototype.isPrototypeOf(eleOrInfoOrId) ? BDFDB.GuildUtils.getId(eleOrInfoOrId) : (typeof eleOrInfoOrId == "object" ? eleOrInfoOrId.id : eleOrInfoOrId);
|
||||
id = typeof id == "number" ? id.toFixed() : id;
|
||||
if (id && LibraryModules.MutedUtils.isGuildOrCategoryOrChannelMuted(id)) found.push(eleOrInfoOrId);
|
||||
}
|
||||
return found;
|
||||
};
|
||||
BDFDB.GuildUtils.getSelected = function () {
|
||||
let info = LibraryModules.GuildStore.getGuild(LibraryModules.LastGuildStore.getGuildId());
|
||||
if (info) return BDFDB.GuildUtils.getData(info.id) || Object.assign(new info.constructor(info), {div: null, instance: null});
|
||||
else return null;
|
||||
};
|
||||
BDFDB.GuildUtils.openMenu = function (eleOrInfoOrId, e = mousePosition) {
|
||||
if (!eleOrInfoOrId) return;
|
||||
let id = Node.prototype.isPrototypeOf(eleOrInfoOrId) ? BDFDB.GuildUtils.getId(eleOrInfoOrId) : (typeof eleOrInfoOrId == "object" ? eleOrInfoOrId.id : eleOrInfoOrId);
|
||||
let guild = LibraryModules.GuildStore.getGuild(id);
|
||||
BDFDB.GuildUtils.openMenu = function (guild, e = mousePosition) {
|
||||
if (guild) LibraryModules.ContextMenuUtils.openContextMenu(e, function (e) {
|
||||
return BDFDB.ReactUtils.createElement((BDFDB.ModuleUtils.findByName("GuildContextMenu", false) || {exports: {}}).exports.default, Object.assign({}, e, {
|
||||
guild: guild
|
||||
}));
|
||||
});
|
||||
};
|
||||
BDFDB.GuildUtils.markAsRead = function (guilds) {
|
||||
if (!guilds) return;
|
||||
let unreadChannels = [];
|
||||
for (let guild of [guilds].map(n => NodeList.prototype.isPrototypeOf(n) ? Array.from(n) : n).flat(10).filter(n => n)) {
|
||||
let id = Node.prototype.isPrototypeOf(guild) ? BDFDB.GuildUtils.getId(guild) : (guild && typeof guild == "object" ? guild.id : guild);
|
||||
let channels = id && LibraryModules.GuildChannelStore.getChannels(id);
|
||||
if (channels) for (let type in channels) if (BDFDB.ArrayUtils.is(channels[type])) for (let channelObj of channels[type]) unreadChannels.push(channelObj.channel.id);
|
||||
}
|
||||
if (unreadChannels.length) BDFDB.ChannelUtils.markAsRead(unreadChannels);
|
||||
BDFDB.GuildUtils.markAsRead = function (guildIds) {
|
||||
let channels = [guildIds].flat(10).filter(id => id && typeof id == "string" && LibraryModules.GuildStore.getGuild(id)).map(id => BDFDB.ObjectUtils.toArray(LibraryModules.GuildChannelStore.getChannels(id)).flat(10).filter(n => BDFDB.ObjectUtils.is(n)).map(n => n.channel)).flat().filter(n => n);
|
||||
if (channels.length) BDFDB.ChannelUtils.markAsRead(channels);
|
||||
};
|
||||
BDFDB.GuildUtils.rerenderAll = function (instant) {
|
||||
BDFDB.TimeUtils.clear(BDFDB.GuildUtils.rerenderAll.timeout);
|
||||
|
@ -2879,35 +2799,16 @@ module.exports = (_ => {
|
|||
return BDFDB.ReactUtils.findValue(div, "folderId", {up: true});
|
||||
};
|
||||
BDFDB.FolderUtils.getDefaultName = function (folderId) {
|
||||
let folder = BDFDB.LibraryModules.FolderStore.getGuildFolderById(folderId);
|
||||
let folder = LibraryModules.FolderStore.getGuildFolderById(folderId);
|
||||
if (!folder) return "";
|
||||
let rest = 2 * BDFDB.DiscordConstants.MAX_GUILD_FOLDER_NAME_LENGTH;
|
||||
let names = [], allNames = folder.guildIds.map(guildId => (BDFDB.LibraryModules.GuildStore.getGuild(guildId) || {}).name).filter(n => n);
|
||||
let names = [], allNames = folder.guildIds.map(guildId => (LibraryModules.GuildStore.getGuild(guildId) || {}).name).filter(n => n);
|
||||
for (let name of allNames) if (name.length < rest || names.length === 0) {
|
||||
names.push(name);
|
||||
rest -= name.length;
|
||||
}
|
||||
return names.join(", ") + (names.length < allNames.length ? ", ..." : "");
|
||||
};
|
||||
BDFDB.FolderUtils.getDiv = function (eleOrInfoOrId) {
|
||||
if (!eleOrInfoOrId) return null;
|
||||
let info = BDFDB.FolderUtils.getData(eleOrInfoOrId);
|
||||
return info ? info.div : null;
|
||||
};
|
||||
BDFDB.FolderUtils.getData = function (eleOrInfoOrId) {
|
||||
if (!eleOrInfoOrId) return null;
|
||||
let id = Node.prototype.isPrototypeOf(eleOrInfoOrId) ? BDFDB.FolderUtils.getId(eleOrInfoOrId) : (typeof eleOrInfoOrId == "object" ? eleOrInfoOrId.id : eleOrInfoOrId);
|
||||
id = typeof id == "number" ? id.toFixed() : id;
|
||||
for (let info of BDFDB.FolderUtils.getAll()) if (info && info.folderId == id) return info;
|
||||
return null;
|
||||
};
|
||||
BDFDB.FolderUtils.getAll = function () {
|
||||
let found = [];
|
||||
for (let ins of BDFDB.ReactUtils.findOwner(document.querySelector(BDFDB.dotCN.guildswrapper), {name: "GuildFolder", all: true, unlimited: true})) {
|
||||
if (ins.props && ins.props.folderId) found.push(Object.assign({}, ins.props, {div: BDFDB.ReactUtils.findDOMNode(ins), instance: ins}));
|
||||
}
|
||||
return found;
|
||||
};
|
||||
|
||||
BDFDB.ChannelUtils = {};
|
||||
BDFDB.ChannelUtils.is = function (channel) {
|
||||
|
@ -2919,8 +2820,8 @@ module.exports = (_ => {
|
|||
let channel = typeof channelOrId == "string" ? LibraryModules.ChannelStore.getChannel(channelOrId) : channelOrId;
|
||||
return BDFDB.ObjectUtils.is(channel) && (channel.type == BDFDB.DiscordConstants.ChannelTypes.GUILD_TEXT || channel.type == BDFDB.DiscordConstants.ChannelTypes.GUILD_STORE || channel.type == BDFDB.DiscordConstants.ChannelTypes.GUILD_ANNOUNCEMENT);
|
||||
};
|
||||
BDFDB.ChannelUtils.markAsRead = function (channels) {
|
||||
let unreadChannels = [channels].flat(10).filter(n => n && typeof n == "string" && BDFDB.ChannelUtils.isTextChannel(id)).map(id => ({
|
||||
BDFDB.ChannelUtils.markAsRead = function (channelIds) {
|
||||
let unreadChannels = [channelIds].flat(10).filter(id => id && typeof id == "string" && BDFDB.ChannelUtils.isTextChannel(id) && (LibraryModules.UnreadChannelUtils.hasUnread(id) || LibraryModules.UnreadChannelUtils.getMentionCount(id) > 0)).map(id => ({
|
||||
channelId: id,
|
||||
messageId: LibraryModules.UnreadChannelUtils.lastMessageId(id)
|
||||
}));
|
||||
|
@ -2942,59 +2843,19 @@ module.exports = (_ => {
|
|||
};
|
||||
|
||||
BDFDB.DMUtils = {};
|
||||
BDFDB.DMUtils.isDMChannel = function (channelOrId) {
|
||||
let channel = typeof channelOrId == "string" ? LibraryModules.ChannelStore.getChannel(channelOrId) : channelOrId;
|
||||
return BDFDB.ObjectUtils.is(channel) && (channel.type == BDFDB.DiscordConstants.ChannelTypes.DM || channel.type == BDFDB.DiscordConstants.ChannelTypes.GROUP_DM);
|
||||
BDFDB.DMUtils.isDMChannel = function (id) {
|
||||
let channel = LibraryModules.ChannelStore.getChannel(id);
|
||||
return BDFDB.ObjectUtils.is(channel) && (channel.isDM() || channel.isGroupDM());
|
||||
};
|
||||
BDFDB.DMUtils.getIcon = function (id) {
|
||||
let channel = LibraryModules.ChannelStore.getChannel(id = typeof id == "number" ? id.toFixed() : id);
|
||||
if (!channel) return null;
|
||||
if (!channel.icon) return channel.type == 1 ? BDFDB.UserUtils.getAvatar(channel.recipients[0]) : (channel.type == 3 ? window.location.origin + LibraryModules.IconUtils.getChannelIconURL(channel).split("?")[0] : null);
|
||||
let channel = LibraryModules.ChannelStore.getChannel(id);
|
||||
if (!channel) return "";
|
||||
if (!channel.icon) return channel.isDM() ? BDFDB.UserUtils.getAvatar(channel.recipients[0]) : (channel.isGroupDM() ? window.location.origin + LibraryModules.IconUtils.getChannelIconURL(channel).split("?")[0] : null);
|
||||
return LibraryModules.IconUtils.getChannelIconURL(channel).split("?")[0];
|
||||
};
|
||||
BDFDB.DMUtils.getId = function (div) {
|
||||
if (!Node.prototype.isPrototypeOf(div) || !BDFDB.ReactUtils.getInstance(div)) return;
|
||||
let dmdiv = BDFDB.DOMUtils.getParent(BDFDB.dotCN.guildouter, div);
|
||||
if (!dmdiv) return;
|
||||
let iconWrap = dmdiv.querySelector(BDFDB.dotCN.guildiconwrapper);
|
||||
let id = iconWrap && iconWrap.href ? iconWrap.href.split("/").slice(-1)[0] : null;
|
||||
return id && !isNaN(parseInt(id)) ? id.toString() : null;
|
||||
};
|
||||
BDFDB.DMUtils.getDiv = function (eleOrInfoOrId) {
|
||||
if (!eleOrInfoOrId) return null;
|
||||
if (Node.prototype.isPrototypeOf(eleOrInfoOrId)) {
|
||||
var div = BDFDB.DOMUtils.getParent(BDFDB.dotCN.guildouter, eleOrInfoOrId);
|
||||
return div ? div.parentElement : div;
|
||||
}
|
||||
else {
|
||||
let id = typeof eleOrInfoOrId == "object" ? eleOrInfoOrId.id : eleOrInfoOrId;
|
||||
if (id) {
|
||||
var div = BDFDB.DOMUtils.getParent(BDFDB.dotCN.guildouter, document.querySelector(`${BDFDB.dotCNS.guilds + BDFDB.dotCN.dmpill + " + * " + BDFDB.dotCN.guildiconwrapper}[href*="/channels/@me/${id}"]`));
|
||||
return div && BDFDB? div.parentElement : div;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
};
|
||||
BDFDB.DMUtils.getData = function (eleOrInfoOrId) {
|
||||
if (!eleOrInfoOrId) return null;
|
||||
let id = Node.prototype.isPrototypeOf(eleOrInfoOrId) ? BDFDB.BDFDB.DMUtils.getId(eleOrInfoOrId) : (typeof eleOrInfoOrId == "object" ? eleOrInfoOrId.id : eleOrInfoOrId);
|
||||
id = typeof id == "number" ? id.toFixed() : id;
|
||||
for (let info of BDFDB.DMUtils.getAll()) if (info && info.id == id) return info;
|
||||
return null;
|
||||
};
|
||||
BDFDB.DMUtils.getAll = function () {
|
||||
let found = [];
|
||||
for (let ins of BDFDB.ReactUtils.findOwner(document.querySelector(BDFDB.dotCN.guilds), {name: "DirectMessage", all: true, unlimited: true})) {
|
||||
if (ins.props && ins.props.channel) found.push(Object.assign(new ins.props.channel.constructor(ins.props.channel), {div: BDFDB.ReactUtils.findDOMNode(ins), instance: ins}));
|
||||
}
|
||||
return found;
|
||||
};
|
||||
BDFDB.DMUtils.openMenu = function (eleOrInfoOrId, e = mousePosition) {
|
||||
if (!eleOrInfoOrId) return;
|
||||
let id = Node.prototype.isPrototypeOf(eleOrInfoOrId) ? BDFDB.ChannelUtils.getId(eleOrInfoOrId) : (typeof eleOrInfoOrId == "object" ? eleOrInfoOrId.id : eleOrInfoOrId);
|
||||
let channel = LibraryModules.ChannelStore.getChannel(id);
|
||||
BDFDB.DMUtils.openMenu = function (channel, e = mousePosition) {
|
||||
if (channel) {
|
||||
if (channel.isMultiUserDM()) LibraryModules.ContextMenuUtils.openContextMenu(e, function (e) {
|
||||
if (channel.isGroupDM()) LibraryModules.ContextMenuUtils.openContextMenu(e, function (e) {
|
||||
return BDFDB.ReactUtils.createElement((BDFDB.ModuleUtils.findByName("GroupDMContextMenu", false) || {exports: {}}).exports.default, Object.assign({}, e, {
|
||||
channel: channel,
|
||||
selected: channel.id == LibraryModules.LastChannelStore.getChannelId()
|
||||
|
@ -3009,14 +2870,9 @@ module.exports = (_ => {
|
|||
});
|
||||
}
|
||||
};
|
||||
BDFDB.DMUtils.markAsRead = function (dms) {
|
||||
if (!dms) return;
|
||||
let unreadChannels = [];
|
||||
for (let dm of [dms].map(n => NodeList.prototype.isPrototypeOf(n) ? Array.from(n) : n).flat(10).filter(n => n)) {
|
||||
let id = Node.prototype.isPrototypeOf(dm) ? BDFDB.BDFDB.DMUtils.getId(dm) : (dm && typeof dm == "object" ? dm.id : dm);
|
||||
if (id) unreadChannels.push(id);
|
||||
}
|
||||
for (let i in unreadChannels) BDFDB.TimeUtils.timeout(_ => {LibraryModules.AckUtils.ack(unreadChannels[i]);}, i * 1000);
|
||||
BDFDB.DMUtils.markAsRead = function (dmIds) {
|
||||
let unreadDMs = [dmIds].flat(10).filter(id => id && typeof id == "string" && BDFDB.DMUtils.isDMChannel(id) && (LibraryModules.UnreadChannelUtils.hasUnread(id) || LibraryModules.UnreadChannelUtils.getMentionCount(id) > 0));
|
||||
if (unreadDMs.length) for (let i in unreadDMs) BDFDB.TimeUtils.timeout(_ => LibraryModules.AckUtils.ack(unreadDMs[i]), i * 1000);
|
||||
};
|
||||
|
||||
InternalBDFDB.writeConfig = function (path, config) {
|
||||
|
@ -3820,7 +3676,7 @@ module.exports = (_ => {
|
|||
LibraryModules.ContextMenuUtils.openContextMenu(e, function (e) {
|
||||
return BDFDB.ReactUtils.createElement(InternalComponents.LibraryComponents.Menu, {
|
||||
navId: "bdfdb-context",
|
||||
onClose: BDFDB.LibraryModules.ContextMenuUtils.closeContextMenu,
|
||||
onClose: LibraryModules.ContextMenuUtils.closeContextMenu,
|
||||
children: children
|
||||
}, true);
|
||||
});
|
||||
|
@ -3829,7 +3685,7 @@ module.exports = (_ => {
|
|||
if (!BDFDB.ObjectUtils.is(nodeOrInstance)) return;
|
||||
let instance = BDFDB.ReactUtils.findOwner(nodeOrInstance, {props: "closeContextMenu", up: true});
|
||||
if (BDFDB.ObjectUtils.is(instance) && instance.props && typeof instance.props.closeContextMenu == "function") instance.props.closeContextMenu();
|
||||
else BDFDB.LibraryModules.ContextMenuUtils.closeContextMenu();
|
||||
else LibraryModules.ContextMenuUtils.closeContextMenu();
|
||||
};
|
||||
BDFDB.ContextMenuUtils.createItem = function (component, props = {}) {
|
||||
if (!component) return null;
|
||||
|
@ -5880,7 +5736,7 @@ module.exports = (_ => {
|
|||
|
||||
InternalComponents.LibraryComponents.KeybindRecorder = reactInitialized && class BDFDB_KeybindRecorder extends LibraryModules.React.Component {
|
||||
handleChange(arrays) {
|
||||
if (typeof this.props.onChange == "function") this.props.onChange(arrays.map(platformkey => LibraryModules.KeyEvents.codes[BDFDB.LibraryModules.KeyCodeUtils.codeToKey(platformkey)] || platformkey[1]), this);
|
||||
if (typeof this.props.onChange == "function") this.props.onChange(arrays.map(platformkey => LibraryModules.KeyEvents.codes[LibraryModules.KeyCodeUtils.codeToKey(platformkey)] || platformkey[1]), this);
|
||||
}
|
||||
handleReset() {
|
||||
this.props.defaultValue = [];
|
||||
|
@ -6333,7 +6189,7 @@ module.exports = (_ => {
|
|||
LibraryModules.ContextMenuUtils.openContextMenu(event, _ => {
|
||||
return BDFDB.ReactUtils.createElement(InternalComponents.LibraryComponents.Menu, {
|
||||
navId: "bdfdb-quickselect",
|
||||
onClose: BDFDB.LibraryModules.ContextMenuUtils.closeContextMenu,
|
||||
onClose: LibraryModules.ContextMenuUtils.closeContextMenu,
|
||||
className: this.props.popoutClassName,
|
||||
children: BDFDB.ContextMenuUtils.createItem(InternalComponents.LibraryComponents.MenuItems.MenuGroup, {
|
||||
children: options.map((option, i) => {
|
||||
|
@ -6429,7 +6285,7 @@ module.exports = (_ => {
|
|||
return BDFDB.ReactUtils.createElement(InternalComponents.LibraryComponents.Flex, {
|
||||
className: this.props.className,
|
||||
wrap: InternalComponents.LibraryComponents.Flex.Wrap.WRAP,
|
||||
children: [this.props.includeDMs && {name: BDFDB.LanguageUtils.LanguageStrings.DIRECT_MESSAGES, acronym: "DMs", id: BDFDB.DiscordConstants.ME, getIconURL: _ => {}}].concat(BDFDB.LibraryModules.FolderStore.getFlattenedGuilds()).filter(n => n).map(guild => BDFDB.ReactUtils.createElement(InternalComponents.LibraryComponents.TooltipContainer, {
|
||||
children: [this.props.includeDMs && {name: BDFDB.LanguageUtils.LanguageStrings.DIRECT_MESSAGES, acronym: "DMs", id: BDFDB.DiscordConstants.ME, getIconURL: _ => {}}].concat(LibraryModules.FolderStore.getFlattenedGuilds()).filter(n => n).map(guild => BDFDB.ReactUtils.createElement(InternalComponents.LibraryComponents.TooltipContainer, {
|
||||
text: guild.name,
|
||||
children: BDFDB.ReactUtils.createElement("div", {
|
||||
className: BDFDB.DOMUtils.formatClassName(this.props.guildClassName, BDFDB.disCN.settingsguild, this.props.disabled.includes(guild.id) && BDFDB.disCN.settingsguilddisabled),
|
||||
|
@ -7961,7 +7817,7 @@ module.exports = (_ => {
|
|||
if (!lang) {
|
||||
let formatTranslation = (l, s, i) => {
|
||||
l = l == "en" ? "default" : l;
|
||||
return config.cached && config.cached[l] && config.cached[l][stringKeys[i]] || (translations[language][i][0] == translations[language][i][0].toUpperCase() ? BDFDB.LibraryModules.StringUtils.upperCaseFirstChar(s) : s);
|
||||
return config.cached && config.cached[l] && config.cached[l][stringKeys[i]] || (translations[language][i][0] == translations[language][i][0].toUpperCase() ? LibraryModules.StringUtils.upperCaseFirstChar(s) : s);
|
||||
};
|
||||
let format = config.asObject ? ((l, isNotFirst) => {
|
||||
return `${isNotFirst ? "," : ""}\n\t\t"${l == "en" ? "default" : l}": {${translations[l].map((s, i) => `\n\t\t\t"${stringKeys[i]}": "${formatTranslation(l, s, i)}"`).join(",")}\n\t\t}`;
|
||||
|
@ -8051,7 +7907,7 @@ module.exports = (_ => {
|
|||
getSettingsPanel (collapseStates = {}) {
|
||||
let settingsPanel;
|
||||
let getString = (type, key, property) => {
|
||||
return BDFDB.LanguageUtils.LibraryStringsCheck[`settings_${key}_${property}`] ? BDFDB.LanguageUtils.LibraryStringsFormat(`settings_${key}_${property}`, BDFDB.BDUtils.getSettingsProperty("name", BDFDB.BDUtils.settingsIds[key]) || BDFDB.LibraryModules.StringUtils.upperCaseFirstChar(key.replace(/([A-Z])/g, " $1"))) : InternalBDFDB.defaults[type][key][property];
|
||||
return BDFDB.LanguageUtils.LibraryStringsCheck[`settings_${key}_${property}`] ? BDFDB.LanguageUtils.LibraryStringsFormat(`settings_${key}_${property}`, BDFDB.BDUtils.getSettingsProperty("name", BDFDB.BDUtils.settingsIds[key]) || LibraryModules.StringUtils.upperCaseFirstChar(key.replace(/([A-Z])/g, " $1"))) : InternalBDFDB.defaults[type][key][property];
|
||||
};
|
||||
return settingsPanel = BDFDB.PluginUtils.createSettingsPanel(BDFDB, {
|
||||
collapseStates: collapseStates,
|
||||
|
|
Loading…
Reference in New Issue