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

View file

@ -166,7 +166,7 @@ module.exports = {
inline: false,
}
)
.setThumbnail(`${d.preview}`)
.setThumbnail(d.preview)
.setFooter(`Made by ${client.author}`, client.user.displayAvatarURL())
.setColor(
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 cmds = [];
const ownercmds = [];
@ -30,7 +31,9 @@ module.exports = async client => {
client.on("ready", async () => {
const gg = client.guilds.cache.get("840225563193114624");
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 => {
const getroles = name => {
const perms = cmds.find(n => n.name == name).UserPerms;
@ -47,10 +50,9 @@ module.exports = async client => {
}, []);
return [...accumulator, { id: v.id, permissions }];
}, []);
try {
g.commands.permissions.set({ fullPermissions });
} catch {}
});
g.commands.permissions.set({ fullPermissions }).catch(null);
});
})
.catch(null);
});
};

View file

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