stuff
This commit is contained in:
parent
58c56cdf4f
commit
2ca9b3887b
|
@ -7318,7 +7318,7 @@ module.exports = (_ => {
|
||||||
children: this.props.settings.map(setting => BDFDB.ReactUtils.createElement("div", {
|
children: this.props.settings.map(setting => BDFDB.ReactUtils.createElement("div", {
|
||||||
className: BDFDB.disCN.checkboxcontainer,
|
className: BDFDB.disCN.checkboxcontainer,
|
||||||
children: BDFDB.ReactUtils.createElement(Internal.LibraryComponents.TooltipContainer, {
|
children: BDFDB.ReactUtils.createElement(Internal.LibraryComponents.TooltipContainer, {
|
||||||
text: setting,
|
text: setting.toUpperCase(),
|
||||||
children: BDFDB.ReactUtils.createElement(Internal.LibraryComponents.Checkbox, {
|
children: BDFDB.ReactUtils.createElement(Internal.LibraryComponents.Checkbox, {
|
||||||
disabled: props.disabled,
|
disabled: props.disabled,
|
||||||
cardId: props.key,
|
cardId: props.key,
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
* @name ShowBadgesInChat
|
* @name ShowBadgesInChat
|
||||||
* @author DevilBro
|
* @author DevilBro
|
||||||
* @authorId 278543574059057154
|
* @authorId 278543574059057154
|
||||||
* @version 1.8.9
|
* @version 1.9.0
|
||||||
* @description Displays Badges (Nitro, Hypesquad, etc...) in the Chat/MemberList/DMList
|
* @description Displays Badges (Nitro, Hypesquad, etc...) in the Chat/MemberList/DMList
|
||||||
* @invite Jx3TjNS
|
* @invite Jx3TjNS
|
||||||
* @donate https://www.paypal.me/MircoWittrien
|
* @donate https://www.paypal.me/MircoWittrien
|
||||||
|
@ -17,8 +17,13 @@ module.exports = (_ => {
|
||||||
"info": {
|
"info": {
|
||||||
"name": "ShowBadgesInChat",
|
"name": "ShowBadgesInChat",
|
||||||
"author": "DevilBro",
|
"author": "DevilBro",
|
||||||
"version": "1.8.9",
|
"version": "1.9.0",
|
||||||
"description": "Displays Badges (Nitro, Hypesquad, etc...) in the Chat/MemberList/DMList"
|
"description": "Displays Badges (Nitro, Hypesquad, etc...) in the Chat/MemberList/DMList"
|
||||||
|
},
|
||||||
|
"changeLog": {
|
||||||
|
"improved": {
|
||||||
|
"More Specific Settings": "You can now select more specifically where which Badges will be shown"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -61,9 +66,17 @@ module.exports = (_ => {
|
||||||
}
|
}
|
||||||
} : (([Plugin, BDFDB]) => {
|
} : (([Plugin, BDFDB]) => {
|
||||||
var _this;
|
var _this;
|
||||||
var loadedUsers = {}, queuedInstances = {}, requestQueue = {queue: [], timeout: null, id: null}, cacheTimeout;
|
var badgeConfigs = {}, loadedUsers = {}, queuedInstances = {}, requestQueue = {queue: [], timeout: null, id: null}, cacheTimeout;
|
||||||
var specialFlag;
|
var specialFlag;
|
||||||
|
|
||||||
|
const places = ["chat", "memberList", "dmsList"];
|
||||||
|
|
||||||
|
const badges = {};
|
||||||
|
|
||||||
|
const indicators = {
|
||||||
|
CURRENT_GUILD_BOOST: {value: true}
|
||||||
|
};
|
||||||
|
|
||||||
return class ShowBadgesInChat extends Plugin {
|
return class ShowBadgesInChat extends Plugin {
|
||||||
onLoad () {
|
onLoad () {
|
||||||
_this = this;
|
_this = this;
|
||||||
|
@ -79,22 +92,10 @@ module.exports = (_ => {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
this.defaults = {
|
|
||||||
places: {
|
|
||||||
chat: {value: true, description: "Chat"},
|
|
||||||
memberList: {value: true, description: "Member List"},
|
|
||||||
dmsList: {value: true, description: "DM List"}
|
|
||||||
},
|
|
||||||
badges: {},
|
|
||||||
indicators: {
|
|
||||||
CURRENT_GUILD_BOOST: {value: true}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
for (let key of Object.keys(BDFDB.LibraryComponents.UserBadgeKeys).filter(n => isNaN(parseInt(n)))) {
|
for (let key of Object.keys(BDFDB.LibraryComponents.UserBadgeKeys).filter(n => isNaN(parseInt(n)))) {
|
||||||
let basicKey = key.replace(/_LEVEL_\d+/g, "");
|
let basicKey = key.replace(/_LEVEL_\d+/g, "");
|
||||||
if (!this.defaults.badges[basicKey]) this.defaults.badges[basicKey] = {value: true, keys: []};
|
if (!badges[basicKey]) badges[basicKey] = {value: true, keys: []};
|
||||||
this.defaults.badges[basicKey].keys.push(BDFDB.LibraryComponents.UserBadgeKeys[key]);
|
badges[basicKey].keys.push(BDFDB.LibraryComponents.UserBadgeKeys[key]);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.css = `
|
this.css = `
|
||||||
|
@ -152,6 +153,12 @@ module.exports = (_ => {
|
||||||
${BDFDB.dotCN._showbadgesinchatbadgessettings} {
|
${BDFDB.dotCN._showbadgesinchatbadgessettings} {
|
||||||
color: var(--header-primary);
|
color: var(--header-primary);
|
||||||
}
|
}
|
||||||
|
${BDFDB.dotCN._showbadgesinchatbadgessettings} * {
|
||||||
|
cursor: default;
|
||||||
|
}
|
||||||
|
${BDFDB.dotCN._showbadgesinchatbadgessettings}:last-child {
|
||||||
|
margin-right: 8px;
|
||||||
|
}
|
||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -159,6 +166,39 @@ module.exports = (_ => {
|
||||||
queuedInstances = {}, loadedUsers = {};
|
queuedInstances = {}, loadedUsers = {};
|
||||||
requestQueue = {queue: [], timeout: null, id: null};
|
requestQueue = {queue: [], timeout: null, id: null};
|
||||||
|
|
||||||
|
badgeConfigs = BDFDB.DataUtils.load(this, "badgeConfigs");
|
||||||
|
for (let key in badges) {
|
||||||
|
if (!badgeConfigs[key]) badgeConfigs[key] = {};
|
||||||
|
for (let key2 of places) if (badgeConfigs[key][key2] == undefined) badgeConfigs[key][key2] = true;
|
||||||
|
badgeConfigs[key].key = key;
|
||||||
|
}
|
||||||
|
for (let key in indicators) {
|
||||||
|
if (!badgeConfigs[key]) badgeConfigs[key] = {};
|
||||||
|
for (let key2 of places) if (badgeConfigs[key][key2] == undefined) badgeConfigs[key][key2] = true;
|
||||||
|
badgeConfigs[key].key = key;
|
||||||
|
}
|
||||||
|
|
||||||
|
// REMOVE 15.06.2022
|
||||||
|
let oldPlaces = BDFDB.DataUtils.load(this, "places");
|
||||||
|
let oldBadges = BDFDB.DataUtils.load(this, "badges");
|
||||||
|
let oldIndicators = BDFDB.DataUtils.load(this, "indicators");
|
||||||
|
if (Object.keys(oldBadges).length && Object.keys(oldIndicators).length && Object.keys(oldPlaces).length) {
|
||||||
|
for (let key in oldBadges) {
|
||||||
|
if (!badgeConfigs[key]) badgeConfigs[key] = {};
|
||||||
|
for (let key2 in oldPlaces) badgeConfigs[key][key2] = oldBadges[key] && oldPlaces[key2];
|
||||||
|
}
|
||||||
|
for (let key in oldIndicators) {
|
||||||
|
if (!badgeConfigs[key]) badgeConfigs[key] = {};
|
||||||
|
for (let key2 in oldPlaces) badgeConfigs[key][key2] = oldIndicators[key] && oldPlaces[key2];
|
||||||
|
}
|
||||||
|
BDFDB.DataUtils.remove(this, "general");
|
||||||
|
BDFDB.DataUtils.remove(this, "settings");
|
||||||
|
BDFDB.DataUtils.remove(this, "places");
|
||||||
|
BDFDB.DataUtils.remove(this, "badges");
|
||||||
|
BDFDB.DataUtils.remove(this, "indicators");
|
||||||
|
BDFDB.DataUtils.save(badgeConfigs, this, "badgeConfigs");
|
||||||
|
}
|
||||||
|
|
||||||
let badgeCache = BDFDB.DataUtils.load(this, "badgeCache");
|
let badgeCache = BDFDB.DataUtils.load(this, "badgeCache");
|
||||||
if (badgeCache) {
|
if (badgeCache) {
|
||||||
let now = (new Date()).getTime(), month = 1000*60*60*24*30;
|
let now = (new Date()).getTime(), month = 1000*60*60*24*30;
|
||||||
|
@ -209,35 +249,54 @@ module.exports = (_ => {
|
||||||
collapseStates: collapseStates,
|
collapseStates: collapseStates,
|
||||||
children: _ => {
|
children: _ => {
|
||||||
let settingsItems = [];
|
let settingsItems = [];
|
||||||
|
settingsItems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.FormComponents.FormTitle, {
|
||||||
settingsItems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsPanelList, {
|
className: BDFDB.disCN.marginbottom4,
|
||||||
title: "Show Badges in:",
|
tag: BDFDB.LibraryComponents.FormComponents.FormTitle.Tags.H3,
|
||||||
children: Object.keys(this.defaults.places).map(key => BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsSaveItem, {
|
children: "Show Badges in"
|
||||||
type: "Switch",
|
|
||||||
plugin: this,
|
|
||||||
keys: ["places", key],
|
|
||||||
label: this.defaults.places[key].description,
|
|
||||||
value: this.settings.places[key]
|
|
||||||
}))
|
|
||||||
}));
|
}));
|
||||||
|
settingsItems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsList, {
|
||||||
settingsItems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsPanelList, {
|
settings: places,
|
||||||
title: "Display Badges:",
|
data: Object.keys(badges).concat(Object.keys(indicators)).map(key => badgeConfigs[key]),
|
||||||
children: Object.keys(this.defaults.badges).map(key => BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsSaveItem, {
|
noRemove: true,
|
||||||
type: "Switch",
|
renderLabel: (cardData, instance) => BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Flex, {
|
||||||
plugin: this,
|
children: [
|
||||||
keys: ["badges", key],
|
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Flex.Child, {
|
||||||
label: key.split("_").map(n => BDFDB.LibraryModules.StringUtils.upperCaseFirstChar(n.toLowerCase())).join(" "),
|
children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Clickable, {
|
||||||
value: this.settings.badges[key],
|
onClick: _ => {
|
||||||
labelChildren: this.createSettingsBadges(key)
|
for (let settingId of places) badgeConfigs[cardData.key][settingId] = true;
|
||||||
})).concat(Object.keys(this.defaults.indicators).map(key => BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsSaveItem, {
|
BDFDB.DataUtils.save(badgeConfigs, this, "badgeConfigs");
|
||||||
type: "Switch",
|
BDFDB.ReactUtils.forceUpdate(instance);
|
||||||
plugin: this,
|
this.SettingsUpdated = true;
|
||||||
keys: ["indicators", key],
|
},
|
||||||
label: key.split("_").map(n => BDFDB.LibraryModules.StringUtils.upperCaseFirstChar(n.toLowerCase())).join(" "),
|
onContextMenu: _ => {
|
||||||
value: this.settings.indicators[key],
|
for (let settingId of places) badgeConfigs[cardData.key][settingId] = false;
|
||||||
labelChildren: this.createSettingsBadges(key)
|
BDFDB.DataUtils.save(badgeConfigs, this, "badgeConfigs");
|
||||||
})))
|
BDFDB.ReactUtils.forceUpdate(instance);
|
||||||
|
this.SettingsUpdated = true;
|
||||||
|
},
|
||||||
|
children: cardData.key.split("_").map(n => BDFDB.LibraryModules.StringUtils.upperCaseFirstChar(n.toLowerCase())).join(" ")
|
||||||
|
})
|
||||||
|
}),
|
||||||
|
this.createSettingsBadges(cardData.key)
|
||||||
|
]
|
||||||
|
}),
|
||||||
|
onHeaderClick: (settingId, instance) => {
|
||||||
|
for (let key in badgeConfigs) badgeConfigs[key][settingId] = true;
|
||||||
|
BDFDB.DataUtils.save(badgeConfigs, this, "badgeConfigs");
|
||||||
|
BDFDB.ReactUtils.forceUpdate(instance);
|
||||||
|
this.SettingsUpdated = true;
|
||||||
|
},
|
||||||
|
onHeaderContextMenu: (settingId, instance) => {
|
||||||
|
for (let key in badgeConfigs) badgeConfigs[key][settingId] = false;
|
||||||
|
BDFDB.DataUtils.save(badgeConfigs, this, "badgeConfigs");
|
||||||
|
BDFDB.ReactUtils.forceUpdate(instance);
|
||||||
|
this.SettingsUpdated = true;
|
||||||
|
},
|
||||||
|
onCheckboxChange: (value, instance) => {
|
||||||
|
badgeConfigs[instance.props.cardId][instance.props.settingId] = value;
|
||||||
|
BDFDB.DataUtils.save(badgeConfigs, this, "badgeConfigs");
|
||||||
|
this.SettingsUpdated = true;
|
||||||
|
}
|
||||||
}));
|
}));
|
||||||
|
|
||||||
settingsItems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsItem, {
|
settingsItems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsItem, {
|
||||||
|
@ -246,7 +305,7 @@ module.exports = (_ => {
|
||||||
label: "Reset cached Badge Data",
|
label: "Reset cached Badge Data",
|
||||||
onClick: _ => BDFDB.ModalUtils.confirm(this, "Are you sure you want to reset the Badge Cache? This will force all Badges to rerender.", _ => {
|
onClick: _ => BDFDB.ModalUtils.confirm(this, "Are you sure you want to reset the Badge Cache? This will force all Badges to rerender.", _ => {
|
||||||
BDFDB.DataUtils.remove(this, "badgeCache");
|
BDFDB.DataUtils.remove(this, "badgeCache");
|
||||||
this.forceUpdateAll();
|
this.SettingsUpdated = true;
|
||||||
}),
|
}),
|
||||||
children: BDFDB.LanguageUtils.LanguageStrings.RESET
|
children: BDFDB.LanguageUtils.LanguageStrings.RESET
|
||||||
}));
|
}));
|
||||||
|
@ -269,7 +328,7 @@ module.exports = (_ => {
|
||||||
}
|
}
|
||||||
|
|
||||||
processMessageUsername (e) {
|
processMessageUsername (e) {
|
||||||
if (!e.instance.props.message || !this.settings.places.chat) return;
|
if (!e.instance.props.message) return;
|
||||||
let [children, index] = BDFDB.ReactUtils.findParent(e.returnvalue, {name: "Popout"});
|
let [children, index] = BDFDB.ReactUtils.findParent(e.returnvalue, {name: "Popout"});
|
||||||
if (index == -1) return;
|
if (index == -1) return;
|
||||||
const author = e.instance.props.userOverride || e.instance.props.message.author;
|
const author = e.instance.props.userOverride || e.instance.props.message.author;
|
||||||
|
@ -277,12 +336,12 @@ module.exports = (_ => {
|
||||||
}
|
}
|
||||||
|
|
||||||
processMemberListItem (e) {
|
processMemberListItem (e) {
|
||||||
if (!e.instance.props.user || !this.settings.places.memberList) return;
|
if (!e.instance.props.user) return;
|
||||||
this.injectBadges(BDFDB.ObjectUtils.get(e.returnvalue, "props.decorators.props.children"), e.instance.props.user, e.instance.props.channel.guild_id, "members");
|
this.injectBadges(BDFDB.ObjectUtils.get(e.returnvalue, "props.decorators.props.children"), e.instance.props.user, e.instance.props.channel.guild_id, "memberList");
|
||||||
}
|
}
|
||||||
|
|
||||||
processPrivateChannel (e) {
|
processPrivateChannel (e) {
|
||||||
if (!e.instance.props.user || !this.settings.places.dmsList) return;
|
if (!e.instance.props.user) return;
|
||||||
let wrapper = e.returnvalue && e.returnvalue.props.children && e.returnvalue.props.children.props && typeof e.returnvalue.props.children.props.children == "function" ? e.returnvalue.props.children : e.returnvalue;
|
let wrapper = e.returnvalue && e.returnvalue.props.children && e.returnvalue.props.children.props && typeof e.returnvalue.props.children.props.children == "function" ? e.returnvalue.props.children : e.returnvalue;
|
||||||
if (typeof wrapper.props.children == "function") {
|
if (typeof wrapper.props.children == "function") {
|
||||||
let childrenRender = wrapper.props.children;
|
let childrenRender = wrapper.props.children;
|
||||||
|
@ -299,15 +358,16 @@ module.exports = (_ => {
|
||||||
const wrapper = returnvalue.props.decorators ? returnvalue : BDFDB.ReactUtils.findChild(returnvalue, {props: ["decorators"]}) || returnvalue;
|
const wrapper = returnvalue.props.decorators ? returnvalue : BDFDB.ReactUtils.findChild(returnvalue, {props: ["decorators"]}) || returnvalue;
|
||||||
if (!wrapper) return;
|
if (!wrapper) return;
|
||||||
wrapper.props.decorators = [wrapper.props.decorators].flat(10);
|
wrapper.props.decorators = [wrapper.props.decorators].flat(10);
|
||||||
this.injectBadges(wrapper.props.decorators, instance.props.user, null, "dms");
|
this.injectBadges(wrapper.props.decorators, instance.props.user, null, "dmsList");
|
||||||
}
|
}
|
||||||
|
|
||||||
processUserProfileBadgeList (e) {
|
processUserProfileBadgeList (e) {
|
||||||
if (e.instance.props.custom) {
|
if (e.instance.props.custom) {
|
||||||
|
let filter = e.instance.props.place != "settings";
|
||||||
for (let i in e.returnvalue.props.children) if (e.returnvalue.props.children[i]) {
|
for (let i in e.returnvalue.props.children) if (e.returnvalue.props.children[i]) {
|
||||||
let key = parseInt(e.returnvalue.props.children[i].key);
|
let key = parseInt(e.returnvalue.props.children[i].key);
|
||||||
let keyName = e.instance.props.filter && Object.keys(this.defaults.badges).find(n => this.defaults.badges[n].keys.includes(key));
|
let keyName = filter && Object.keys(badges).find(n => badges[n].keys.includes(key));
|
||||||
if (keyName && !this.settings.badges[keyName]) e.returnvalue.props.children[i] = null;
|
if (keyName && badgeConfigs[keyName] && !badgeConfigs[keyName][e.instance.props.place]) e.returnvalue.props.children[i] = null;
|
||||||
else if (e.returnvalue.props.children[i].type.displayName == "TooltipContainer" || e.returnvalue.props.children[i].type.displayName == "Tooltip") {
|
else if (e.returnvalue.props.children[i].type.displayName == "TooltipContainer" || e.returnvalue.props.children[i].type.displayName == "Tooltip") {
|
||||||
const childrenRender = e.returnvalue.props.children[i].props.children;
|
const childrenRender = e.returnvalue.props.children[i].props.children;
|
||||||
e.returnvalue.props.children[i].props.children = (...args) => {
|
e.returnvalue.props.children[i].props.children = (...args) => {
|
||||||
|
@ -318,7 +378,7 @@ module.exports = (_ => {
|
||||||
e.returnvalue.props.children[i] = BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.TooltipContainer, e.returnvalue.props.children[i].props);
|
e.returnvalue.props.children[i] = BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.TooltipContainer, e.returnvalue.props.children[i].props);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ((this.settings.indicators.CURRENT_GUILD_BOOST || !e.instance.props.filter) && e.instance.props.premiumCurrentGuildSince) e.returnvalue.props.children.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.TooltipContainer, {
|
if (e.instance.props.premiumCurrentGuildSince && !(filter && badgeConfigs.CURRENT_GUILD_BOOST && !badgeConfigs.CURRENT_GUILD_BOOST[e.instance.props.place])) e.returnvalue.props.children.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.TooltipContainer, {
|
||||||
text: BDFDB.LanguageUtils.LanguageStringsFormat("PREMIUM_GUILD_SUBSCRIPTION_TOOLTIP", e.instance.props.premiumCurrentGuildSince),
|
text: BDFDB.LanguageUtils.LanguageStringsFormat("PREMIUM_GUILD_SUBSCRIPTION_TOOLTIP", e.instance.props.premiumCurrentGuildSince),
|
||||||
children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Clickable, {
|
children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Clickable, {
|
||||||
className: BDFDB.disCN.userbadgeouter,
|
className: BDFDB.disCN.userbadgeouter,
|
||||||
|
@ -335,7 +395,7 @@ module.exports = (_ => {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
injectBadges (children, user, guildId, type) {
|
injectBadges (children, user, guildId, place) {
|
||||||
if (!BDFDB.ArrayUtils.is(children) || !user || user.isNonUserBot()) return;
|
if (!BDFDB.ArrayUtils.is(children) || !user || user.isNonUserBot()) return;
|
||||||
if (!loadedUsers[user.id] || ((new Date()).getTime() - loadedUsers[user.id].date >= 1000*60*60*24*7)) {
|
if (!loadedUsers[user.id] || ((new Date()).getTime() - loadedUsers[user.id].date >= 1000*60*60*24*7)) {
|
||||||
queuedInstances[user.id] = [].concat(queuedInstances[user.id]).filter(n => n);
|
queuedInstances[user.id] = [].concat(queuedInstances[user.id]).filter(n => n);
|
||||||
|
@ -348,7 +408,7 @@ module.exports = (_ => {
|
||||||
if (queuedInstances[user.id].indexOf(this) == -1) queuedInstances[user.id].push(this);
|
if (queuedInstances[user.id].indexOf(this) == -1) queuedInstances[user.id].push(this);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
else return _this.createBadges(user, guildId, type);
|
else return _this.createBadges(user, guildId, place);
|
||||||
}
|
}
|
||||||
}, {}, true));
|
}, {}, true));
|
||||||
}
|
}
|
||||||
|
@ -368,7 +428,7 @@ module.exports = (_ => {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
createBadges (user, guildId, type) {
|
createBadges (user, guildId, place) {
|
||||||
let fakeGuildBoostDate;
|
let fakeGuildBoostDate;
|
||||||
if (typeof user.id == "string" && user.id.startsWith(specialFlag + "GB")) {
|
if (typeof user.id == "string" && user.id.startsWith(specialFlag + "GB")) {
|
||||||
let level = parseInt(user.id.split("_").pop());
|
let level = parseInt(user.id.split("_").pop());
|
||||||
|
@ -379,11 +439,11 @@ module.exports = (_ => {
|
||||||
}
|
}
|
||||||
let member = guildId && BDFDB.LibraryModules.MemberStore.getMember(guildId, user.id);
|
let member = guildId && BDFDB.LibraryModules.MemberStore.getMember(guildId, user.id);
|
||||||
return BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.UserBadges.default, {
|
return BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.UserBadges.default, {
|
||||||
className: BDFDB.DOMUtils.formatClassName(BDFDB.disCN._showbadgesinchatbadges, BDFDB.disCN[`_showbadgesinchatbadges${type}`]),
|
className: BDFDB.DOMUtils.formatClassName(BDFDB.disCN._showbadgesinchatbadges, BDFDB.disCN[`_showbadgesinchatbadges${place.toLowerCase()}`]),
|
||||||
user: user,
|
user: user,
|
||||||
size: BDFDB.LibraryComponents.UserBadges.BadgeSizes.SIZE_18,
|
size: BDFDB.LibraryComponents.UserBadges.BadgeSizes.SIZE_18,
|
||||||
custom: true,
|
custom: true,
|
||||||
filter: type != "settings",
|
place: place,
|
||||||
premiumSince: loadedUsers[user.id] && loadedUsers[user.id].premium_since ? new Date(loadedUsers[user.id].premium_since) : (user.id == (specialFlag + "NITRO") ? new Date() : null),
|
premiumSince: loadedUsers[user.id] && loadedUsers[user.id].premium_since ? new Date(loadedUsers[user.id].premium_since) : (user.id == (specialFlag + "NITRO") ? new Date() : null),
|
||||||
premiumGuildSince: fakeGuildBoostDate || (loadedUsers[user.id] && loadedUsers[user.id].premium_guild_since ? new Date(loadedUsers[user.id].premium_guild_since) : null),
|
premiumGuildSince: fakeGuildBoostDate || (loadedUsers[user.id] && loadedUsers[user.id].premium_guild_since ? new Date(loadedUsers[user.id].premium_guild_since) : null),
|
||||||
premiumCurrentGuildSince: member && member.premiumSince && new Date(member.premiumSince) || user.id == (specialFlag + "CGB") && new Date()
|
premiumCurrentGuildSince: member && member.premiumSince && new Date(member.premiumSince) || user.id == (specialFlag + "CGB") && new Date()
|
||||||
|
@ -392,12 +452,12 @@ module.exports = (_ => {
|
||||||
|
|
||||||
createSettingsBadges (flag) {
|
createSettingsBadges (flag) {
|
||||||
let wrappers = [];
|
let wrappers = [];
|
||||||
if (this.defaults.indicators[flag]) {
|
if (indicators[flag]) {
|
||||||
let id = flag == "CURRENT_GUILD_BOOST" ? (specialFlag + "CGB") : null;
|
let id = flag == "CURRENT_GUILD_BOOST" ? (specialFlag + "CGB") : null;
|
||||||
let user = new BDFDB.DiscordObjects.User({flags: 0, id: id});
|
let user = new BDFDB.DiscordObjects.User({flags: 0, id: id});
|
||||||
wrappers.push(this.createBadges(user, null, "settings"));
|
wrappers.push(this.createBadges(user, null, "settings"));
|
||||||
}
|
}
|
||||||
else for (let key of this.defaults.badges[flag].keys) {
|
else for (let key of badges[flag].keys) {
|
||||||
let userFlag = flag == "PREMIUM" || flag == "GUILD_BOOSTER" ? 0 : BDFDB.DiscordConstants.UserFlags[flag];
|
let userFlag = flag == "PREMIUM" || flag == "GUILD_BOOSTER" ? 0 : BDFDB.DiscordConstants.UserFlags[flag];
|
||||||
let keyName = BDFDB.LibraryComponents.UserBadgeKeys[key];
|
let keyName = BDFDB.LibraryComponents.UserBadgeKeys[key];
|
||||||
if (userFlag == null && keyName) userFlag = BDFDB.DiscordConstants.UserFlags[keyName] != null ? BDFDB.DiscordConstants.UserFlags[keyName] : BDFDB.DiscordConstants.UserFlags[Object.keys(BDFDB.DiscordConstants.UserFlags).find(f => f.indexOf(keyName) > -1 || keyName.indexOf(f) > -1)];
|
if (userFlag == null && keyName) userFlag = BDFDB.DiscordConstants.UserFlags[keyName] != null ? BDFDB.DiscordConstants.UserFlags[keyName] : BDFDB.DiscordConstants.UserFlags[Object.keys(BDFDB.DiscordConstants.UserFlags).find(f => f.indexOf(keyName) > -1 || keyName.indexOf(f) > -1)];
|
||||||
|
|
Loading…
Reference in New Issue