Skip to content

Commit

Permalink
log DB connection errors
Browse files Browse the repository at this point in the history
  • Loading branch information
chen7897499 committed May 27, 2023
1 parent cb4702b commit cf177a0
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ const sqlLock = require('sql-lock');

const keyv = new Keyv(process.env.database_uri);

keyv.on('error', err => console.log('Connection Error', err));

sqlLock.initialize(process.env.database_uri, { locking_ttl: 30000 });

const client = new Client({ intents: [GatewayIntentBits.Guilds] });
Expand Down Expand Up @@ -64,9 +66,9 @@ client.on(Events.InteractionCreate, async (interaction) => {
if (command.data.name === 'faucet-dvt') {
await keyv.set(`discord-faucet-dvt-lasttx-week-${interaction.user.id}`, moment().startOf('isoweek').format("YYYY-MM-DD"));

const lockReleaser = await sqlLock.getLock(address, 3000);
// const lockReleaser = await sqlLock.getLock(address, 3000);
await keyv.set(`ethaddress-faucet-dvt-lasttx-week-${address}`, moment().startOf('isoweek').format("YYYY-MM-DD"));
lockReleaser();
// lockReleaser();
}
} catch (error) {
if (error.code === 10062) return;
Expand Down

0 comments on commit cf177a0

Please sign in to comment.