Skip to content

Commit

Permalink
feat: Project For Awesome!
Browse files Browse the repository at this point in the history
  • Loading branch information
BenSegal855 committed Feb 16, 2024
1 parent 295cc57 commit f73951b
Show file tree
Hide file tree
Showing 6 changed files with 1,297 additions and 918 deletions.
4 changes: 3 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,12 @@
"sreply",
"sudoreply",
"tagq",
"timeslot",
"timespan",
"udel",
"unfaxed",
"viewremind"
],
"debug.javascript.unmapMissingSources": true
"debug.javascript.unmapMissingSources": true,
"WhiteSource Advise.Diff.BaseBranch": "main"
}
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
"chartjs-plugin-datalabels": "2.2.0",
"colorette": "2.0.20",
"common-tags": "1.8.2",
"date-and-time": "^3.1.1",
"discord.js": "14.14.1",
"module-alias": "2.2.3",
"mongodb": "4.17.2",
Expand Down
249 changes: 249 additions & 0 deletions src/assets/P4A24Schedule.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,249 @@
{
"p4aSchedule": [
{
"time": "2/16/2024 12:00pm -0500",
"tag": "Live",
"hosts": "Hank Green, John Green"
},
{
"time": "2/16/2024 1:00pm -0500",
"tag": "Live",
"hosts": "John Green, Dr. Joia Mukherjee"
},
{
"time": "2/16/2024 2:00pm -0500",
"tag": "Live",
"hosts": "John Green"
},
{
"time": "2/16/2024 3:00pm -0500",
"tag": "Live",
"hosts": "Hank Green, Ettore Rossetti"
},
{
"time": "2/16/2024 4:00pm -0500",
"tag": "Live",
"hosts": "Hank Green"
},
{
"time": "2/16/2024 5:00pm -0500",
"tag": "Live",
"hosts": "Hank Green, Travis McElroy"
},
{
"time": "2/16/2024 6:00pm -0500",
"tag": "Live",
"hosts": "John Green"
},
{
"time": "2/16/2024 7:00pm -0500",
"tag": "Live",
"hosts": "John Green, Danielle Bainbridge"
},
{
"time": "2/16/2024 8:00pm -0500",
"tag": "Live",
"hosts": "Sabrina Cruz, Tom Lum"
},
{
"time": "2/16/2024 9:00pm -0500",
"tag": "Live",
"hosts": "Nerdfighteria Minecraft Server"
},
{
"time": "2/16/2024 10:00pm -0500",
"tag": "Live",
"hosts": "Ceri Riley, Sam Schultz"
},
{
"time": "2/16/2024 11:00pm -0500",
"tag": "Live",
"hosts": "Hank Green, Ceri Riley, Sam Schultz"
},
{
"time": "2/17/2024 12:00am -0500",
"tag": "Live",
"hosts": "Hank Green, Brennan Lee Mulligan"
},
{
"time": "2/17/2024 1:00am -0500",
"tag": "Live",
"hosts": "Hank Green"
},
{
"time": "2/17/2024 2:00am -0500",
"tag": "Optional",
"hosts": "Hank Green"
},
{
"time": "2/17/2024 3:00am -0500",
"tag": "Optional",
"hosts": "Hank Green"
},
{
"time": "2/17/2024 4:00am -0500",
"tag": "Dark",
"hosts": "Taking a break! 💤"
},
{
"time": "2/17/2024 5:00am -0500",
"tag": "Dark",
"hosts": "Taking a break! 💤"
},
{
"time": "2/17/2024 6:00am -0500",
"tag": "Dark",
"hosts": "Taking a break! 💤"
},
{
"time": "2/17/2024 7:00am -0500",
"tag": "Dark",
"hosts": "Taking a break! 💤"
},
{
"time": "2/17/2024 8:00am -0500",
"tag": "Dark",
"hosts": "Taking a break! 💤"
},
{
"time": "2/17/2024 9:00am -0500",
"tag": "Dark",
"hosts": "Taking a break! 💤"
},
{
"time": "2/17/2024 10:00am -0500",
"tag": "Live",
"hosts": "John Green"
},
{
"time": "2/17/2024 11:00am -0500",
"tag": "Live",
"hosts": "John Green, Phil Plait"
},
{
"time": "2/17/2024 12:00pm -0500",
"tag": "Live",
"hosts": "Hank Green"
},
{
"time": "2/17/2024 1:00pm -0500",
"tag": "Live",
"hosts": "Rosianna Halse Rojas"
},
{
"time": "2/17/2024 2:00pm -0500",
"tag": "Live",
"hosts": "Rosianna Halse Rojas"
},
{
"time": "2/17/2024 3:00pm -0500",
"tag": "Live",
"hosts": "Hank Green, Tyler Thrasher"
},
{
"time": "2/17/2024 4:00pm -0500",
"tag": "Live",
"hosts": "Hank Green, Drawfee"
},
{
"time": "2/17/2024 5:00pm -0500",
"tag": "Live",
"hosts": "Animal Wonders (Jessi Knudsen-Castañeda), Nicole Sweeney"
},
{
"time": "2/17/2024 6:00pm -0500",
"tag": "Live",
"hosts": "Taylor Behnke , Miriam Nielsen"
},
{
"time": "2/17/2024 7:00pm -0500",
"tag": "Live",
"hosts": "John Green"
},
{
"time": "2/17/2024 8:00pm -0500",
"tag": "Live",
"hosts": "John Green"
},
{
"time": "2/17/2024 9:00pm -0500",
"tag": "Live",
"hosts": "Hank Green, Alexis Nikole Nelson"
},
{
"time": "2/17/2024 10:00pm -0500",
"tag": "Live",
"hosts": "Destin Sandlin"
},
{
"time": "2/17/2024 11:00pm -0500",
"tag": "Live",
"hosts": "Destin Sandlin"
},
{
"time": "2/18/2024 12:00am -0500",
"tag": "Live",
"hosts": "Hank Green"
},
{
"time": "2/18/2024 1:00am -0500",
"tag": "Live",
"hosts": "Hank Green, Brittany Broski"
},
{
"time": "2/18/2024 2:00am -0500",
"tag": "Optional",
"hosts": "Hank Green"
},
{
"time": "2/18/2024 3:00am -0500",
"tag": "Optional",
"hosts": "Hank Green"
},
{
"time": "2/18/2024 4:00am -0500",
"tag": "Dark",
"hosts": "Taking a break! 💤"
},
{
"time": "2/18/2024 5:00am -0500",
"tag": "Dark",
"hosts": "Taking a break! 💤"
},
{
"time": "2/18/2024 6:00am -0500",
"tag": "Dark",
"hosts": "Taking a break! 💤"
},
{
"time": "2/18/2024 7:00am -0500",
"tag": "Live",
"hosts": "John Green"
},
{
"time": "2/18/2024 8:00am -0500",
"tag": "Live",
"hosts": "John Green"
},
{
"time": "2/18/2024 9:00am -0500",
"tag": "Live",
"hosts": "Hank Green"
},
{
"time": "2/18/2024 10:00am -0500",
"tag": "Live",
"hosts": "Hank Green, John Green"
},
{
"time": "2/18/2024 11:00am -0500",
"tag": "Live",
"hosts": "Hank Green, John Green"
},
{
"time": "2/18/2024 12:00pm -0500",
"tag": "Dark",
"hosts": "No one, its over"
}
]
}
89 changes: 89 additions & 0 deletions src/commands/Info/p4a.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
import { ApplyOptions } from '@sapphire/decorators';
import type { Command, CommandOptions } from '@sapphire/framework';
import date from 'date-and-time';
import meridiem from 'date-and-time/plugin/meridiem';
import { EmbedBuilder, Message, TimestampStyles, time as discordTime } from 'discord.js';
import { SteveCommand } from '@lib/extensions/SteveCommand';
import { p4aSchedule } from '../../assets/P4A24Schedule.json';
import { send } from '@sapphire/plugin-editable-commands';

