Skip to content

Commit

Permalink
#patch removing db entry on failed msg updates, lowered progress delt…
Browse files Browse the repository at this point in the history
…a time
  • Loading branch information
jgaribsin committed Mar 15, 2024
1 parent 7a61e18 commit 9aebbd8
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 12 deletions.
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ HellCom StratDef Network is the all-in-one solution for your Helldivers 2 server

HellCom will be continuously updated and improved. It is a community-driven project, so if there's a feature you'd like to see, feel free to suggest it in our Discord! Improvements and addition suggestions are always welcome =)

You can add it to your own server using **[this link (click)](https://discord.com/api/oauth2/authorize?client_id=1213944670288347176&permissions=414464658496&scope=applications.commands%20bot)**.
You can add it to your own server using **[this link (click)](https://discord.com/api/oauth2/authorize?client_id=1213944670288347176&permissions=274878221376&scope=applications.commands%20bot)**.

## Features

Expand All @@ -21,3 +21,7 @@ You can add it to your own server using **[this link (click)](https://discord.co
> Thanks for reading, have an awesome day!
If you notice any issues, or have a suggestion, feel free to contact me via Discord @`theyodastream`.

## Terms of Service

## Privacy Policy
4 changes: 2 additions & 2 deletions src/handlers/embed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -251,8 +251,8 @@ export async function warStatusEmbeds() {
Total: [],
};

// todo: get API data from 6~ hours ago (or closer), and calculate the lossPercPerHour
const timeCheck = 4 * 60 * 60 * 1000; // 6 hours in milliseconds
// todo: get API data from 2~ hours ago (or closer), and calculate the lossPercPerHour
const timeCheck = 3 * 60 * 60 * 1000; // 6 hours in milliseconds
const timestamp = new Date(Date.now() - timeCheck);
// fetch the first API data entry that is older than 6 hours
const pastApiData = await db.query.apiData.findMany({
Expand Down
30 changes: 21 additions & 9 deletions src/handlers/update.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,25 +56,37 @@ export async function updateMessages() {
case 10003: // Unknown channel
promises.push(
db
.update(persistentMessages)
.set({deleted: true})
.where(eq(persistentMessages.messageId, messageId))
.delete(persistentMessages)
.where(
and(
eq(persistentMessages.messageId, messageId),
eq(persistentMessages.production, isProd)
)
)
);
break;
case 10008: // Unknown message
promises.push(
db
.update(persistentMessages)
.set({deleted: true})
.where(eq(persistentMessages.messageId, messageId))
.delete(persistentMessages)
.where(
and(
eq(persistentMessages.messageId, messageId),
eq(persistentMessages.production, isProd)
)
)
);
break;
case 50001: // Missing access
promises.push(
db
.update(persistentMessages)
.set({deleted: true})
.where(eq(persistentMessages.messageId, messageId))
.delete(persistentMessages)
.where(
and(
eq(persistentMessages.messageId, messageId),
eq(persistentMessages.production, isProd)
)
)
);
break;
case 50005: // Cannot edit a message authored by another user
Expand Down

0 comments on commit 9aebbd8

Please sign in to comment.