Compare commits

...

2 commits

Author SHA1 Message Date
0068cde234 salmonrun schedule support 2023-08-01 10:58:42 +10:00
2347762ecc guild ID no longer hardcoded 2023-08-01 10:58:27 +10:00
2 changed files with 53 additions and 1 deletions

View file

@ -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');

View file

@ -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({