Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
BenSegal855 committed Feb 14, 2025
2 parents fd0a314 + 3e077a3 commit 46fcd77
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 7 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"license": "MIT",
"homepage": "https://github.com/BenSegal855/Steve-V3",
"engines": {
"node": "16.*"
"node": "20.*"
},
"dependencies": {
"@discordjs/collection": "2.0.0",
Expand Down Expand Up @@ -50,7 +50,7 @@
"devDependencies": {
"@sapphire/ts-config": "^5.0.0",
"@types/common-tags": "1.8.4",
"@types/node": "17.0.45",
"@types/node": "20.10.5",
"@types/node-cron": "3.0.11",
"@types/ws": "8.5.10",
"@typescript-eslint/eslint-plugin": "6.21.0",
Expand Down
32 changes: 32 additions & 0 deletions src/commands/Info/p4a.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import ical from 'node-ical';
import { EmbedBuilder, Message, TimestampStyles, time as discordTime } from 'discord.js';
import { SteveCommand } from '@lib/extensions/SteveCommand';
import { send } from '@sapphire/plugin-editable-commands';
import axios from 'axios';

@ApplyOptions<CommandOptions>({
description: 'See who\'s live right now on the Project for Awesome',
Expand All @@ -12,6 +13,7 @@ import { send } from '@sapphire/plugin-editable-commands';
export class UserCommand extends SteveCommand {

private icalURL25 = 'https://calendar.google.com/calendar/ical/c_b4abece77b5d42e59a82e68ef19a543c873b1177d53296529eb89cee0d179b5b%40group.calendar.google.com/public/basic.ics';
private statsURL = 'https://www.projectforawesome.com/data?req=stats';

public override registerApplicationCommands(registry: Command.Registry) {
registry.registerChatInputCommand(builder => {
Expand All @@ -34,6 +36,7 @@ export class UserCommand extends SteveCommand {
.setThumbnail('https://www.projectforawesome.com/assets/2025/Social/Profile_Lilac.png')
.setColor('#1B9C64');

const statsPromise = this.getStats();
const schedule = await this.getIcalData();

const now = new Date();
Expand Down Expand Up @@ -72,6 +75,15 @@ ${nextSlot ? `Next up, its ${nextSlot.hosts}` : ''}`)
break;
}

const stats = await statsPromise.catch(() => null);

if (stats) {
embed.addFields([
{ name: 'Total Raised', value: stats.total, inline: true },
{ name: 'Total Votes', value: stats.votes, inline: true }
]);
}

return embed;
}

Expand Down Expand Up @@ -100,6 +112,20 @@ ${nextSlot ? `Next up, its ${nextSlot.hosts}` : ''}`)
});
}

private async getStats(): Promise<stats> {
const response = await axios.get<stats>(this.statsURL);
const usDollar = new Intl.NumberFormat('en-US', {
style: 'currency',
currency: 'USD'
});

return {
total: usDollar.format(parseFloat(response.data.total)),
votes: response.data.votes,
donations: usDollar.format(parseFloat(response.data.donations))
};
}

}

type timeslot = {
Expand All @@ -108,3 +134,9 @@ type timeslot = {
tag: 'Live'|'Dark'|'Optional'|'Unknown',
hosts: string
};

type stats = {
total: string,
votes: string,
donations: string
};
19 changes: 14 additions & 5 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -738,10 +738,12 @@ __metadata:
languageName: node
linkType: hard

"@types/node@npm:17.0.45":
version: 17.0.45
resolution: "@types/node@npm:17.0.45"
checksum: aa04366b9103b7d6cfd6b2ef64182e0eaa7d4462c3f817618486ea0422984c51fc69fd0d436eae6c9e696ddfdbec9ccaa27a917f7c2e8c75c5d57827fe3d95e8
"@types/node@npm:20.10.5":
version: 20.10.5
resolution: "@types/node@npm:20.10.5"
dependencies:
undici-types: ~5.26.4
checksum: e216b679f545a8356960ce985a0e53c3a58fff0eacd855e180b9e223b8db2b5bd07b744a002b8c1f0c37f9194648ab4578533b5c12df2ec10cc02f61d20948d2
languageName: node
linkType: hard

Expand Down Expand Up @@ -4275,7 +4277,7 @@ __metadata:
"@sapphire/utilities": 3.15.3
"@skyra/env-utilities": ^1.2.1
"@types/common-tags": 1.8.4
"@types/node": 17.0.45
"@types/node": 20.10.5
"@types/node-cron": 3.0.11
"@types/ws": 8.5.10
"@typescript-eslint/eslint-plugin": 6.21.0
Expand Down Expand Up @@ -4693,6 +4695,13 @@ __metadata:
languageName: node
linkType: hard

"undici-types@npm:~5.26.4":
version: 5.26.5
resolution: "undici-types@npm:5.26.5"
checksum: 3192ef6f3fd5df652f2dc1cd782b49d6ff14dc98e5dced492aa8a8c65425227da5da6aafe22523c67f035a272c599bb89cfe803c1db6311e44bed3042fc25487
languageName: node
linkType: hard

"undici-types@npm:~6.20.0":
version: 6.20.0
resolution: "undici-types@npm:6.20.0"
Expand Down

0 comments on commit 46fcd77

Please sign in to comment.