Skip to content

Commit

Permalink
Defer interactions before database writes (#76)
Browse files Browse the repository at this point in the history
* Defer button interactions before doing database writes

* Discord.js, or one of its dependencies, yelled at me for running Node below 16.9. It's probs fine, but updating docs anyway

* v1.6.3

* Update test runner to Node 16.9
  • Loading branch information
AverageHelper authored Jun 15, 2022
1 parent 8cf956d commit 90170e0
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 16 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:

strategy:
matrix:
node-version: [16.6.x]
node-version: [16.9.x]
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/

steps:
Expand All @@ -33,10 +33,10 @@ jobs:

steps:
- uses: actions/checkout@v2
- name: Use Node.js 16.6.x (earliest version supported)
- name: Use Node.js 16.9.x (earliest version supported)
uses: actions/setup-node@v1
with:
node-version: 16.6.x
node-version: 16.9.x
- run: npm ci
- run: npm run build
- run: npm run test:e2e
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ This project started out as a simple Discord bot to play around with APIs and th

## Prerequisites

This project requires [NodeJS](https://nodejs.org/) (version 16.6 or later), [NPM](https://npmjs.org/), and a [Discord bot account token](https://www.howtogeek.com/364225/how-to-make-your-own-discord-bot/).
This project requires [NodeJS](https://nodejs.org/) (version 16.9 or later), [NPM](https://npmjs.org/), and a [Discord bot account token](https://www.howtogeek.com/364225/how-to-make-your-own-discord-bot/).
To make sure you have them available on your machine,
try running the following command:

```sh
$ npm -v && node -v
7.20.3
v16.6.2
v16.15.1
```

## Clone the Repo
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "gamgee",
"version": "1.6.2",
"version": "1.6.3",
"description": "A Discord bot for managing a song request queue.",
"private": true,
"scripts": {
Expand Down
16 changes: 8 additions & 8 deletions src/handleMessageComponent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,24 +72,24 @@ export async function handleMessageComponent(

switch (interaction.customId) {
case DONE_BUTTON.id:
logger.debug("Marking done....");
await markEntryDoneInQueue(message, queueChannel);
logger.debug("Marked an entry done.");
try {
await interaction.deferUpdate();
logger.debug("Marking done....");
await markEntryDoneInQueue(message, queueChannel);
logger.debug("Marked an entry done.");
} catch (error) {
logger.error(richErrorMessage(`Failed to defer update`, error));
logger.error(richErrorMessage(`Failed to mark done`, error));
}
break;

case RESTORE_BUTTON.id:
logger.debug("Marking undone....");
await markEntryNotDoneInQueue(message, queueChannel);
logger.debug("Marked an entry undone");
try {
await interaction.deferUpdate();
logger.debug("Marking undone....");
await markEntryNotDoneInQueue(message, queueChannel);
logger.debug("Marked an entry undone");
} catch (error) {
logger.error(richErrorMessage(`Failed to defer update`, error));
logger.error(richErrorMessage(`Failed to mark not done`, error));
}
break;

Expand Down

0 comments on commit 90170e0

Please sign in to comment.