no idea wtf is happening

This commit is contained in:
night0721 2022-01-23 09:06:11 +08:00
parent 6e8fbe15e7
commit 9db31abc02
5 changed files with 655 additions and 664 deletions

View file

@ -1,6 +1,6 @@
const common = require("../../util/functions/common"); const common = require("../../util/functions/common");
const data = require("../../util/Data/data.json"); const data = require("../../util/Data/data.json");
const Discord = require("discord.js"); const { MessageEmbed } = require("discord.js");
let currGun, let currGun,
currStats, currStats,
@ -52,12 +52,15 @@ module.exports = {
}, },
], ],
run: async (client, interaction, args) => { run: async (client, interaction, args) => {
repEmb = null;
recoilAvailable = false; recoilAvailable = false;
hasError = false; hasError = false;
console.log(args); if (args.length == 1)
const repEmb = statsHandler(args.join(" ").replace("\n", " ")); repEmb = statsHandler(args.join(" ").replace("\n", " "));
else repEmb = statsHandler(args.join(" + ").replace("\n", " "));
if (hasError) { if (hasError) {
interaction.followUp({ embeds: [repEmb] }); interaction.followUp({ embeds: [new MessageEmbed(repEmb)] });
} }
if (recoilAvailable) { if (recoilAvailable) {
repEmb.fields.push({ repEmb.fields.push({
@ -68,7 +71,7 @@ module.exports = {
const recoilImageLink = await chart.getShortUrl(); const recoilImageLink = await chart.getShortUrl();
repEmb.image = { url: recoilImageLink }; repEmb.image = { url: recoilImageLink };
} }
interaction.followUp({ embeds: [repEmb] }); interaction.followUp({ embeds: [new MessageEmbed(repEmb)] });
}, },
}; };

View file

@ -1,7 +1,8 @@
const { HTTPError, DiscordAPIError } = require("discord.js");
const NYX = require("./client/NYX"); const NYX = require("./client/NYX");
const client = new NYX(); const client = new NYX();
module.exports = client; module.exports = client;
process.on("unhandledRejection", err => { process.on("unhandledRejection", err => {
console.log(err); console.error(err);
}); });
client.start(); client.start();

View file

@ -166,7 +166,7 @@ module.exports = {
inline: false, inline: false,
} }
) )
.setThumbnail(`${d.preview}`) .setThumbnail(d.preview)
.setFooter(`Made by ${client.author}`, client.user.displayAvatarURL()) .setFooter(`Made by ${client.author}`, client.user.displayAvatarURL())
.setColor( .setColor(
d.type == "lethal" d.type == "lethal"

12
util/dist/handler.js vendored
View file

@ -1,3 +1,4 @@
const { DiscordAPIError, HTTPError } = require("discord.js");
const fs = require("fs"); const fs = require("fs");
const cmds = []; const cmds = [];
const ownercmds = []; const ownercmds = [];
@ -30,7 +31,9 @@ module.exports = async client => {
client.on("ready", async () => { client.on("ready", async () => {
const gg = client.guilds.cache.get("840225563193114624"); const gg = client.guilds.cache.get("840225563193114624");
await gg.commands.set(ownercmds); await gg.commands.set(ownercmds);
await client.application.commands.set(cmds).then(async cmd => { await client.application.commands
.set(cmds)
.then(async cmd => {
client.guilds.cache.forEach(g => { client.guilds.cache.forEach(g => {
const getroles = name => { const getroles = name => {
const perms = cmds.find(n => n.name == name).UserPerms; const perms = cmds.find(n => n.name == name).UserPerms;
@ -47,10 +50,9 @@ module.exports = async client => {
}, []); }, []);
return [...accumulator, { id: v.id, permissions }]; return [...accumulator, { id: v.id, permissions }];
}, []); }, []);
try { g.commands.permissions.set({ fullPermissions }).catch(null);
g.commands.permissions.set({ fullPermissions });
} catch {}
});
}); });
})
.catch(null);
}); });
}; };

View file

