@@ -10,19 +10,19 @@ import Logger from '../utils/Logger';
1010import QR from './QR' ;
1111
1212/**
13- * This Command DM's the caller the checkin code and Express Checkin link for any events
14- * in today's timeframe. Optional argument `now ` makes the embed with the checkin codes
15- * be returned in the same chat as the Command message, but only for currently running events.
16- * Argument 'widescreen' allows users to choose if they want a QR code by itself (false) or
17- * the widescreen slide QR (true).
13+ * This Command DM's the caller the checkin code and Express Checkin link for any current and
14+ * upcoming events in today's timeframe. Optional argument `public ` makes the embed with the
15+ * checkin codes be returned in the same chat as the Command message instead of DMs. Optional
16+ * argument 'widescreen' allows users to choose if they want a QR code by itself (false) or
17+ * the widescreen slide QR (true). 'widescreen' is true by default.
1818 */
1919export default class Checkin extends Command {
2020 constructor ( client : BotClient ) {
2121 const definition = new SlashCommandBuilder ( )
2222 . setName ( 'checkin' )
2323 . addBooleanOption ( option =>
2424 option
25- . setName ( 'now ' )
25+ . setName ( 'public ' )
2626 . setDescription ( 'If true, send public embed of checking code for live events!' )
2727 . setRequired ( false )
2828 )
@@ -40,7 +40,7 @@ export default class Checkin extends Command {
4040 boardRequired : true ,
4141 enabled : true ,
4242 description :
43- "Sends a private message with all check-in codes from today's events. Calling with `now ` argument sends public embed of checkin code if any events are now live! " ,
43+ "Sends a private message with all check-in codes from today's events. Calling with `public ` argument sends public embed of checkin code in the current channel instead of via DM. " ,
4444 category : 'Utility' ,
4545 usage : client . settings . prefix . concat ( 'checkin [now]' ) ,
4646 requiredPermissions : [ 'SEND_MESSAGES' ] ,
@@ -66,10 +66,11 @@ export default class Checkin extends Command {
6666 */
6767 public async run ( interaction : CommandInteraction ) : Promise < void > {
6868 // Get arguments. Get rid of the null types by checking them.
69- const nowArgument = interaction . options . getBoolean ( 'now ' ) ;
69+ const publicArgument = interaction . options . getBoolean ( 'public ' ) ;
7070 const widescreenArgument = interaction . options . getBoolean ( 'widescreen' ) ;
7171
72- const isPublic = nowArgument !== null ? nowArgument : false ;
72+ // By default, we want the QR code to be DMed to the user.
73+ const isPublic = publicArgument !== null ? publicArgument : false ;
7374 // By default, we want to include the slide.
7475 const needsSlide = widescreenArgument !== null ? widescreenArgument : true ;
7576
@@ -83,12 +84,7 @@ export default class Checkin extends Command {
8384 // Oh, boy, here come more dates and times to check.
8485 // Luxon makes it much nicer, however.
8586 //
86- // We need two sets of arrays for "checkin":
87- // - all events that have a start time within today's timeframe
88- // - all events that are live RIGHT NOW
89- //
90- // The first set is useful for us to prepare a checkin code beforehand, while the second set
91- // enables the functionality for `checkin now`. We'll start with the first set.
87+ // We need an array to store all events that have a start time within today's timeframe.
9288 const todayEvents = futureEvents . filter ( event => {
9389 // get today's midnight
9490 const midnightToday = DateTime . now ( ) . set ( {
@@ -112,33 +108,21 @@ export default class Checkin extends Command {
112108 return Interval . fromDateTimes ( midnightToday , midnightTomorrow ) . contains ( event . start ) ;
113109 } ) ;
114110
115- // Check if current time in between event
116- const liveEvents = futureEvents . filter ( event =>
117- Interval . fromDateTimes ( event . start , event . end ) . contains ( DateTime . now ( ) )
118- ) ;
119-
120111 // We'll make sure to check if the required set of events by
121112 // command arugments is empty; if it is, just return "No events today!"
122- if ( ! isPublic && todayEvents . length === 0 ) {
113+ if ( todayEvents . length === 0 ) {
123114 await super . edit ( interaction , {
124115 content : 'No events today!' ,
125116 ephemeral : true ,
126117 } ) ;
127118 return ;
128119 }
129- if ( isPublic && liveEvents . length === 0 ) {
130- await super . edit ( interaction , 'No events right now!' ) ;
131- return ;
132- }
133120
134121 // Now we finally check the command argument.
135122 // If we just had `checkin` in our call, no arguments...
136123 if ( ! isPublic ) {
137124 const author = await this . client . users . fetch ( interaction . member ! . user . id ) ;
138- // What we need now is to construct the Payload to send for `checkin` with no arguments,
139- // as well as the Payload for when we have `checkin now`.
140- //
141- // Since this is private, we can list all of today's events.
125+ // What we need now is to construct the Payload to send for `checkin`.
142126 const privateMessage = await Checkin . getCheckinMessage ( todayEvents , isPublic , needsSlide ) ;
143127 await author . send ( privateMessage ) ;
144128 await super . edit ( interaction , {
@@ -147,9 +131,7 @@ export default class Checkin extends Command {
147131 } ) ;
148132 await interaction . followUp ( `**/checkin** was used privately by ${ interaction . user } !` ) ;
149133 } else {
150- // This is public, so we only want to give events that are live RIGHT now (so no one can
151- // pre-emptively get checkin codes if they're left to be seen).
152- const publicMessage = await Checkin . getCheckinMessage ( liveEvents , isPublic , needsSlide ) ;
134+ const publicMessage = await Checkin . getCheckinMessage ( todayEvents , isPublic , needsSlide ) ;
153135 await super . edit ( interaction , publicMessage ) ;
154136 }
155137 } catch ( e ) {
0 commit comments