Skip to content

Commit

Permalink
Fix search modal
Browse files Browse the repository at this point in the history
  • Loading branch information
inventionpro committed Oct 30, 2024
1 parent 7eed132 commit 7ba06f1
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 29 deletions.
66 changes: 38 additions & 28 deletions newFsh/interactions/search-modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,67 +23,77 @@ module.exports = {
/* -- Get search term -- */
let term = interaction.fields.getTextInputValue("searchterm");

const prefix = 'fsh!'
let locale = fsh.getLocale(interaction);

let results = [];
let results2 = [];
let done = [];

/* -- Get results for said term -- */
client.textcommands.forEach((command) => {
client.textcommands.forEach(command => {
let commandName = command.name;
if (Array.isArray(commandName)) {
if (done.includes(commandName[0])) {
return;
} else {
done.push(commandName[0])
}
}
let commandInfo = command.info;
let commandCat = command.category; // cat 🐈 reel
let commandCatn =
commandCat + listsRepeat(" ", 8 - commandCat.length).join("");

if (command.slash) {
let inf = locale.get(`commands.${commandName}`);
commandName = inf.name;
commandInfo = inf.info;
}

if (existing_cat.includes(commandCat)) {
/* -- Get parameters -- */
let paramList = [];
var i_inc = 2;
let param = command.params || [];
if (param.length != 0) {
for (i = 0; i <= param.length / 2; i += i_inc) {
if (param[i + 1] == true) {
paramList.push(`<${param[i]}>`);
} else {
paramList.push(`(${param[i]})`);
if (command.slash) {
param = param.map(p => `${p.required ? '<' : '('}${locale.get('commands.'+command.name+'.params.'+p.name+'.name')}${p.required ? '>' : ')'}`).join(' ');
} else {
let paramList = [];
if (param.length != 0) {
for (i = 0; i <= param.length / 2; i += 2) {
if (param[i + 1] == true) {
paramList.push(`<${param[i]}>`);
} else {
paramList.push(`(${param[i]})`);
}
}
}
param = paramList.join(" ");
}
param = paramList.join(" ");
/* -- Join command name if multi alias -- */
if (Array.isArray(commandName)) {
commandName = commandName.join("/");
}

if (commandName.includes(term)) {
results.push(
`${commandCatn} > fsh!${commandName} ${param} - ${commandInfo}`
);
results.push(`*${commandCat}* > **${command.slash ? '/' : prefix}${commandName}** ${param} - ${commandInfo}`);
}
if (commandInfo.includes(term)) {
results2.push(
`${commandCatn} > fsh!${commandName} ${param} - ${commandInfo}`
);
results2.push(`*${commandCat}* > **${command.slash ? '/' : prefix}${commandName}** ${param} - ${commandInfo}`);
}
}
});
/* -- create embed -- */
let color = interaction.message.embeds[0].color;

// o i forgor to make param getter
let embed = new Discord.EmbedBuilder()
.setTitle(`${fsh.emojis.search} Help Menu - Results For "${term}"`)
.setDescription(
`<required>, (not required)
.setDescription(`(optional) - <required>
Name search
> ${results.join("\n> ") || "**Sorry, no commands have that name**"}
> ${results.slice(0,18).join("\n> ") || "**Sorry, no commands have that name**"}
Info Search
> ${results2.join("\n> ") || "**Sorry, no commands with that in their info**"}`
)
> ${results2.slice(0,18).join("\n> ") || "**Sorry, no commands with that in their info**"}`.slice(0,4096))
.setColor(color);

/* -- join/send results -- */
await interaction.update({
embeds: [embed],
embeds: [embed]
});
},
};
}
};
2 changes: 1 addition & 1 deletion text/bad.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
938831934962946170,945843153141911583,1042492981829173299,703405189872353401,1060305202948874403,980363502709530654,1110438615630217257,1108699529395568650,1108473547791290428,265941606035619841,396828331192090625,784977471162155029,1080404723133325392,990494289027018753,989179816873955378,846543119914893394,546917869141884938,989535117150158888,425708102520668173,784849546357768233,973829920025346088,436965815036674079,527604348037890048,615837732190552084,1114811223352016897,945816874938155029,1114247574115864656,961162577302388751,906907112704204820,893967180448821259,1092622262114467941,912881117277876297,1128423275391889490,880283255625113641,738113139295387761,1122818033669394504,1127927100947570708,599945975259201587,1141481803576770630,1137123219661410344,1145111635397193758,1118954109354123306,1118967325765410938,1154067086155468800,601480674670805024,1118969169547894804,972923595506475049,1118930270339473461,1075755980660416612,1165552145559457802,974608074771931166,976700749385990144,988428267562360913,1164461825614692372,159985870458322944,974601085341802508,1007288024658350111,1084182519454388306,376364221128245279,1031230682246160454,973686782837293067,964006257268752454,731772226608824371,498010961102503947,976960121764712478,1195430076595056701,984655808606380082,762076450047131648,1223168494426918914,429628691023134722,1236525969582587938,551360729425641473,558996514119221249,631754347591499786,654794063307866172,657093741823131650,705030473692348426,726171028354498560,726698838881992704,779242486186246155,842024725776695336,853307742651154432,878506828676345896,889243118157848599,889243962441859144,889244104200974386,889245165586358355,889245533288402977,889253631667343431,889255332155650079,889256000211791903,889259838478090272,889262616147554344,889282279304724533,891451407658528839,891451709711351808,891491235058057246,908999657450004480,919203544173785088,919577542829150298,919916564034228256,923436995236233238,925895536425459732,928533002441596968,932083147808596018,955717644969988116,957901669365055518,958095458482397314,963380769391259708,965472860569239622,965820979039318098,967335891410489355,967772286402854932,967784659540922409,967785909045059615,925899287676727348,967787195735875615,973048816951492678,973593889787240479,974638911374647318,975158085649838110,980043139802869810,979284706631761920,981819426263420958,981821046225240075,995744187590922341,1001418778590072933,1019723088675471461,1024235828077133834,1024377776217800876,1024969444511989780,1027158402767540235,1029857317870641252,1029872234782802070,1030046147072507967,1030989378291515524,1032198369222852688,1032521822983430154,1055212720804352100,1063032636500627476,1068710194122608640,1068782292438368266,1089174715156926556,1099130512922116188,1100173698683646042,1110723354232619018,1110855772994285588,1112167835259641917,1127329372911718431,1153763266900803704,1203168493563019337,1217899783969046679,1241345157085921291,771644607070732291,1142500629407875092,845681489958010960,866731936751550535,1253228308817248260,889090864029257790,1236460122088276070,1241768160504451083,868121476027531294
938831934962946170,945843153141911583,1042492981829173299,703405189872353401,1060305202948874403,980363502709530654,1110438615630217257,1108699529395568650,1108473547791290428,265941606035619841,396828331192090625,784977471162155029,1080404723133325392,990494289027018753,989179816873955378,846543119914893394,546917869141884938,989535117150158888,425708102520668173,784849546357768233,973829920025346088,436965815036674079,527604348037890048,615837732190552084,1114811223352016897,945816874938155029,1114247574115864656,961162577302388751,906907112704204820,893967180448821259,1092622262114467941,912881117277876297,1128423275391889490,880283255625113641,738113139295387761,1122818033669394504,1127927100947570708,599945975259201587,1141481803576770630,1137123219661410344,1145111635397193758,1118954109354123306,1118967325765410938,1154067086155468800,601480674670805024,1118969169547894804,972923595506475049,1118930270339473461,1075755980660416612,1165552145559457802,974608074771931166,976700749385990144,988428267562360913,1164461825614692372,159985870458322944,974601085341802508,1007288024658350111,1084182519454388306,376364221128245279,1031230682246160454,973686782837293067,964006257268752454,731772226608824371,498010961102503947,976960121764712478,1195430076595056701,984655808606380082,762076450047131648,1223168494426918914,429628691023134722,1236525969582587938,551360729425641473,558996514119221249,631754347591499786,654794063307866172,657093741823131650,705030473692348426,726171028354498560,726698838881992704,779242486186246155,842024725776695336,853307742651154432,878506828676345896,889243118157848599,889243962441859144,889244104200974386,889245165586358355,889245533288402977,889253631667343431,889255332155650079,889256000211791903,889259838478090272,889262616147554344,889282279304724533,891451407658528839,891451709711351808,891491235058057246,908999657450004480,919203544173785088,919577542829150298,919916564034228256,923436995236233238,925895536425459732,928533002441596968,932083147808596018,955717644969988116,957901669365055518,958095458482397314,963380769391259708,965472860569239622,965820979039318098,967335891410489355,967772286402854932,967784659540922409,967785909045059615,925899287676727348,967787195735875615,973048816951492678,973593889787240479,974638911374647318,975158085649838110,980043139802869810,979284706631761920,981819426263420958,981821046225240075,995744187590922341,1001418778590072933,1019723088675471461,1024235828077133834,1024377776217800876,1024969444511989780,1027158402767540235,1029857317870641252,1029872234782802070,1030046147072507967,1030989378291515524,1032198369222852688,1032521822983430154,1055212720804352100,1063032636500627476,1068710194122608640,1068782292438368266,1089174715156926556,1099130512922116188,1100173698683646042,1110723354232619018,1110855772994285588,1112167835259641917,1127329372911718431,1153763266900803704,1203168493563019337,1217899783969046679,1241345157085921291,771644607070732291,1142500629407875092,845681489958010960,866731936751550535,1253228308817248260,889090864029257790,1236460122088276070,1241768160504451083,868121476027531294,1297965381880778811

0 comments on commit 7ba06f1

Please sign in to comment.