@ -65,7 +65,7 @@ function inpFixer(inpmsg) {
(parts[1] ? ", " : " + ") + (parts[1] ? ", " : " + ") +
nmDt.attachmentActualName[0][i]; nmDt.attachmentActualName[0][i];
} }
}), })
); );
return inpmsg; return inpmsg;
} }
@ -107,8 +107,7 @@ function weaponIdentifier(inpmsg) {
for (let i = 0; i < data.cguns.length; i++) { for (let i = 0; i < data.cguns.length; i++) {
if (inpWeaponName.Simplify() == data.cguns[i].gunname.Simplify()) { if (inpWeaponName.Simplify() == data.cguns[i].gunname.Simplify()) {
return JSON.parse(JSON.stringify(data.cguns[i])); return JSON.parse(JSON.stringify(data.cguns[i]));
} } else if (
else if (
data.cguns[i].gunname.Simplify().includes(inpWeaponName.Simplify()) data.cguns[i].gunname.Simplify().includes(inpWeaponName.Simplify())
) { ) {
probableWeapons.push(i); probableWeapons.push(i);
@ -142,7 +141,7 @@ function weaponIdentifier(inpmsg) {
probableWeapons probableWeapons
.map(x => data.cguns[x].gunname) .map(x => data.cguns[x].gunname)
.reduce((out, x, i) => .reduce((out, x, i) =>
[out, x].join(i === probableWeapons.length - 1 ? "` or `" : "`, `"), [out, x].join(i === probableWeapons.length - 1 ? "` or `" : "`, `")
) + ) +
"`?" "`?"
); );
@ -205,7 +204,7 @@ function attachmentsIdentifier(inpmsg, attachmentsData, inpStats) {
for (let i3 = 0; i3 < splitInputAttachmentsName.length; i3++) { for (let i3 = 0; i3 < splitInputAttachmentsName.length; i3++) {
if ( if (
splitAttachmentsDataName[j][i2].includes( splitAttachmentsDataName[j][i2].includes(
splitInputAttachmentsName[i3].Simplify(), splitInputAttachmentsName[i3].Simplify()
) )
) { ) {
let probablePushed = false; let probablePushed = false;
@ -229,13 +228,13 @@ function attachmentsIdentifier(inpmsg, attachmentsData, inpStats) {
(inputAttachmentsNames[i].includes(" rounds mag") || (inputAttachmentsNames[i].includes(" rounds mag") ||
inputAttachmentsNames[i].includes(" round mag")) && inputAttachmentsNames[i].includes(" round mag")) &&
inputAttachmentsNames[i].startsWith( inputAttachmentsNames[i].startsWith(
inputAttachmentsNames[i].replace(/\D/g, ""), inputAttachmentsNames[i].replace(/\D/g, "")
) )
) { ) {
var tmp1 = parseInt(inputAttachmentsNames[i]); var tmp1 = parseInt(inputAttachmentsNames[i]);
const tmp2 = attachmentsData.filter( const tmp2 = attachmentsData.filter(
x => x =>
x.type === 8 && x.effects[27] + x.effects[28] + inpStats[17] === tmp1, x.type === 8 && x.effects[27] + x.effects[28] + inpStats[17] === tmp1
); );
if (tmp2.length === 1) { if (tmp2.length === 1) {
outAttachments.push(tmp2[0]); outAttachments.push(tmp2[0]);
@ -254,8 +253,8 @@ function attachmentsIdentifier(inpmsg, attachmentsData, inpStats) {
if (x.Simplify() === z.Simplify()) { if (x.Simplify() === z.Simplify()) {
splitInputAttachmentsName[i5] = nmDt.attachmentActualName[1][i6]; splitInputAttachmentsName[i5] = nmDt.attachmentActualName[1][i6];
} }
}), })
), )
); );
splitInputAttachmentsName = splitInputAttachmentsName splitInputAttachmentsName = splitInputAttachmentsName
.join(" ") .join(" ")
@ -284,19 +283,17 @@ function attachmentsIdentifier(inpmsg, attachmentsData, inpStats) {
const temp1 = probables[probables.length - 1].filter( const temp1 = probables[probables.length - 1].filter(
x => x =>
attachmentsData[x].name.Simplify() == attachmentsData[x].name.Simplify() ==
inputAttachmentsNames[i].Simplify(), inputAttachmentsNames[i].Simplify()
); );
const temp2 = probables[probables.length - 1].filter( const temp2 = probables[probables.length - 1].filter(
x => x =>
splitAttachmentsDataName[x].length == splitInputAttachmentsName.length, splitAttachmentsDataName[x].length == splitInputAttachmentsName.length
); );
/**/ if (temp1.length === 1 && temp2.length !== 1) { /**/ if (temp1.length === 1 && temp2.length !== 1) {
probables.push([temp1]); probables.push([temp1]);
} } else if (temp1.length !== 1 && temp2.length === 1) {
else if (temp1.length !== 1 && temp2.length === 1) {
probables.push([temp2]); probables.push([temp2]);
} } else if (
else if (
temp1.length === 1 && temp1.length === 1 &&
temp2.length === 1 && temp2.length === 1 &&
temp1[0] == temp2[0] temp1[0] == temp2[0]
@ -312,11 +309,11 @@ function attachmentsIdentifier(inpmsg, attachmentsData, inpStats) {
curr curr
.map(x => attachmentsData[x].name) .map(x => attachmentsData[x].name)
.reduce((out, x, i) => .reduce((out, x, i) =>
[out, x].join(i === curr.length - 1 ? "` or `" : "`, `"), [out, x].join(i === curr.length - 1 ? "` or `" : "`, `")
) + ) +
'` by `"' + '` by `"' +
inputAttachmentsNames[i] + inputAttachmentsNames[i] +
'"`', '"`'
); );
} }
outAttachments.push(attachmentsData[probables[probables.length - 1][0]]); outAttachments.push(attachmentsData[probables[probables.length - 1][0]]);
@ -330,7 +327,7 @@ function attachmentsIdentifier(inpmsg, attachmentsData, inpStats) {
.toString() .toString()
.split("") .split("")
.map((x, i) => .map((x, i) =>
parseInt(x) !== 0 && outAttachmentsTypes.includes(i) ? parseInt(i) : -1, parseInt(x) !== 0 && outAttachmentsTypes.includes(i) ? parseInt(i) : -1
) )
.filter(x => x !== -1); .filter(x => x !== -1);
@ -339,14 +336,14 @@ function attachmentsIdentifier(inpmsg, attachmentsData, inpStats) {
t1 t1
.map(x => data.attachmentTypes[x]) .map(x => data.attachmentTypes[x])
.reduce((out, x, i, a) => .reduce((out, x, i, a) =>
[out, x].join(i === a.length - 1 ? "` or `" : "`, `"), [out, x].join(i === a.length - 1 ? "` or `" : "`, `")
) + ) +
"` with " + "` with " +
outAttachments outAttachments
.filter(x => x.effects[35]) .filter(x => x.effects[35])
.map(x => x.name) .map(x => x.name)
.reduce((out, x, i, a) => .reduce((out, x, i, a) =>
[out, x].join(i === a.length - 1 ? " and " : ", "), [out, x].join(i === a.length - 1 ? " and " : ", ")
) )
: ""; : "";
errorMsgs += errors.length errorMsgs += errors.length
@ -374,7 +371,7 @@ function attachmentsIdentifier(inpmsg, attachmentsData, inpStats) {
(tooSmall.length === 1 ? "" : "s") + (tooSmall.length === 1 ? "" : "s") +
': `"' + ': `"' +
tooSmall.reduce((out, x, i) => tooSmall.reduce((out, x, i) =>
[out, x].join(i === curr.length - 1 ? '"` and `"' : '"`, `"'), [out, x].join(i === curr.length - 1 ? '"` and `"' : '"`, `"')
) + ) +
'"` ' + '"` ' +
(tooSmall.length === 1 ? "is" : "are") + (tooSmall.length === 1 ? "is" : "are") +
@ -395,7 +392,7 @@ function damageHandler(
tbs, tbs,
tbb, tbb,
bib, bib,
pellets, pellets
) { ) {
currDmgs = [...currDmgs]; currDmgs = [...currDmgs];
currRngs = [...currRngs]; currRngs = [...currRngs];
@ -422,8 +419,7 @@ function damageHandler(
let out; let out;
if (!pellets) { if (!pellets) {
out = Math.ceil(hp / dmg); out = Math.ceil(hp / dmg);
} } else {
else {
out = Math.ceil(hp / (dmg * pellets)); out = Math.ceil(hp / (dmg * pellets));
} }
out = out == Infinity ? "∞" : out; out = out == Infinity ? "∞" : out;
@ -444,8 +440,7 @@ function damageHandler(
out += tbs * (bib - 1) + tbb; out += tbs * (bib - 1) + tbb;
} }
out = out + tbs * (bib - 1); out = out + tbs * (bib - 1);
} } else if (stkVal % bib != 0) {
else if (stkVal % bib != 0) {
for (var i = 0; i <= Math.floor(stkVal / bib) - 1; i++) { for (var i = 0; i <= Math.floor(stkVal / bib) - 1; i++) {
out += tbs * (bib - 1) + tbb; out += tbs * (bib - 1) + tbb;
} }
@ -457,8 +452,7 @@ function damageHandler(
if (out == Infinity) { if (out == Infinity) {
return "∞"; return "∞";
} }
} } else {
else {
out = "No"; out = "No";
} }
return out; return out;
@ -489,7 +483,7 @@ function recoilHandler(
yRecoil, yRecoil,
xMultiplier, xMultiplier,
yMultiplier, yMultiplier,
bulletCount, bulletCount
) { ) {
if (xRecoil.length != yRecoil.length) { if (xRecoil.length != yRecoil.length) {
return "err"; return "err";
@ -515,8 +509,7 @@ function recoilHandler(
x: xRecoil[i] * (1 + xMultiplier / 100), x: xRecoil[i] * (1 + xMultiplier / 100),
y: yRecoil[i] * (1 + yMultiplier / 100), y: yRecoil[i] * (1 + yMultiplier / 100),
}; };
} } else {
else {
recoilObj = { recoilObj = {
x: x:
(recoilPattern[recoilPattern.length - 1].x + xContinuationVal) * (recoilPattern[recoilPattern.length - 1].x + xContinuationVal) *
@ -627,15 +620,14 @@ function attachmentHandler(currEffects, currStats) {
currEffects[0] + currEffects[0] +
"% zoom (+" + "% zoom (+" +
(currEffects[0] - currStats[16]) + (currEffects[0] - currStats[16]) +
"% zoom)", "% zoom)"
); );
} } else if (currEffects[0] != 0 && currEffects[0] != currStats[16]) {
else if (currEffects[0] != 0 && currEffects[0] != currStats[16]) {
neg.push( neg.push(
currEffects[0] + currEffects[0] +
"% zoom (-" + "% zoom (-" +
(currStats[16] - currEffects[0]) + (currStats[16] - currEffects[0]) +
"% zoom)", "% zoom)"
); );
} }
if (currEffects[0] != 0 && currStats[16] <= 110) { if (currEffects[0] != 0 && currStats[16] <= 110) {
@ -662,12 +654,11 @@ function attachmentHandler(currEffects, currStats) {
negGood1(19, "Idle Sway"); negGood1(19, "Idle Sway");
if (currEffects[20] > currStats[3]) { if (currEffects[20] > currStats[3]) {
pos.push( pos.push(
currEffects[20].ToString().Replace(".", " ~ ") + " Explosion Damage", currEffects[20].ToString().Replace(".", " ~ ") + " Explosion Damage"
); );
} } else if (currEffects[20] != 0 && currEffects[20] != currStats[3]) {
else if (currEffects[20] != 0 && currEffects[20] != currStats[3]) {
neg.push( neg.push(
currEffects[20].ToString().Replace(".", " ~ ") + " Explosion Damage", currEffects[20].ToString().Replace(".", " ~ ") + " Explosion Damage"
); );
} }
atrPush3(21, "Visible Laser when not ADS-ed"); atrPush3(21, "Visible Laser when not ADS-ed");
@ -690,7 +681,7 @@ function attachmentHandler(currEffects, currStats) {
.toString() .toString()
.split("") .split("")
.map((x, i) => (parseInt(x) !== 0 ? data.attachmentTypes[i] : 0)) .map((x, i) => (parseInt(x) !== 0 ? data.attachmentTypes[i] : 0))
.filter(x => x), .filter(x => x)
); );
} }
atrPush3(36, "Can't ADS"); atrPush3(36, "Can't ADS");
@ -699,8 +690,7 @@ function attachmentHandler(currEffects, currStats) {
} }
if (currEffects[38] != 0 && currEffects[38] < currStats[4]) { if (currEffects[38] != 0 && currEffects[38] < currStats[4]) {
pos.push("Turns to " + data.firingModes[currEffects[38] - 1]); pos.push("Turns to " + data.firingModes[currEffects[38] - 1]);
} } else if (currEffects[38] != 0 && currEffects[38] != currStats[4]) {
else if (currEffects[38] != 0 && currEffects[38] != currStats[4]) {
neg.push("Turns to " + data.firingModes[currEffects[38] - 1]); neg.push("Turns to " + data.firingModes[currEffects[38] - 1]);
} }
posGood2(39, "Tick Damage"); posGood2(39, "Tick Damage");
@ -710,8 +700,7 @@ function attachmentHandler(currEffects, currStats) {
posGood1(43, "Bullet Speed"); posGood1(43, "Bullet Speed");
if (currEffects[44] == 1) { if (currEffects[44] == 1) {
atr.push("Higher Penetraion Damage"); atr.push("Higher Penetraion Damage");
} } else if (currEffects[44] == -1) {
else if (currEffects[44] == -1) {
atr.push("Lower Penetraion Damage"); atr.push("Lower Penetraion Damage");
} }
posGood2(45, "Round" + (currEffects[45] - 1 ? "s" : "") + " in Reserve"); posGood2(45, "Round" + (currEffects[45] - 1 ? "s" : "") + " in Reserve");
@ -719,8 +708,7 @@ function attachmentHandler(currEffects, currStats) {
function posGood1(i, ext) { function posGood1(i, ext) {
if (currEffects[i].IsPositive()) { if (currEffects[i].IsPositive()) {
pos.push(currEffects[i].PlusHL() + "% " + ext); pos.push(currEffects[i].PlusHL() + "% " + ext);
} } else if (currEffects[i].IsNegative()) {
else if (currEffects[i].IsNegative()) {
neg.push(currEffects[i].PlusHL() + "% " + ext); neg.push(currEffects[i].PlusHL() + "% " + ext);
} }
} }
@ -728,8 +716,7 @@ function attachmentHandler(currEffects, currStats) {
function negGood1(i, ext) { function negGood1(i, ext) {
if (currEffects[i].IsNegative()) { if (currEffects[i].IsNegative()) {
pos.push(currEffects[i].PlusHL() + "% " + ext); pos.push(currEffects[i].PlusHL() + "% " + ext);
} } else if (currEffects[i].IsPositive()) {
else if (currEffects[i].IsPositive()) {
neg.push(currEffects[i].PlusHL() + "% " + ext); neg.push(currEffects[i].PlusHL() + "% " + ext);
} }
} }
@ -737,8 +724,7 @@ function attachmentHandler(currEffects, currStats) {
function posGood2(i, ext) { function posGood2(i, ext) {
if (currEffects[i].IsPositive()) { if (currEffects[i].IsPositive()) {
pos.push(currEffects[i].PlusHL() + " " + ext); pos.push(currEffects[i].PlusHL() + " " + ext);
} } else if (currEffects[i].IsNegative()) {
else if (currEffects[i].IsNegative()) {
neg.push(currEffects[i].PlusHL() + " " + ext); neg.push(currEffects[i].PlusHL() + " " + ext);
} }
} }
@ -746,8 +732,7 @@ function attachmentHandler(currEffects, currStats) {
function negGood2(i, ext) { function negGood2(i, ext) {
if (currEffects[i].IsNegative()) { if (currEffects[i].IsNegative()) {
pos.push(currEffects[i].PlusHL() + " " + ext); pos.push(currEffects[i].PlusHL() + " " + ext);
} } else if (currEffects[i].IsPositive()) {
else if (currEffects[i].IsPositive()) {
neg.push(currEffects[i].PlusHL() + " " + ext); neg.push(currEffects[i].PlusHL() + " " + ext);
} }
} }