MAR v2.0.3
This commit is contained in:
parent
43744f8d99
commit
9bcfcfb2ee
|
@ -1,4 +1,9 @@
|
||||||
# [MentionAliasesRedux](https://1lighty.github.io/BetterDiscordStuff/?plugin=MentionAliasesRedux "MentionAliasesRedux") Changelog
|
# [MentionAliasesRedux](https://1lighty.github.io/BetterDiscordStuff/?plugin=MentionAliasesRedux "MentionAliasesRedux") Changelog
|
||||||
|
### 2.0.3
|
||||||
|
- Fixed clicking items in the menu not working
|
||||||
|
- Fixed tagging groups not working well
|
||||||
|
- Fixed unfriendly patch
|
||||||
|
|
||||||
### 2.0.2
|
### 2.0.2
|
||||||
- Plugin has been renamed to MentionAliasesRedux to avoid issues loading due to the original plugin, as well as to be able to distinguish between the two more easily.
|
- Plugin has been renamed to MentionAliasesRedux to avoid issues loading due to the original plugin, as well as to be able to distinguish between the two more easily.
|
||||||
- Fixed plugin description being wrong
|
- Fixed plugin description being wrong
|
||||||
|
|
|
@ -23,7 +23,7 @@
|
||||||
|
|
||||||
@else@*/
|
@else@*/
|
||||||
/*
|
/*
|
||||||
* Copyright© 2019-2020, _Lighty_
|
* Copyright © 2019-2020, _Lighty_
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
* Code may not be redistributed, modified or otherwise taken without explicit permission.
|
* Code may not be redistributed, modified or otherwise taken without explicit permission.
|
||||||
*/
|
*/
|
||||||
|
@ -41,21 +41,16 @@ var MentionAliasesRedux = (() => {
|
||||||
twitter_username: ''
|
twitter_username: ''
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
version: '2.0.2',
|
version: '2.0.3',
|
||||||
description: 'Set custom @mention aliases, that can also appear next to their name (nearly) anywhere, as well as have mention groups to mention multiple people at once.',
|
description: 'Set custom @mention aliases, that can also appear next to their name (nearly) anywhere, as well as have mention groups to mention multiple people at once.',
|
||||||
github: 'https://github.com/1Lighty',
|
github: 'https://github.com/1Lighty',
|
||||||
github_raw: 'https://raw.githubusercontent.com/1Lighty/BetterDiscordPlugins/master/Plugins/MentionAliasesRedux/MentionAliasesRedux.plugin.js'
|
github_raw: 'https://raw.githubusercontent.com/1Lighty/BetterDiscordPlugins/master/Plugins/MentionAliasesRedux/MentionAliasesRedux.plugin.js'
|
||||||
},
|
},
|
||||||
changelog: [
|
changelog: [
|
||||||
{
|
|
||||||
title: 'plugin has been renamed!',
|
|
||||||
type: 'added',
|
|
||||||
items: ['Plugin has been renamed to MentionAliasesRedux to avoid issues loading due to the original plugin, as well as to be able to distinguish between the two more easily.']
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
title: 'fixed',
|
title: 'fixed',
|
||||||
type: 'fixed',
|
type: 'fixed',
|
||||||
items: ['Fixed plugin description being wrong', 'Fixed menu button not showing']
|
items: ['Fixed clicking items in the menu not working', 'Fixed tagging groups not working well', 'Fixed unfriendly patch']
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
defaultConfig: [
|
defaultConfig: [
|
||||||
|
@ -156,7 +151,7 @@ var MentionAliasesRedux = (() => {
|
||||||
/* Build */
|
/* Build */
|
||||||
const buildPlugin = ([Plugin, Api]) => {
|
const buildPlugin = ([Plugin, Api]) => {
|
||||||
const { ContextMenu, EmulatedTooltip, Toasts, Settings, Popouts, Modals, Utilities, WebpackModules, Filters, DiscordModules, ColorConverter, DOMTools, DiscordClasses, DiscordSelectors, ReactTools, ReactComponents, DiscordAPI, Logger, Patcher, PluginUpdater, PluginUtilities, DiscordClassModules, Structs } = Api;
|
const { ContextMenu, EmulatedTooltip, Toasts, Settings, Popouts, Modals, Utilities, WebpackModules, Filters, DiscordModules, ColorConverter, DOMTools, DiscordClasses, DiscordSelectors, ReactTools, ReactComponents, DiscordAPI, Logger, Patcher, PluginUpdater, PluginUtilities, DiscordClassModules, Structs } = Api;
|
||||||
const { React, ModalStack, ContextMenuActions, ContextMenuItem, ContextMenuItemsGroup, ReactDOM, ChannelStore, GuildStore, UserStore, DiscordConstants, Dispatcher, GuildMemberStore, GuildActions, SwitchRow, EmojiUtils, RadioGroup, Permissions, TextElement, FlexChild, PopoutOpener, Textbox } = DiscordModules;
|
const { React, ModalStack, ContextMenuActions, ContextMenuItem, ContextMenuItemsGroup, ReactDOM, ChannelStore, GuildStore, UserStore, DiscordConstants, Dispatcher, GuildMemberStore, GuildActions, SwitchRow, EmojiUtils, RadioGroup, Permissions, TextElement, FlexChild, PopoutOpener, Textbox, UserSettingsStore } = DiscordModules;
|
||||||
|
|
||||||
const UserStatusStore = WebpackModules.getByProps('getStatus');
|
const UserStatusStore = WebpackModules.getByProps('getStatus');
|
||||||
|
|
||||||
|
@ -271,7 +266,7 @@ var MentionAliasesRedux = (() => {
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
super(props);
|
super(props);
|
||||||
this.handleSubmit = this.handleSubmitPatch.bind(this);
|
this.handleSubmit = this.handleSubmitPatch.bind(this);
|
||||||
this.renderWarning = () => { };
|
this.renderWarning = () => {};
|
||||||
}
|
}
|
||||||
handleSubmitPatch(e) {
|
handleSubmitPatch(e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
@ -309,7 +304,8 @@ var MentionAliasesRedux = (() => {
|
||||||
}
|
}
|
||||||
handleClick(text, rich) {
|
handleClick(text, rich) {
|
||||||
if (!this.props.channelTextAreaRef._editorRef) return Toasts.error('Internal error, cannot get _editorRef');
|
if (!this.props.channelTextAreaRef._editorRef) return Toasts.error('Internal error, cannot get _editorRef');
|
||||||
this.props.channelTextAreaRef._editorRef.appendText(text);
|
/* hm.. */
|
||||||
|
this.props.channelTextAreaRef._editorRef.ref.current.insertText(/* UserSettingsStore.useRichChatTextBox ? rich : */ text, true);
|
||||||
}
|
}
|
||||||
handleMentionsChange() {
|
handleMentionsChange() {
|
||||||
this.setState({ mentions: this.props.getMentions() });
|
this.setState({ mentions: this.props.getMentions() });
|
||||||
|
@ -350,12 +346,12 @@ var MentionAliasesRedux = (() => {
|
||||||
const children = [];
|
const children = [];
|
||||||
try {
|
try {
|
||||||
this.state.mentions.users.forEach(({ userId, alias }, index) => {
|
this.state.mentions.users.forEach(({ userId, alias }, index) => {
|
||||||
if (!index) children.push(this.renderHeader(`Users—”${this.state.mentions.users.length}`));
|
if (!index) children.push(this.renderHeader(`Users—${this.state.mentions.users.length}`));
|
||||||
const user = UserStore.getUser(userId);
|
const user = UserStore.getUser(userId);
|
||||||
children.push(React.createElement(AliasItem, { isUser: true, onContextMenu: e => this.handleContextMenu(e, userId), onClick: () => this.handleClick(`@${user.tag}`, `<@${userId}>`) }, React.createElement('div', { className: AvatarWrapperClassname }, renderAvatar(user)), renderAlias(alias, user.tag, undefined, true)));
|
children.push(React.createElement(AliasItem, { isUser: true, onContextMenu: e => this.handleContextMenu(e, userId), onClick: () => this.handleClick(`@${user.tag}`, `<@${userId}>`) }, React.createElement('div', { className: AvatarWrapperClassname }, renderAvatar(user)), renderAlias(alias, user.tag, undefined, true)));
|
||||||
});
|
});
|
||||||
this.state.mentions.groups.forEach((group, index) => {
|
this.state.mentions.groups.forEach((group, index) => {
|
||||||
if (!index) children.push(this.renderHeader(`Groups—”${this.state.mentions.groups.length}`, true));
|
if (!index) children.push(this.renderHeader(`Groups—${this.state.mentions.groups.length}`, true));
|
||||||
const groupUsers = this.props.getGroupUsers(group.users);
|
const groupUsers = this.props.getGroupUsers(group.users);
|
||||||
if (groupUsers.note.length > 32) groupUsers.note = groupUsers.note.substr(0, 32 - 3) + '...';
|
if (groupUsers.note.length > 32) groupUsers.note = groupUsers.note.substr(0, 32 - 3) + '...';
|
||||||
children.push(React.createElement(AliasItem, { onContextMenu: e => this.handleContextMenu(e, group.id, true), onClick: () => this.handleClick(groupUsers.tags, groupUsers.tagsIds) }, renderAlias(group.name, groupUsers.note, undefined, false)));
|
children.push(React.createElement(AliasItem, { onContextMenu: e => this.handleContextMenu(e, group.id, true), onClick: () => this.handleClick(groupUsers.tags, groupUsers.tagsIds) }, renderAlias(group.name, groupUsers.note, undefined, false)));
|
||||||
|
@ -393,7 +389,7 @@ var MentionAliasesRedux = (() => {
|
||||||
|
|
||||||
class PreviewField extends Settings.SettingField {
|
class PreviewField extends Settings.SettingField {
|
||||||
constructor(name, note) {
|
constructor(name, note) {
|
||||||
super(name, note, () => { }, Preview);
|
super(name, note, () => {}, Preview);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -734,7 +730,7 @@ var MentionAliasesRedux = (() => {
|
||||||
async patchPrivateChannel(promiseState) {
|
async patchPrivateChannel(promiseState) {
|
||||||
const PrivateChannel = await ReactComponents.getComponentByName('PrivateChannel', `.${XenoLib.getSingleClass('closeButton channel')}`);
|
const PrivateChannel = await ReactComponents.getComponentByName('PrivateChannel', `.${XenoLib.getSingleClass('closeButton channel')}`);
|
||||||
if (promiseState.cancelled) return;
|
if (promiseState.cancelled) return;
|
||||||
const TypePatch = function (e) {
|
const TypePatch = function(e) {
|
||||||
const ret = e.__oldTypeMA(e);
|
const ret = e.__oldTypeMA(e);
|
||||||
const nameAndDecorators = Utilities.getNestedProp(ret, 'props.children.props.children.1.props.children.0.props.children');
|
const nameAndDecorators = Utilities.getNestedProp(ret, 'props.children.props.children.1.props.children.0.props.children');
|
||||||
if (!nameAndDecorators) return ret;
|
if (!nameAndDecorators) return ret;
|
||||||
|
@ -756,7 +752,7 @@ var MentionAliasesRedux = (() => {
|
||||||
async patchFriendRow(promiseState) {
|
async patchFriendRow(promiseState) {
|
||||||
const FriendRow = await ReactComponents.getComponentByName('FriendRow', `.${XenoLib.getSingleClass('friendsColumn friendsRow')}`);
|
const FriendRow = await ReactComponents.getComponentByName('FriendRow', `.${XenoLib.getSingleClass('friendsColumn friendsRow')}`);
|
||||||
if (promiseState.cancelled) return;
|
if (promiseState.cancelled) return;
|
||||||
const TypePatch2 = function (e) {
|
const TypePatch2 = function(e) {
|
||||||
try {
|
try {
|
||||||
const ret = new e.__oldType2MA(e);
|
const ret = new e.__oldType2MA(e);
|
||||||
ret.props.children.splice(1, 0, this.createAlias(e.__aliasMA, MemberTagClassname));
|
ret.props.children.splice(1, 0, this.createAlias(e.__aliasMA, MemberTagClassname));
|
||||||
|
@ -771,7 +767,7 @@ var MentionAliasesRedux = (() => {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}.bind(this);
|
}.bind(this);
|
||||||
const TypePatch1 = function (e) {
|
const TypePatch1 = function(e) {
|
||||||
try {
|
try {
|
||||||
const ret = new e.__oldType1MA(e);
|
const ret = new e.__oldType1MA(e);
|
||||||
ret.props.__oldType2MA = ret.type;
|
ret.props.__oldType2MA = ret.type;
|
||||||
|
@ -805,7 +801,7 @@ var MentionAliasesRedux = (() => {
|
||||||
async patchMutualFriends(promiseState) {
|
async patchMutualFriends(promiseState) {
|
||||||
const MutualFriends = await ReactComponents.getComponentByName('MutualFriends', `.${XenoLib.getSingleClass('scroller themeGhostHairline')}`);
|
const MutualFriends = await ReactComponents.getComponentByName('MutualFriends', `.${XenoLib.getSingleClass('scroller themeGhostHairline')}`);
|
||||||
if (promiseState.cancelled) return;
|
if (promiseState.cancelled) return;
|
||||||
const TypePatch3 = function (e) {
|
const TypePatch3 = function(e) {
|
||||||
try {
|
try {
|
||||||
const ret = new e.__oldType3MA(e);
|
const ret = new e.__oldType3MA(e);
|
||||||
ret.props.children.push(this.createAlias(e.__aliasMA, MemberTagClassname));
|
ret.props.children.push(this.createAlias(e.__aliasMA, MemberTagClassname));
|
||||||
|
@ -820,7 +816,7 @@ var MentionAliasesRedux = (() => {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}.bind(this);
|
}.bind(this);
|
||||||
const TypePatch2 = function (e) {
|
const TypePatch2 = function(e) {
|
||||||
try {
|
try {
|
||||||
const ret = new e.__oldType2MA(e);
|
const ret = new e.__oldType2MA(e);
|
||||||
ret.props.__oldType3MA = ret.type;
|
ret.props.__oldType3MA = ret.type;
|
||||||
|
@ -836,7 +832,7 @@ var MentionAliasesRedux = (() => {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}.bind(this);
|
}.bind(this);
|
||||||
const TypePatch1 = function (e) {
|
const TypePatch1 = function(e) {
|
||||||
try {
|
try {
|
||||||
const ret = new e.__oldType1MA(e);
|
const ret = new e.__oldType1MA(e);
|
||||||
const DiscordTag = Utilities.getNestedProp(ret, 'props.children.1');
|
const DiscordTag = Utilities.getNestedProp(ret, 'props.children.1');
|
||||||
|
@ -877,25 +873,25 @@ var MentionAliasesRedux = (() => {
|
||||||
async patchChannelTextArea(promiseState) {
|
async patchChannelTextArea(promiseState) {
|
||||||
const ChannelTextArea = await ReactComponents.getComponentByName('ChannelTextAreaForm', `.${XenoLib.getSingleClass('channelTextArea')}`);
|
const ChannelTextArea = await ReactComponents.getComponentByName('ChannelTextAreaForm', `.${XenoLib.getSingleClass('channelTextArea')}`);
|
||||||
if (promiseState.cancelled) return;
|
if (promiseState.cancelled) return;
|
||||||
Patcher.after(
|
const ChannelTextAreaContainer = WebpackModules.find(m => m.render && m.render.displayName === 'ChannelTextAreaContainer');
|
||||||
WebpackModules.find(m => m.render && m.render.displayName === 'ChannelTextAreaContainer'),
|
const original = ChannelTextAreaContainer.render;
|
||||||
'render',
|
Patcher.after(ChannelTextAreaContainer, 'render', (_this, _, ret) => {
|
||||||
(_this, _, ret) => {
|
const ChannelEditorContainer = Utilities.getNestedProp(ret, 'props.children.0.props.children.props.children.1');
|
||||||
const props = Utilities.getNestedProp(ret, 'props.children.0.props.children.props.children.2.props.children.2.props');
|
if (!ChannelEditorContainer || ChannelEditorContainer.props.disabled || !this.settings.display.displayButton) return;
|
||||||
if (!props || props.disabled || !this.settings.display.displayButton) return;
|
const buttons = Utilities.getNestedProp(ret, 'props.children.0.props.children.props.children.2.props.children');
|
||||||
const buttons = Utilities.getNestedProp(ret, 'props.children.0.props.children.props.children.2.props.children');
|
if (!buttons) return;
|
||||||
if (!buttons) return;
|
const _editorRef = Utilities.getNestedProp(ChannelEditorContainer, 'ref.current');
|
||||||
const _editorRef = Utilities.getNestedProp(props, 'editorRef.current');
|
buttons.unshift(
|
||||||
buttons.unshift(
|
React.createElement(ChannelTextAreaButton, {
|
||||||
React.createElement(ChannelTextAreaButton, {
|
iconName: 'Nova_At',
|
||||||
iconName: 'Nova_At',
|
label: 'Open Aliases',
|
||||||
label: 'Open Aliases',
|
className: ChannelTextAreaButtonClassname,
|
||||||
className: ChannelTextAreaButtonClassname,
|
onClick: e => this.openAliasesPopout(e, { _editorRef })
|
||||||
onClick: e => this.openAliasesPopout(e, { _editorRef })
|
})
|
||||||
})
|
);
|
||||||
);
|
});
|
||||||
}
|
/* transfer displayName and such, to be friendly to other plugins */
|
||||||
);
|
Object.keys(original).forEach(name => (ChannelTextAreaContainer.render[name] = original[name]));
|
||||||
this.patchedModules.push(ChannelTextArea);
|
this.patchedModules.push(ChannelTextArea);
|
||||||
ChannelTextArea.forceUpdateAll();
|
ChannelTextArea.forceUpdateAll();
|
||||||
}
|
}
|
||||||
|
@ -998,11 +994,12 @@ var MentionAliasesRedux = (() => {
|
||||||
Patcher.instead(WebpackModules.getByPrototypes('selectAutocompletion').prototype, 'selectAutocompletion', (_this, args, orig) => {
|
Patcher.instead(WebpackModules.getByPrototypes('selectAutocompletion').prototype, 'selectAutocompletion', (_this, args, orig) => {
|
||||||
const selected = args[0];
|
const selected = args[0];
|
||||||
const type = _this.state.autocompleteType;
|
const type = _this.state.autocompleteType;
|
||||||
if (type !== 'MENTIONS' || !_this._editorRef) return orig(...args);
|
const _editorRef = _this.props.editorRef.current;
|
||||||
const autocompletes = _this.props.autocompletes;
|
if (type !== 'MENTIONS' || !_editorRef) return orig(...args);
|
||||||
|
const autocompletes = _this.state.autocompletes;
|
||||||
const role = autocompletes.roles[selected - autocompletes.users.length - autocompletes.globals.length];
|
const role = autocompletes.roles[selected - autocompletes.users.length - autocompletes.globals.length];
|
||||||
if (!role || !role.MA) return orig(...args);
|
if (!role || !role.MA) return orig(...args);
|
||||||
_this._editorRef.insertAutocomplete(role.mentioned_users, role.mentioned_users_ids);
|
_editorRef.insertAutocomplete(role.mentioned_users, role.mentioned_users_ids);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1081,112 +1078,112 @@ var MentionAliasesRedux = (() => {
|
||||||
|
|
||||||
return !global.ZeresPluginLibrary || !global.XenoLib
|
return !global.ZeresPluginLibrary || !global.XenoLib
|
||||||
? class {
|
? class {
|
||||||
getName() {
|
getName() {
|
||||||
return this.name.replace(/\s+/g, '');
|
return this.name.replace(/\s+/g, '');
|
||||||
}
|
}
|
||||||
getAuthor() {
|
getAuthor() {
|
||||||
return this.author;
|
return this.author;
|
||||||
}
|
}
|
||||||
getVersion() {
|
getVersion() {
|
||||||
return this.version;
|
return this.version;
|
||||||
}
|
}
|
||||||
getDescription() {
|
getDescription() {
|
||||||
return this.description;
|
return this.description;
|
||||||
}
|
}
|
||||||
stop() { }
|
stop() {}
|
||||||
load() {
|
load() {
|
||||||
const XenoLibMissing = !global.XenoLib;
|
const XenoLibMissing = !global.XenoLib;
|
||||||
const zlibMissing = !global.ZeresPluginLibrary;
|
const zlibMissing = !global.ZeresPluginLibrary;
|
||||||
const bothLibsMissing = XenoLibMissing && zlibMissing;
|
const bothLibsMissing = XenoLibMissing && zlibMissing;
|
||||||
const header = `Missing ${(bothLibsMissing && 'Libraries') || 'Library'}`;
|
const header = `Missing ${(bothLibsMissing && 'Libraries') || 'Library'}`;
|
||||||
const content = `The ${(bothLibsMissing && 'Libraries') || 'Library'} ${(zlibMissing && 'ZeresPluginLibrary') || ''} ${(XenoLibMissing && (zlibMissing ? 'and XenoLib' : 'XenoLib')) || ''} required for ${this.name} ${(bothLibsMissing && 'are') || 'is'} missing.`;
|
const content = `The ${(bothLibsMissing && 'Libraries') || 'Library'} ${(zlibMissing && 'ZeresPluginLibrary') || ''} ${(XenoLibMissing && (zlibMissing ? 'and XenoLib' : 'XenoLib')) || ''} required for ${this.name} ${(bothLibsMissing && 'are') || 'is'} missing.`;
|
||||||
const ModalStack = BdApi.findModuleByProps('push', 'update', 'pop', 'popWithKey');
|
const ModalStack = BdApi.findModuleByProps('push', 'update', 'pop', 'popWithKey');
|
||||||
const TextElement = BdApi.findModuleByProps('Sizes', 'Weights');
|
const TextElement = BdApi.findModuleByProps('Sizes', 'Weights');
|
||||||
const ConfirmationModal = BdApi.findModule(m => m.defaultProps && m.key && m.key() === 'confirm-modal');
|
const ConfirmationModal = BdApi.findModule(m => m.defaultProps && m.key && m.key() === 'confirm-modal');
|
||||||
const onFail = () => BdApi.getCore().alert(header, `${content}<br/>Due to a slight mishap however, you'll have to download the libraries yourself. After opening the links, do CTRL + S to download the library.<br/>${(zlibMissing && '<br/><a href="https://rauenzi.github.io/BDPluginLibrary/release/0PluginLibrary.plugin.js"target="_blank">Click here to download ZeresPluginLibrary</a>') || ''}${(zlibMissing && '<br/><a href="http://localhost:7474/XenoLib.js"target="_blank">Click here to download XenoLib</a>') || ''}`);
|
const onFail = () => BdApi.getCore().alert(header, `${content}<br/>Due to a slight mishap however, you'll have to download the libraries yourself. After opening the links, do CTRL + S to download the library.<br/>${(zlibMissing && '<br/><a href="https://rauenzi.github.io/BDPluginLibrary/release/0PluginLibrary.plugin.js"target="_blank">Click here to download ZeresPluginLibrary</a>') || ''}${(zlibMissing && '<br/><a href="http://localhost:7474/XenoLib.js"target="_blank">Click here to download XenoLib</a>') || ''}`);
|
||||||
if (!ModalStack || !ConfirmationModal || !TextElement) return onFail();
|
if (!ModalStack || !ConfirmationModal || !TextElement) return onFail();
|
||||||
ModalStack.push(props => {
|
ModalStack.push(props => {
|
||||||
return BdApi.React.createElement(
|
return BdApi.React.createElement(
|
||||||
ConfirmationModal,
|
ConfirmationModal,
|
||||||
Object.assign(
|
Object.assign(
|
||||||
{
|
{
|
||||||
header,
|
header,
|
||||||
children: [TextElement({ color: TextElement.Colors.PRIMARY, children: [`${content} Please click Download Now to install ${(bothLibsMissing && 'them') || 'it'}.`] })],
|
children: [TextElement({ color: TextElement.Colors.PRIMARY, children: [`${content} Please click Download Now to install ${(bothLibsMissing && 'them') || 'it'}.`] })],
|
||||||
red: false,
|
red: false,
|
||||||
confirmText: 'Download Now',
|
confirmText: 'Download Now',
|
||||||
cancelText: 'Cancel',
|
cancelText: 'Cancel',
|
||||||
onConfirm: () => {
|
onConfirm: () => {
|
||||||
const request = require('request');
|
const request = require('request');
|
||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
const waitForLibLoad = callback => {
|
const waitForLibLoad = callback => {
|
||||||
if (!global.BDEvents) return callback();
|
if (!global.BDEvents) return callback();
|
||||||
const onLoaded = e => {
|
const onLoaded = e => {
|
||||||
if (e !== 'ZeresPluginLibrary') return;
|
if (e !== 'ZeresPluginLibrary') return;
|
||||||
BDEvents.off('plugin-loaded', onLoaded);
|
BDEvents.off('plugin-loaded', onLoaded);
|
||||||
callback();
|
callback();
|
||||||
};
|
};
|
||||||
BDEvents.on('plugin-loaded', onLoaded);
|
BDEvents.on('plugin-loaded', onLoaded);
|
||||||
};
|
};
|
||||||
const onDone = () => {
|
const onDone = () => {
|
||||||
if (!global.pluginModule || (!global.BDEvents && !global.XenoLib)) return;
|
if (!global.pluginModule || (!global.BDEvents && !global.XenoLib)) return;
|
||||||
if (!global.BDEvents || global.XenoLib) pluginModule.reloadPlugin(this.name);
|
if (!global.BDEvents || global.XenoLib) pluginModule.reloadPlugin(this.name);
|
||||||
else {
|
else {
|
||||||
const listener = () => {
|
const listener = () => {
|
||||||
pluginModule.reloadPlugin(this.name);
|
pluginModule.reloadPlugin(this.name);
|
||||||
BDEvents.off('xenolib-loaded', listener);
|
BDEvents.off('xenolib-loaded', listener);
|
||||||
};
|
};
|
||||||
BDEvents.on('xenolib-loaded', listener);
|
BDEvents.on('xenolib-loaded', listener);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
const downloadXenoLib = () => {
|
const downloadXenoLib = () => {
|
||||||
if (global.XenoLib) return onDone();
|
if (global.XenoLib) return onDone();
|
||||||
request('https://raw.githubusercontent.com/1Lighty/BetterDiscordPlugins/master/Plugins/1XenoLib.plugin.js', (error, response, body) => {
|
request('https://raw.githubusercontent.com/1Lighty/BetterDiscordPlugins/master/Plugins/1XenoLib.plugin.js', (error, response, body) => {
|
||||||
if (error) return onFail();
|
if (error) return onFail();
|
||||||
onDone();
|
onDone();
|
||||||
fs.writeFile(path.join(window.ContentManager.pluginsFolder, '1XenoLib.plugin.js'), body, () => { });
|
fs.writeFile(path.join(window.ContentManager.pluginsFolder, '1XenoLib.plugin.js'), body, () => {});
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
if (!global.ZeresPluginLibrary) {
|
if (!global.ZeresPluginLibrary) {
|
||||||
request('https://rauenzi.github.io/BDPluginLibrary/release/0PluginLibrary.plugin.js', (error, response, body) => {
|
request('https://rauenzi.github.io/BDPluginLibrary/release/0PluginLibrary.plugin.js', (error, response, body) => {
|
||||||
if (error) return onFail();
|
if (error) return onFail();
|
||||||
waitForLibLoad(downloadXenoLib);
|
waitForLibLoad(downloadXenoLib);
|
||||||
fs.writeFile(path.join(window.ContentManager.pluginsFolder, '0PluginLibrary.plugin.js'), body, () => { });
|
fs.writeFile(path.join(window.ContentManager.pluginsFolder, '0PluginLibrary.plugin.js'), body, () => {});
|
||||||
});
|
});
|
||||||
} else downloadXenoLib();
|
} else downloadXenoLib();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
props
|
props
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
start() { }
|
start() {}
|
||||||
get [Symbol.toStringTag]() {
|
get [Symbol.toStringTag]() {
|
||||||
return 'Plugin';
|
return 'Plugin';
|
||||||
}
|
}
|
||||||
get name() {
|
get name() {
|
||||||
return config.info.name;
|
return config.info.name;
|
||||||
}
|
}
|
||||||
get short() {
|
get short() {
|
||||||
let string = '';
|
let string = '';
|
||||||
for (let i = 0, len = config.info.name.length; i < len; i++) {
|
for (let i = 0, len = config.info.name.length; i < len; i++) {
|
||||||
const char = config.info.name[i];
|
const char = config.info.name[i];
|
||||||
if (char === char.toUpperCase()) string += char;
|
if (char === char.toUpperCase()) string += char;
|
||||||
|
}
|
||||||
|
return string;
|
||||||
|
}
|
||||||
|
get author() {
|
||||||
|
return config.info.authors.map(author => author.name).join(', ');
|
||||||
|
}
|
||||||
|
get version() {
|
||||||
|
return config.info.version;
|
||||||
|
}
|
||||||
|
get description() {
|
||||||
|
return config.info.description;
|
||||||
}
|
}
|
||||||
return string;
|
|
||||||
}
|
}
|
||||||
get author() {
|
|
||||||
return config.info.authors.map(author => author.name).join(', ');
|
|
||||||
}
|
|
||||||
get version() {
|
|
||||||
return config.info.version;
|
|
||||||
}
|
|
||||||
get description() {
|
|
||||||
return config.info.description;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
: buildPlugin(global.ZeresPluginLibrary.buildPlugin(config));
|
: buildPlugin(global.ZeresPluginLibrary.buildPlugin(config));
|
||||||
})();
|
})();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue