Skip to content

Commit

Permalink
Merge pull request #82 from Jesmaster/release-v2.1.3
Browse files Browse the repository at this point in the history
Release v2.1.3
  • Loading branch information
Jesmaster authored Oct 29, 2022
2 parents 6be04ca + 48e3cc1 commit 98f394c
Show file tree
Hide file tree
Showing 4 changed files with 225 additions and 195 deletions.
18 changes: 14 additions & 4 deletions commands/bgg-collection.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ module.exports = {
const
cache_type = 'bgg_collection',
cache = await this.cacheGet(cache_type, username),
axios = require('axios').default,
axios = require('axios'),
xml2js = require('xml2js'),
parser = new xml2js.Parser();

Expand Down Expand Up @@ -192,15 +192,25 @@ module.exports = {
const username = interaction.options.getString('username');

let result = await this.bggCollection(username);
if (result === 'Building results') {
console.log(new Date().toISOString(), `Building collection results for ${username}`);
let attempts = 1;
const max_attemps = 5;

while (result === 'Building results' && attempts <= max_attemps) {
console.log(new Date().toISOString(), `Building collection results for ${username} - Attempt ${attempts}`);

//Wait 2 seconds and then attempt call again.
await new Promise((resolve) => setTimeout(resolve, 2000));
result = await this.bggCollection(username);
attempts++;
}

if (result === 'Building results') {
console.log(new Date().toISOString(), `Unable to build collection results after ${attemps} attemps for ${username}`);
}
else {
console.log(new Date().toISOString(), `Collection results found for ${username}`);
}

console.log(new Date().toISOString(), `Collection results found for ${username}`);
this.collectionPrintEmbed(result, interaction, username);
},
}
6 changes: 2 additions & 4 deletions commands/bgg-search.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ module.exports = {
query = searchParams.toString(),
cache_type = 'bgg_search',
cache = await this.cacheGet(cache_type, query),
axios = require('axios').default;
axios = require('axios');

console.log(new Date().toISOString(), `Looking up search: ${name}...`);

Expand Down Expand Up @@ -61,7 +61,7 @@ module.exports = {
const
cache_type = 'bgg_thing',
cache = await this.cacheGet(cache_type, thing_id),
axios = require('axios').default,
axios = require('axios'),
xml2js = require('xml2js'),
parser = new xml2js.Parser();

Expand Down Expand Up @@ -247,8 +247,6 @@ module.exports = {
* Send game embed to channel given thing_id
*/
thingIdToSuggestEmbed: async function(bggSearchResult, interaction) {
const { EmbedBuilder } = require('discord.js');

if(bggSearchResult.found) {
this.bggThing(bggSearchResult.thing_id)
.then(result => {
Expand Down
Loading

0 comments on commit 98f394c

Please sign in to comment.