@@ -10,19 +10,19 @@ import Logger from '../utils/Logger';
10
10
import QR from './QR' ;
11
11
12
12
/**
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.
18
18
*/
19
19
export default class Checkin extends Command {
20
20
constructor ( client : BotClient ) {
21
21
const definition = new SlashCommandBuilder ( )
22
22
. setName ( 'checkin' )
23
23
. addBooleanOption ( option =>
24
24
option
25
- . setName ( 'now ' )
25
+ . setName ( 'public ' )
26
26
. setDescription ( 'If true, send public embed of checking code for live events!' )
27
27
. setRequired ( false )
28
28
)
@@ -40,7 +40,7 @@ export default class Checkin extends Command {
40
40
boardRequired : true ,
41
41
enabled : true ,
42
42
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. " ,
44
44
category : 'Utility' ,
45
45
usage : client . settings . prefix . concat ( 'checkin [now]' ) ,
46
46
requiredPermissions : [ 'SEND_MESSAGES' ] ,
@@ -66,10 +66,11 @@ export default class Checkin extends Command {
66
66
*/
67
67
public async run ( interaction : CommandInteraction ) : Promise < void > {
68
68
// 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 ' ) ;
70
70
const widescreenArgument = interaction . options . getBoolean ( 'widescreen' ) ;
71
71
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 ;
73
74
// By default, we want to include the slide.
74
75
const needsSlide = widescreenArgument !== null ? widescreenArgument : true ;
75
76
@@ -83,12 +84,7 @@ export default class Checkin extends Command {
83
84
// Oh, boy, here come more dates and times to check.
84
85
// Luxon makes it much nicer, however.
85
86
//
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.
92
88
const todayEvents = futureEvents . filter ( event => {
93
89
// get today's midnight
94
90
const midnightToday = DateTime . now ( ) . set ( {
@@ -112,33 +108,21 @@ export default class Checkin extends Command {
112
108
return Interval . fromDateTimes ( midnightToday , midnightTomorrow ) . contains ( event . start ) ;
113
109
} ) ;
114
110
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
-
120
111
// We'll make sure to check if the required set of events by
121
112
// command arugments is empty; if it is, just return "No events today!"
122
- if ( ! isPublic && todayEvents . length === 0 ) {
113
+ if ( todayEvents . length === 0 ) {
123
114
await super . edit ( interaction , {
124
115
content : 'No events today!' ,
125
116
ephemeral : true ,
126
117
} ) ;
127
118
return ;
128
119
}
129
- if ( isPublic && liveEvents . length === 0 ) {
130
- await super . edit ( interaction , 'No events right now!' ) ;
131
- return ;
132
- }
133
120
134
121
// Now we finally check the command argument.
135
122
// If we just had `checkin` in our call, no arguments...
136
123
if ( ! isPublic ) {
137
124
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`.
142
126
const privateMessage = await Checkin . getCheckinMessage ( todayEvents , isPublic , needsSlide ) ;
143
127
await author . send ( privateMessage ) ;
144
128
await super . edit ( interaction , {
@@ -147,9 +131,7 @@ export default class Checkin extends Command {
147
131
} ) ;
148
132
await interaction . followUp ( `**/checkin** was used privately by ${ interaction . user } !` ) ;
149
133
} 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 ) ;
153
135
await super . edit ( interaction , publicMessage ) ;
154
136
}
155
137
} catch ( e ) {
0 commit comments