From 2347762ecccb48a9fbd54a1c88b138d41ced3329 Mon Sep 17 00:00:00 2001 From: Emily Date: Tue, 1 Aug 2023 10:58:27 +1000 Subject: [PATCH 1/2] guild ID no longer hardcoded --- bot/deploy.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/bot/deploy.js b/bot/deploy.js index 920de24..027642a 100644 --- a/bot/deploy.js +++ b/bot/deploy.js @@ -2,11 +2,17 @@ const { REST, Routes } = require('discord.js'); const { clientId, token } = require('../botconfig.json'); -const guildId = '413591792185769984'; const read = require('fs-readdir-recursive'); const commands = []; const commandFiles = read('./commands').filter(file => file.endsWith('.js')); +if (process.argv.length === 2) { + console.log('No guild ID provided, deployment failed.'); + process.exit(1); +} + +const guildId = process.argv[2]; + for (const file of commandFiles) { const command = new (require(__dirname + '/commands/' + file))(file.substr(file.indexOf('/') + 1).slice(0, -3), file.substr(0, file.indexOf('/'))); commands.push({ From 0068cde2347f9887803c4787efdaf1e2cd10c2a0 Mon Sep 17 00:00:00 2001 From: Emily Date: Tue, 1 Aug 2023 10:58:42 +1000 Subject: [PATCH 2/2] salmonrun schedule support --- bot/commands/Utility/splatnet.js | 46 ++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/bot/commands/Utility/splatnet.js b/bot/commands/Utility/splatnet.js index d97fa9e..ec818c0 100644 --- a/bot/commands/Utility/splatnet.js +++ b/bot/commands/Utility/splatnet.js @@ -185,6 +185,52 @@ module.exports = class Splatnet extends Command { } } + if (subCmd === 'salmonrun') { + if (client.cache.has('SPLATNET_SR') && Date.now() > client.cache.get('SPLATNET_SR').expiry) { + client.cache.delete('SPLATNET_SR'); + } + + if (!client.cache.has('SPLATNET_SR')) { + fetch('https://splatoon3.ink/data/schedules.json', { headers: { 'User-Agent': client.config.userAgent} }) + .then(res => res.json()) + .then(tlJson => { + fetch('https://splatoon3.ink/data/coop.json', { headers: { 'User-Agent': client.config.userAgent} }) + .then(rewardRes => rewardRes.json()) + .then(async rewardJson => { + const embeds = []; + const json = { + tl: tlJson.data.coopGroupingSchedule, + rw: rewardJson.data.coopResult.monthlyGear + }; + + embeds.push(new client.EmbedBuilder() + .setTitle('Current Salmon Run') + .setColor(interaction.guild.members.me.displayColor) + .setThumbnail(json.rw.image.url) + .setImage(json.tl.regularSchedules.nodes[0].setting.coopStage.image.url) + .addFields( + { + name: 'Stage', + value: json.tl.regularSchedules.nodes[0].setting.coopStage.name, + inline: true + }, + { + name: 'Monthly Gear', + value: json.rw.name, + inline: true + }, + { + name: 'Weapons', + value: json.tl.regularSchedules.nodes[0].setting.weapons[0] + } + + ) + ); + }); + }); + } + } + if (subCmd === 'gear') { if (client.cache.has('SPLATNET_GEAR') && Date.now() > client.cache.get('SPLATNET_GEAR').expiry) { client.cache.delete('SPLATNET_GEAR');