-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
56 lines (44 loc) · 1.64 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
require('dotenv').config();
const cron = require('node-cron');
const axios = require('axios');
// Require the necessary discord.js classes
const { Client, Events, GatewayIntentBits } = require('discord.js');
const token = process.env.DISCORD_APP_TOKEN;
// Create a new client instance
const client = new Client({ intents: [GatewayIntentBits.Guilds] });
client.once(Events.ClientReady, async c => {
try {
cron.schedule('0 0 8 * * *', async () => {
const channel = await c.channels.fetch('824302971914289194');
const steamPromotions = await axios.get('https://store.steampowered.com/contenthub/ajaxgetcontenthubdata', {
headers: {
key: process.env.STEAM_KEY,
},
params: { hubtype: 'specials' },
});
const { dailyDeals } = steamPromotions.data;
if (!dailyDeals) {
await channel.send('@player Infelizmente hoje não temos joguinhos em promoção.');
return;
}
await channel.send('@player\n Promoções do dia:');
dailyDeals.forEach(async (el) => {
if (el.item.type !== 'app') return;
const appDetails = await axios.get('https://store.steampowered.com/api/appdetails', {
headers: {
key: process.env.STEAM_KEY,
},
params: { appids: el.item.id },
});
const appData = appDetails.data[el.item.id].data;
await channel.send(`${appData.name}\n${appData.short_description}\n${appData.price_overview.initial_formatted}\n${appData.price_overview.final_formatted}\nDesconto de: ${appData.price_overview.discount_percent}% \n${appData.capsule_image}
`);
});
});
}
catch (error) {
console.error(error);
}
});
// Log in to Discord with your client's token
client.login(token);