stuff
This commit is contained in:
parent
f7a8a5e22f
commit
6c147cb110
|
@ -2,7 +2,7 @@
|
||||||
* @name ChatAliases
|
* @name ChatAliases
|
||||||
* @author DevilBro
|
* @author DevilBro
|
||||||
* @authorId 278543574059057154
|
* @authorId 278543574059057154
|
||||||
* @version 2.3.0
|
* @version 2.3.1
|
||||||
* @description Allows you to configure your own Aliases/Commands
|
* @description Allows you to configure your own Aliases/Commands
|
||||||
* @invite Jx3TjNS
|
* @invite Jx3TjNS
|
||||||
* @donate https://www.paypal.me/MircoWittrien
|
* @donate https://www.paypal.me/MircoWittrien
|
||||||
|
@ -17,12 +17,12 @@ module.exports = (_ => {
|
||||||
"info": {
|
"info": {
|
||||||
"name": "ChatAliases",
|
"name": "ChatAliases",
|
||||||
"author": "DevilBro",
|
"author": "DevilBro",
|
||||||
"version": "2.3.0",
|
"version": "2.3.1",
|
||||||
"description": "Allows you to configure your own Aliases/Commands"
|
"description": "Allows you to configure your own Aliases/Commands"
|
||||||
},
|
},
|
||||||
"changeLog": {
|
"changeLog": {
|
||||||
"improved": {
|
"improved": {
|
||||||
"Case Equalization": "Equalizes the case for case insensitive non-regex Aliases (Thats becomes That's not that's)"
|
"Autocomplete Menu": ""
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -73,7 +73,9 @@ module.exports = (_ => {
|
||||||
return template.content.firstElementChild;
|
return template.content.firstElementChild;
|
||||||
}
|
}
|
||||||
} : (([Plugin, BDFDB]) => {
|
} : (([Plugin, BDFDB]) => {
|
||||||
var aliases = {}, commandAliases = {}, commandSentinel;
|
var aliases = {}, commandSentinel;
|
||||||
|
|
||||||
|
const AUTOCOMPLETE_ALIAS_OPTION = "ALIASES";
|
||||||
|
|
||||||
return class ChatAliases extends Plugin {
|
return class ChatAliases extends Plugin {
|
||||||
onLoad () {
|
onLoad () {
|
||||||
|
@ -113,7 +115,7 @@ module.exports = (_ => {
|
||||||
|
|
||||||
this.css = `
|
this.css = `
|
||||||
${BDFDB.dotCNS.aliasautocomplete + BDFDB.dotCN.autocompleteinner} {
|
${BDFDB.dotCNS.aliasautocomplete + BDFDB.dotCN.autocompleteinner} {
|
||||||
max-height: 50vh;
|
max-height: 480px;
|
||||||
}
|
}
|
||||||
${BDFDB.dotCN.autocompleteicon} {
|
${BDFDB.dotCN.autocompleteicon} {
|
||||||
flex: 0 0 auto;
|
flex: 0 0 auto;
|
||||||
|
@ -124,10 +126,10 @@ module.exports = (_ => {
|
||||||
onStart () {
|
onStart () {
|
||||||
aliases = BDFDB.DataUtils.load(this, "words");
|
aliases = BDFDB.DataUtils.load(this, "words");
|
||||||
commandSentinel = BDFDB.LibraryModules.AutocompleteSentinels && BDFDB.LibraryModules.AutocompleteSentinels.COMMAND_SENTINEL || "/";
|
commandSentinel = BDFDB.LibraryModules.AutocompleteSentinels && BDFDB.LibraryModules.AutocompleteSentinels.COMMAND_SENTINEL || "/";
|
||||||
commandAliases = BDFDB.ObjectUtils.filter(aliases, key => key.startsWith(commandSentinel), true);
|
|
||||||
|
|
||||||
|
if (BDFDB.LibraryModules.AutocompleteOptions && BDFDB.LibraryModules.AutocompleteOptions.AUTOCOMPLETE_PRIORITY) BDFDB.LibraryModules.AutocompleteOptions.AUTOCOMPLETE_PRIORITY.unshift(AUTOCOMPLETE_ALIAS_OPTION);
|
||||||
if (BDFDB.LibraryModules.AutocompleteOptions && BDFDB.LibraryModules.AutocompleteOptions.AUTOCOMPLETE_OPTIONS) {
|
if (BDFDB.LibraryModules.AutocompleteOptions && BDFDB.LibraryModules.AutocompleteOptions.AUTOCOMPLETE_OPTIONS) {
|
||||||
BDFDB.LibraryModules.AutocompleteOptions.AUTOCOMPLETE_OPTIONS.ALIASES = {
|
BDFDB.LibraryModules.AutocompleteOptions.AUTOCOMPLETE_OPTIONS[AUTOCOMPLETE_ALIAS_OPTION] = {
|
||||||
autoSelect: true,
|
autoSelect: true,
|
||||||
getPlainText: (eventOrIndex, config, autocompletes) => {
|
getPlainText: (eventOrIndex, config, autocompletes) => {
|
||||||
let aliasData = eventOrIndex._targetInst ? eventOrIndex._targetInst.memoizedProps.alias : typeof eventOrIndex == "number" && autocompletes.aliases[eventOrIndex];
|
let aliasData = eventOrIndex._targetInst ? eventOrIndex._targetInst.memoizedProps.alias : typeof eventOrIndex == "number" && autocompletes.aliases[eventOrIndex];
|
||||||
|
@ -137,56 +139,52 @@ module.exports = (_ => {
|
||||||
let aliasData = eventOrIndex._targetInst ? eventOrIndex._targetInst.memoizedProps.alias : typeof eventOrIndex == "number" && autocompletes.aliases[eventOrIndex];
|
let aliasData = eventOrIndex._targetInst ? eventOrIndex._targetInst.memoizedProps.alias : typeof eventOrIndex == "number" && autocompletes.aliases[eventOrIndex];
|
||||||
return aliasData.file ? aliasData.word : BDFDB.StringUtils.insertNRST(aliasData.replace);
|
return aliasData.file ? aliasData.word : BDFDB.StringUtils.insertNRST(aliasData.replace);
|
||||||
},
|
},
|
||||||
getSentinel: _ => {
|
getSentinel: _ => "",
|
||||||
return "";
|
matches: (channel, guild, currentWord, _, config) => {
|
||||||
},
|
if (currentWord.length >= this.settings.amounts.minAliasLength) for (let word in aliases) {
|
||||||
matches: (channel, what, wordLowercase, what2, config, rawValue) => {
|
|
||||||
let currentLastWord = BDFDB.StringUtils.findMatchCaseless(wordLowercase, rawValue, true);
|
|
||||||
if (currentLastWord.length >= this.settings.amounts.minAliasLength) for (let word in aliases) {
|
|
||||||
let aliasData = aliases[word];
|
let aliasData = aliases[word];
|
||||||
if (!aliasData.regex && aliasData.autoc) {
|
if (!aliasData.regex && aliasData.autoc) {
|
||||||
if (aliasData.exact) {
|
if (aliasData.exact) {
|
||||||
if (aliasData.case && word.indexOf(currentLastWord) == 0) return true;
|
if (aliasData.case && word.indexOf(currentWord) == 0) return true;
|
||||||
else if (!aliasData.case && word.toLowerCase().indexOf(currentLastWord.toLowerCase()) == 0) return true;
|
else if (!aliasData.case && word.toLowerCase().indexOf(currentWord.toLowerCase()) == 0) return true;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (aliasData.case && word.indexOf(currentLastWord) > -1) return true;
|
if (aliasData.case && word.indexOf(currentWord) > -1) return true;
|
||||||
else if (!aliasData.case && word.toLowerCase().indexOf(currentLastWord.toLowerCase()) > -1) return true;
|
else if (!aliasData.case && word.toLowerCase().indexOf(currentWord.toLowerCase()) > -1) return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
},
|
},
|
||||||
queryResults: (channel, wordLowercase, config, rawValue) => {
|
queryResults: (channel, guild, currentWord, config) => {
|
||||||
if (rawValue == commandSentinel) return;
|
if (currentWord == commandSentinel) return;
|
||||||
let currentLastWord = BDFDB.StringUtils.findMatchCaseless(wordLowercase, rawValue, true);
|
|
||||||
let matches = [];
|
let matches = [];
|
||||||
for (let word in aliases) {
|
for (let word in aliases) {
|
||||||
let aliasData = Object.assign({word}, aliases[word]);
|
let aliasData = Object.assign({word}, aliases[word]);
|
||||||
if (!aliasData.regex && aliasData.autoc) {
|
if (!aliasData.regex && aliasData.autoc) {
|
||||||
if (aliasData.exact) {
|
if (aliasData.exact) {
|
||||||
if (aliasData.case && word.indexOf(currentLastWord) == 0) matches.push(aliasData);
|
if (aliasData.case && word.indexOf(currentWord) == 0) matches.push(aliasData);
|
||||||
else if (!aliasData.case && word.toLowerCase().indexOf(currentLastWord.toLowerCase()) == 0) matches.push(aliasData);
|
else if (!aliasData.case && word.toLowerCase().indexOf(currentWord.toLowerCase()) == 0) matches.push(aliasData);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (aliasData.case && word.indexOf(currentLastWord) > -1) matches.push(aliasData);
|
if (aliasData.case && word.indexOf(currentWord) > -1) matches.push(aliasData);
|
||||||
else if (!aliasData.case && word.toLowerCase().indexOf(currentLastWord.toLowerCase()) > -1) matches.push(aliasData);
|
else if (!aliasData.case && word.toLowerCase().indexOf(currentWord.toLowerCase()) > -1) matches.push(aliasData);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (matches.length) return {aliases: matches};
|
if (matches.length) return {results: {aliases: matches}};
|
||||||
},
|
},
|
||||||
renderResults: (channel, wordLowercase, currentSelected, setSelected, chooseSelected, state, config, autocompletes) => {
|
renderResults: (results, currentSelected, channel, guild, currenWord, config, setSelected, chooseSelected) => {
|
||||||
return autocompletes && autocompletes.aliases && [
|
return results && results.aliases && [
|
||||||
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.AutocompleteItems.Title, {
|
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.AutocompleteItems.Title, {
|
||||||
title: [
|
title: [
|
||||||
"Aliases: ",
|
"Aliases: ",
|
||||||
BDFDB.ReactUtils.createElement("strong", {
|
BDFDB.ReactUtils.createElement("strong", {
|
||||||
children: wordLowercase
|
children: currenWord
|
||||||
})
|
})
|
||||||
]
|
]
|
||||||
}),
|
}),
|
||||||
autocompletes.aliases.map((aliasData, i) => BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.AutocompleteItems.Generic, {
|
results.aliases.map((aliasData, i) => BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.AutocompleteItems.Generic, {
|
||||||
onClick: chooseSelected,
|
onClick: chooseSelected,
|
||||||
onHover: setSelected,
|
onHover: setSelected,
|
||||||
index: i,
|
index: i,
|
||||||
|
@ -198,40 +196,14 @@ module.exports = (_ => {
|
||||||
].flat(10).filter(n => n);
|
].flat(10).filter(n => n);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
BDFDB.PatchUtils.patch(this, BDFDB.LibraryModules.AutocompleteOptions.AUTOCOMPLETE_OPTIONS.COMMANDS, "renderResults", {before: e => {
|
|
||||||
let m = Array.from(e.methodArguments).find(n => n && n.commands);
|
|
||||||
if (m) {
|
|
||||||
let currentLastWord = commandSentinel + e.methodArguments[1];
|
|
||||||
if (currentLastWord.length >= this.settings.amounts.minAliasLength) for (let word in commandAliases) {
|
|
||||||
let aliasData = commandAliases[word];
|
|
||||||
let name = word.slice(1);
|
|
||||||
let command = {
|
|
||||||
id: "chatalias-" + name,
|
|
||||||
name: name,
|
|
||||||
description: BDFDB.StringUtils.insertNRST(aliasData.replace)
|
|
||||||
};
|
|
||||||
if (!aliasData.regex && aliasData.autoc) {
|
|
||||||
if (aliasData.exact) {
|
|
||||||
if (aliasData.case && word.indexOf(currentLastWord) == 0) m.commands.push(command);
|
|
||||||
else if (!aliasData.case && word.toLowerCase().indexOf(currentLastWord.toLowerCase()) == 0) m.commands.push(command);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
if (aliasData.case && word.indexOf(currentLastWord) > -1) m.commands.push(command);
|
|
||||||
else if (!aliasData.case && word.toLowerCase().indexOf(currentLastWord.toLowerCase()) > -1) m.commands.push(command);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
BDFDB.PatchUtils.forceAllUpdates(this);
|
BDFDB.PatchUtils.forceAllUpdates(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
onStop () {
|
onStop () {
|
||||||
if (BDFDB.LibraryModules.AutocompleteOptions && BDFDB.LibraryModules.AutocompleteOptions.AUTOCOMPLETE_OPTIONS) {
|
if (BDFDB.LibraryModules.AutocompleteOptions && BDFDB.LibraryModules.AutocompleteOptions.AUTOCOMPLETE_PRIORITY) BDFDB.ArrayUtils.remove(BDFDB.LibraryModules.AutocompleteOptions.AUTOCOMPLETE_PRIORITY, AUTOCOMPLETE_ALIAS_OPTION, true);
|
||||||
delete BDFDB.LibraryModules.AutocompleteOptions.AUTOCOMPLETE_OPTIONS.ALIASES;
|
if (BDFDB.LibraryModules.AutocompleteOptions && BDFDB.LibraryModules.AutocompleteOptions.AUTOCOMPLETE_OPTIONS) delete BDFDB.LibraryModules.AutocompleteOptions.AUTOCOMPLETE_OPTIONS[AUTOCOMPLETE_ALIAS_OPTION];
|
||||||
}
|
|
||||||
BDFDB.PatchUtils.forceAllUpdates(this);
|
BDFDB.PatchUtils.forceAllUpdates(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -353,7 +325,6 @@ module.exports = (_ => {
|
||||||
onClick: _ => {
|
onClick: _ => {
|
||||||
BDFDB.ModalUtils.confirm(this, "Are you sure you want to remove all added Aliases?", _ => {
|
BDFDB.ModalUtils.confirm(this, "Are you sure you want to remove all added Aliases?", _ => {
|
||||||
aliases = {};
|
aliases = {};
|
||||||
commandAliases = {};
|
|
||||||
BDFDB.DataUtils.remove(this, "words");
|
BDFDB.DataUtils.remove(this, "words");
|
||||||
BDFDB.PluginUtils.refreshSettingsPanel(this, settingsPanel, collapseStates);
|
BDFDB.PluginUtils.refreshSettingsPanel(this, settingsPanel, collapseStates);
|
||||||
});
|
});
|
||||||
|
@ -441,13 +412,6 @@ module.exports = (_ => {
|
||||||
}}, {force: true, noCache: true});
|
}}, {force: true, noCache: true});
|
||||||
}
|
}
|
||||||
|
|
||||||
processAutocomplete (e) {
|
|
||||||
if (e.returnvalue.props.children && e.instance.props.className && e.instance.props.className.indexOf(BDFDB.disCN.aliasautocomplete) > -1) {
|
|
||||||
let [children, index] = BDFDB.ReactUtils.findParent(e.returnvalue, {props: [["className", BDFDB.disCN.autocompleteinner]]});
|
|
||||||
if (index > -1) children[index] = BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Scrollers.Thin, children[index].props);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
handleSubmit (e, e2, textIndex) {
|
handleSubmit (e, e2, textIndex) {
|
||||||
if (!this.settings.general.replaceBeforeSend || BDFDB.LibraryModules.SlowmodeUtils.getSlowmodeCooldownGuess(e.instance.props.channel.id) > 0) return;
|
if (!this.settings.general.replaceBeforeSend || BDFDB.LibraryModules.SlowmodeUtils.getSlowmodeCooldownGuess(e.instance.props.channel.id) > 0) return;
|
||||||
let messageData = this.formatText(e2.methodArguments[textIndex]);
|
let messageData = this.formatText(e2.methodArguments[textIndex]);
|
||||||
|
|
|
@ -5,10 +5,10 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
.sidebarRegion-VFTUkN {
|
.sidebarRegion-VFTUkN {
|
||||||
flex-basis: calc(218px + (var(--usesettingsicons)*(var(--settingsiconssize)+var(--settingsiconsgap))));
|
flex-basis: calc(218px + (var(--usesettingsicons) * (var(--settingsiconssize) + var(--settingsiconsgap))));
|
||||||
}
|
}
|
||||||
.sidebar-CFHs9e {
|
.sidebar-CFHs9e {
|
||||||
width: calc(218px + (var(--usesettingsicons)*(var(--settingsiconssize)+var(--settingsiconsgap))));
|
width: calc(218px + (var(--usesettingsicons) * (var(--settingsiconssize) + var(--settingsiconsgap))));
|
||||||
}
|
}
|
||||||
#bd-settings-sidebar .ui-tab-bar-item,
|
#bd-settings-sidebar .ui-tab-bar-item,
|
||||||
.sidebar-CFHs9e .side-8zPYf6 .item-PXvHYJ {
|
.sidebar-CFHs9e .side-8zPYf6 .item-PXvHYJ {
|
||||||
|
@ -20,9 +20,9 @@
|
||||||
content: "";
|
content: "";
|
||||||
position: relative;
|
position: relative;
|
||||||
flex: 0 0 auto;
|
flex: 0 0 auto;
|
||||||
width: calc(var(--usesettingsicons)*var(--settingsiconssize));
|
width: calc(var(--usesettingsicons) * var(--settingsiconssize));
|
||||||
height: calc(var(--usesettingsicons)*var(--settingsiconssize));
|
height: calc(var(--usesettingsicons) * var(--settingsiconssize));
|
||||||
margin-right: calc(var(--usesettingsicons)*var(--settingsiconsgap));
|
margin-right: calc(var(--usesettingsicons) * var(--settingsiconsgap));
|
||||||
background: currentColor;
|
background: currentColor;
|
||||||
-webkit-mask: url(https://mwittrien.github.io/BetterDiscordAddons/Themes/_res/svgs/settingsicons/questionmark.svg) center/contain no-repeat;
|
-webkit-mask: url(https://mwittrien.github.io/BetterDiscordAddons/Themes/_res/svgs/settingsicons/questionmark.svg) center/contain no-repeat;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue