Batch Chart Game Publishers
This commit is contained in:
parent
7977cada59
commit
791d4dd33a
@ -2,7 +2,7 @@ const { createCanvas } = require('canvas');
|
|||||||
const { Chart } = require('chart.js/auto');
|
const { Chart } = require('chart.js/auto');
|
||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
const { getUserRegistration, getBeatenGames, checkGameStorageId } = require('../../databaseHelperFunctions.js');
|
const { getUserRegistration, getBeatenGames, checkGameStorageId } = require('../../databaseHelperFunctions.js');
|
||||||
const { getGameJson, getCompanyInfo } = require('../../igdbHelperFunctions.js');
|
const { getGameJson, getInvolvedCompanies, getCompanies } = require('../../igdbHelperFunctions.js');
|
||||||
const { SlashCommandBuilder, EmbedBuilder } = require('discord.js');
|
const { SlashCommandBuilder, EmbedBuilder } = require('discord.js');
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
@ -18,7 +18,6 @@ module.exports = {
|
|||||||
let user = interaction.user;
|
let user = interaction.user;
|
||||||
const userOption = interaction.options.getUser('user');
|
const userOption = interaction.options.getUser('user');
|
||||||
const yearOption = interaction.options.getInteger('year');
|
const yearOption = interaction.options.getInteger('year');
|
||||||
const ignoreadventure = interaction.options.getBoolean('ignoreadventure');
|
|
||||||
|
|
||||||
if (userOption) {
|
if (userOption) {
|
||||||
user = userOption;
|
user = userOption;
|
||||||
@ -51,38 +50,40 @@ module.exports = {
|
|||||||
return interaction.editReply({ embeds: [embed] });
|
return interaction.editReply({ embeds: [embed] });
|
||||||
}
|
}
|
||||||
|
|
||||||
const beatGameIGDBEntries = [];
|
const gameIds = [];
|
||||||
|
|
||||||
for (let i = 0; i < beatenGamesDatabaseEntries.length; i++) {
|
for (let i = 0; i < beatenGamesDatabaseEntries.length; i++) {
|
||||||
const game = await checkGameStorageId(beatenGamesDatabaseEntries[i].gameId);
|
const game = await checkGameStorageId(beatenGamesDatabaseEntries[i].gameId);
|
||||||
const json = await getGameJson(String.prototype.concat('where id = ', game.igdb_id, '; fields *;'));
|
gameIds.push(game.igdb_id);
|
||||||
beatGameIGDBEntries.push(json[0]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const companies = [];
|
const beatGameIGDBEntries = await getGameJson(String.prototype.concat(`where id = (${gameIds}); fields *; limit ${gameIds.length};`));
|
||||||
const companyIds = new Set();
|
|
||||||
|
const involvedCompanyIds = new Set();
|
||||||
|
|
||||||
for (let i = 0; i < beatGameIGDBEntries.length; i++) {
|
for (let i = 0; i < beatGameIGDBEntries.length; i++) {
|
||||||
if (beatGameIGDBEntries[i].involved_companies)
|
if (beatGameIGDBEntries[i].involved_companies)
|
||||||
{
|
{
|
||||||
for (let j = 0; j < beatGameIGDBEntries[i].involved_companies.length; j++) {
|
for (let j = 0; j < beatGameIGDBEntries[i].involved_companies.length; j++) {
|
||||||
companyIds.add(beatGameIGDBEntries[i].involved_companies[j]);
|
involvedCompanyIds.add(beatGameIGDBEntries[i].involved_companies[j]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const ids = [...companyIds];
|
const involvedIds = [...involvedCompanyIds];
|
||||||
const tempIds = [];
|
|
||||||
|
|
||||||
for (let i = 0; i < ids.length; i++) {
|
const involvedCompanies = await getInvolvedCompanies(involvedIds);
|
||||||
const company = await getCompanyInfo(ids[i]);
|
const companyIds = new Set();
|
||||||
|
for (let i = 0; i < involvedCompanies.length; i++) {
|
||||||
if (!tempIds.includes(company.id)) {
|
if (involvedCompanies[i].company)
|
||||||
tempIds.push(company.id);
|
{
|
||||||
companies.push(company);
|
companyIds.add(involvedCompanies[i].company);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const compIds = [...companyIds];
|
||||||
|
const companies = await getCompanies(compIds);
|
||||||
|
|
||||||
const publishers = [];
|
const publishers = [];
|
||||||
const counts = [];
|
const counts = [];
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user