date.plugin(meridiem);

@ApplyOptions<CommandOptions>({
description: 'See who\'s live right now on the Project for Awesome',
preconditions: ['CommitteeOnly']
})
export class UserCommand extends SteveCommand {

public override registerApplicationCommands(registry: Command.Registry) {
registry.registerChatInputCommand(builder => {
builder
.setName(this.name)
.setDescription(this.description);
}, { guildIds: ['700378785605877820'] });
}

public async chatInputRun(interaction: Command.ChatInputCommandInteraction) {
interaction.reply({ embeds: [this.buildEmbed()] });
}

public async messageRun(msg: Message) {
return send(msg, { embeds: [this.buildEmbed()] });
}

private buildEmbed(): EmbedBuilder {
const embed = new EmbedBuilder()
.setThumbnail('https://projectforawesome.com/assets/2024/Social/p4a_2024_profile.png')
.setColor('#1B9C64');

const trueDateSchedule: timeslot[] = p4aSchedule.map(({ tag, hosts, time }) => ({
tag: tag === 'Live' || tag === 'Dark' || tag === 'Optional' ? tag : 'Unknown',
hosts,
time: date.parse(time, 'M/D/YYYY h:mma Z')
}));

const nextSlotIdx = trueDateSchedule.findIndex(timeslot => timeslot.time.getTime() > Date.now());

if (nextSlotIdx < 0) {
return embed
.setTitle('The P4A is over. See you next year');
}

const currentSlot = trueDateSchedule[nextSlotIdx - 1];
const nextSlot = trueDateSchedule[nextSlotIdx];

switch (currentSlot.tag) {
case 'Live':
embed.setTitle(`Live now: ${currentSlot.hosts}`)
.setDescription(`**${currentSlot.hosts}** Will be live until ${discordTime(nextSlot.time, TimestampStyles.ShortTime)}
Next up, its ${nextSlot.hosts}`)
.setURL('https://projectforawesome.com/live');
break;
case 'Optional':
embed.setTitle(`${currentSlot.hosts} might be live now, but they might not`)
.setDescription(`**${currentSlot.hosts}** Will be live until ${discordTime(nextSlot.time, TimestampStyles.ShortTime)}
Next up, its ${nextSlot.hosts}`)
.setURL('https://projectforawesome.com/live'); ;
break;
case 'Dark':
embed.setTitle('The Project for Awesome is taking a break.')
.setDescription('Take this time to catch some sleep')
.setColor('DarkButNotBlack');
break;
case 'Unknown':
default:
embed.setTitle('Something broke!')
.setDescription('If you think this is an issue, contact Ben');
break;
}

return embed;
}

}

type timeslot = {
time: Date,
tag: 'Live'|'Dark'|'Optional'|'Unknown',
hosts: string
};
10 changes: 9 additions & 1 deletion src/preconditions/CommitteeOnly.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Precondition } from '@sapphire/framework';
import type { Message } from 'discord.js';
import type { CommandInteraction, Message } from 'discord.js';

export class UserPrecondition extends Precondition {

Expand All @@ -11,6 +11,14 @@ export class UserPrecondition extends Precondition {
});
}

public chatInputRun(interaction: CommandInteraction) {
return interaction.guildId === '700378785605877820'
? this.ok()
: this.error({
message: 'This command can only be run in the Server By Committiee'
});
}

}

declare module '@sapphire/framework' {
Expand Down
Loading

0 comments on commit f73951b

Please sign in to comment.