Update SplitLargeMessages.plugin.js
This commit is contained in:
parent
eac4748ffd
commit
fe96b66c2d
|
@ -2,7 +2,7 @@
|
||||||
* @name SplitLargeMessages
|
* @name SplitLargeMessages
|
||||||
* @author DevilBro
|
* @author DevilBro
|
||||||
* @authorId 278543574059057154
|
* @authorId 278543574059057154
|
||||||
* @version 1.8.0
|
* @version 1.8.1
|
||||||
* @description Allows you to enter larger Messages, which will automatically split into several smaller Messages
|
* @description Allows you to enter larger Messages, which will automatically split into several smaller Messages
|
||||||
* @invite Jx3TjNS
|
* @invite Jx3TjNS
|
||||||
* @donate https://www.paypal.me/MircoWittrien
|
* @donate https://www.paypal.me/MircoWittrien
|
||||||
|
@ -56,7 +56,7 @@ module.exports = (_ => {
|
||||||
return template.content.firstElementChild;
|
return template.content.firstElementChild;
|
||||||
}
|
}
|
||||||
} : (([Plugin, BDFDB]) => {
|
} : (([Plugin, BDFDB]) => {
|
||||||
const messageDelay = 1000; //changing at own risk, might result in bans or mutes
|
const messageDelay = 2000; //changing at own risk, might result in bans or mutes
|
||||||
let maxMessageLength = 2000;
|
let maxMessageLength = 2000;
|
||||||
|
|
||||||
return class SplitLargeMessages extends Plugin {
|
return class SplitLargeMessages extends Plugin {
|
||||||
|
@ -67,7 +67,7 @@ module.exports = (_ => {
|
||||||
},
|
},
|
||||||
amounts: {
|
amounts: {
|
||||||
splitCounter: {value: 0, description: "Messages will be split after roughly X Characters"},
|
splitCounter: {value: 0, description: "Messages will be split after roughly X Characters"},
|
||||||
maxPages: { value: 0, description: 'Maximum number of split pages', note: "(0 for unlimited) Pages beyond this count will be discarded" }
|
maxPages: {value: 0, description: "Maximum number of split pages", note: "(0 for unlimited) Pages beyond this count will be discarded"}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -132,21 +132,19 @@ module.exports = (_ => {
|
||||||
value: this.settings.amounts.splitCounter < 1000 || this.settings.amounts.splitCounter > maxMessageLength ? maxMessageLength : this.settings.amounts.splitCounter
|
value: this.settings.amounts.splitCounter < 1000 || this.settings.amounts.splitCounter > maxMessageLength ? maxMessageLength : this.settings.amounts.splitCounter
|
||||||
}));
|
}));
|
||||||
|
|
||||||
settingsItems.push(
|
settingsItems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsSaveItem, {
|
||||||
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsSaveItem, {
|
type: "TextInput",
|
||||||
type: 'TextInput',
|
childProps: {
|
||||||
childProps: {
|
type: "number"
|
||||||
type: 'number'
|
},
|
||||||
},
|
plugin: this,
|
||||||
plugin: this,
|
keys: ["amounts", "maxPages"],
|
||||||
keys: ['amounts', 'maxPages'],
|
label: this.defaults.amounts.maxPages.description,
|
||||||
label: this.defaults.amounts.maxPages.description,
|
note: this.defaults.amounts.maxPages.note,
|
||||||
note: this.defaults.amounts.maxPages.note,
|
min: 0,
|
||||||
min: 0,
|
max: 20,
|
||||||
max: 20,
|
value: this.settings.amounts.splitCounter
|
||||||
value: this.settings.amounts.splitCounter
|
}));
|
||||||
})
|
|
||||||
);
|
|
||||||
|
|
||||||
return settingsItems;
|
return settingsItems;
|
||||||
}
|
}
|
||||||
|
@ -196,7 +194,7 @@ module.exports = (_ => {
|
||||||
}
|
}
|
||||||
|
|
||||||
processChannelTextAreaEditor (e) {
|
processChannelTextAreaEditor (e) {
|
||||||
if (e.instance.props.type == BDFDB.DiscordConstants.ChannelTextAreaTypes.NORMAL || e.instance.props.type == BDFDB.DiscordConstants.ChannelTextAreaTypes.NORMAL_WITH_ACTIVITY || e.instance.props.type == BDFDB.LibraryComponents.ChannelTextAreaTypes.SIDEBAR) e.instance.props.uploadPromptCharacterCount = 999999999999999;
|
if (e.instance.props.type == BDFDB.DiscordConstants.ChannelTextAreaTypes.NORMAL || e.instance.props.type == BDFDB.DiscordConstants.ChannelTextAreaTypes.NORMAL_WITH_ACTIVITY || e.instance.props.type == BDFDB.LibraryComponents.ChannelTextAreaTypes.SIDEBAR) e.instance.props.uploadPromptCharacterCount = 100000;
|
||||||
}
|
}
|
||||||
|
|
||||||
isSlowDowned (channel) {
|
isSlowDowned (channel) {
|
||||||
|
@ -206,7 +204,7 @@ module.exports = (_ => {
|
||||||
formatText (text) {
|
formatText (text) {
|
||||||
const separator = !this.settings.general.byNewlines ? "\n" : " ";
|
const separator = !this.settings.general.byNewlines ? "\n" : " ";
|
||||||
const splitMessageLength = this.settings.amounts.splitCounter < 1000 || this.settings.amounts.splitCounter > maxMessageLength ? maxMessageLength : this.settings.amounts.splitCounter;
|
const splitMessageLength = this.settings.amounts.splitCounter < 1000 || this.settings.amounts.splitCounter > maxMessageLength ? maxMessageLength : this.settings.amounts.splitCounter;
|
||||||
const maxPages = this.settings.amounts.maxPages || Infinity;
|
const maxPages = this.settings.amounts.maxPages || Infinity;
|
||||||
|
|
||||||
text = text.replace(/\t/g, " ");
|
text = text.replace(/\t/g, " ");
|
||||||
let longWords = text.match(new RegExp(`[^${separator.replace("\n", "\\n")}]{${splitMessageLength * (19/20)},}`, "gm"));
|
let longWords = text.match(new RegExp(`[^${separator.replace("\n", "\\n")}]{${splitMessageLength * (19/20)},}`, "gm"));
|
||||||
|
|
Loading…
Reference in New Issue