Skip to content

Commit

Permalink
Merge pull request #330 from the-hideout/fix-restock-alert-error
Browse files Browse the repository at this point in the history
Fixes error related to restock alerts
  • Loading branch information
Razzmatazzz authored Jan 16, 2025
2 parents a5fd7ce + 86c5573 commit f5efa34
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 9 deletions.
2 changes: 1 addition & 1 deletion bot.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ discordClient.on('interactionCreate', async interaction => {
sendWebhook({
title: `Error running /${interaction.commandName} command on shard ${discordClient.shard.ids[0]}`,
message: error.stack,
footer: `Command invoked by @${interaction.member.user.username} | ${interaction.member.guild ? `Server: ${interaction.member.guild.name}` : 'DM'} | lang: ${lang} | mode ${gameMode}`,
footer: `Command invoked by @${interaction.member?.user?.username ?? 'Unknown User'} | ${interaction.member?.guild ? `Server: ${interaction.member.guild.name}` : 'DM'} | lang: ${lang} | mode ${gameMode}`,
files: [
new AttachmentBuilder(
Buffer.from(JSON.stringify(interaction.options, null, 4), 'utf8'),
Expand Down
2 changes: 1 addition & 1 deletion commands/goons.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ const defaultFunction = {
json: {
map: selectedMap.nameId,
timestamp: new Date().getTime(),
accountId: parseInt(interaction.user.id.slice(-10)),
discordId: interaction.user.id,
gameMode: gameMode,
},
}).json();
Expand Down
13 changes: 7 additions & 6 deletions modules/progress.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,9 @@ const buildDefaultProgress = id => {
restock: {},
},
};
const gameModes = ['regular', 'pve'];
for (const gameMode of gameModes) {
progress[gameMode] = getDefaultGameModeProgress();
progress.alerts[gameMode] = [];
progress.alerts.restock[gameMode] = [];
}
return progress;
};
Expand Down Expand Up @@ -167,9 +166,14 @@ const getUserProgress = async id => {
if (Array.isArray(userProgress[id].alerts.restock)) {
userProgress[id].alerts.restock = {
regular: userProgress[id].alerts.restock,
pve: [],
};
}
for (const gameMode of gameModes) {
if (!userProgress[id].alerts.restock[gameMode]) {
userProgress[id].alerts.restock[gameMode] = [];
}

}
return userProgress[id];
};

Expand Down Expand Up @@ -249,9 +253,6 @@ const addRestockAlert = async (id, traders, locale) => {
if (locale) {
prog.locale = locale;
}
if (!prog.alerts.restock[gameMode]) {
prog.alerts.restock[gameMode] = [];
}
const restockAlerts = prog.alerts.restock[gameMode];
for (const traderId of traders) {
if (!restockAlerts.includes(traderId)) restockAlerts.push(traderId);
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"description": "The Tarkov.dev's Escape from Tarkov Discord bot",
"main": "index.mjs",
"engines": {
"node": "20.*"
"node": "22.*"
},
"repository": {
"type": "git",
Expand Down

0 comments on commit f5efa34

Please sign in to comment.