From be8fbd797cc91c18c9bd0ad67befaeb05d3575ad Mon Sep 17 00:00:00 2001 From: Jesmaster Date: Fri, 25 Nov 2022 00:50:16 -0500 Subject: [PATCH 1/3] fallback if interaction user isn't available --- commands/bgg-collection.js | 4 ++-- commands/bgg-search.js | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/commands/bgg-collection.js b/commands/bgg-collection.js index 6b874a1..6b739e3 100644 --- a/commands/bgg-collection.js +++ b/commands/bgg-collection.js @@ -131,7 +131,7 @@ module.exports = { .setTitle(username + '\'s collection') .setURL(collection_url) .setDescription(collection_url) - .setAuthor({ name: user.username, url: user.avatarURL(), iconURL: user.displayAvatarURL() }) + .setAuthor(user ? { name: user.username, url: user.avatarURL(), iconURL: user.displayAvatarURL() } : null) .addFields( { name: 'Total', @@ -176,7 +176,7 @@ module.exports = { } if (isObject && !hasErrors && result.items['$'].totalitems > 0) { - interaction.editReply({ embeds: [this.collectionToEmbed(result, username, interaction.member.user)] }); + interaction.editReply({ embeds: [this.collectionToEmbed(result, username, interaction?.member?.user)] }); } else { interaction.editReply(`No results found for "${username}".`); diff --git a/commands/bgg-search.js b/commands/bgg-search.js index acbc9d7..555ef77 100644 --- a/commands/bgg-search.js +++ b/commands/bgg-search.js @@ -165,7 +165,7 @@ module.exports = { .setURL(`https://boardgamegeek.com/${item['$'].type}/${item['$'].id}`) .setThumbnail(item.thumbnail[0]) .setDescription(he.decode(item.description[0]).substring(0, 200)+'...') - .setAuthor({ name: user.username, url: user.avatarURL(), iconURL: user.displayAvatarURL() }) + .setAuthor(user ? { name: user.username, url: user.avatarURL(), iconURL: user.displayAvatarURL() } : null) .addFields( { name: ':hash: Number of Players', @@ -189,7 +189,7 @@ module.exports = { if(bggSearchResult.found) { const result = await this.bggThing(bggSearchResult.thing_id); await interaction.reply({ - embeds: [this.itemToSearchEmbed(result.items.item[0], interaction.member.user)] + embeds: [this.itemToSearchEmbed(result.items.item[0], interaction?.member?.user)] }); } else { @@ -214,7 +214,7 @@ module.exports = { .setThumbnail(item.thumbnail[0]) .setDescription(he.decode(item.description[0]).substring(0, 200)+'...') .setFooter({ text: '( 👍 Interested | 📖 Can Teach | ❌ End Suggestion )'}) - .setAuthor({ name: user.username, url: user.avatarURL(), iconURL: user.displayAvatarURL() }) + .setAuthor(user ? { name: user.username, url: user.avatarURL(), iconURL: user.displayAvatarURL() } : null) .addFields( { name: ':hash: Number of Players', @@ -250,7 +250,7 @@ module.exports = { if(bggSearchResult.found) { this.bggThing(bggSearchResult.thing_id) .then(result => { - let embed = this.itemToSuggestEmbed(result.items.item[0], interaction.member.user); + let embed = this.itemToSuggestEmbed(result.items.item[0], interaction?.member?.user); interaction.reply({ embeds: [embed], fetchReply: true }).then(embedMessage => { try { embedMessage.react("👍"); @@ -312,7 +312,7 @@ module.exports = { }); const deleteFilter = (reaction, user) => { - return reaction.emoji.name == '❌' && user.id === interaction.member.user.id; + return reaction.emoji.name == '❌' && user.id === interaction?.member?.user?.id; }; const deleteCollector = embedMessage.createReactionCollector({ filter: deleteFilter }); deleteCollector.on('collect', () => { From ee9011b78a3058e24074e73c81af5fc137777363 Mon Sep 17 00:00:00 2001 From: Jesmaster Date: Fri, 25 Nov 2022 00:51:40 -0500 Subject: [PATCH 2/3] increased redis cache to one week --- commands/bgg-search.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/commands/bgg-search.js b/commands/bgg-search.js index 555ef77..34c02fd 100644 --- a/commands/bgg-search.js +++ b/commands/bgg-search.js @@ -17,7 +17,7 @@ module.exports = { value: 'suggest', }) ), - cache_ttl: 1000 * 60 * 60 * 24, + cache_ttl: 1000 * 60 * 60 * 24 * 7, /** * Preforms BGG API search call. * @return {Promise} From fcd3edc81a89f4af16db34bd46d7ce61e1bd999a Mon Sep 17 00:00:00 2001 From: Jesmaster Date: Fri, 25 Nov 2022 00:52:09 -0500 Subject: [PATCH 3/3] update version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index b5b1cc0..97f3df6 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "discord-bgg-bot", - "version": "2.1.4", + "version": "2.1.5", "description": "Board Game Geek Discord Bot", "main": "index.js", "scripts": {