@@ -111,40 +111,50 @@ export function renderCommandListPage(context: BaseContext, state: CommandListSt
111
111
container . components . push ( ...entry ) ;
112
112
}
113
113
114
- if ( entries . length === 0 ) {
114
+ if ( entries . length === 0 )
115
115
container . components . push ( Text ( `**${ icons . info } You do not have access to any commands for this plugin!**` ) ) ;
116
- return { components : [ container ] } ;
117
- }
116
+ else {
117
+ const prevDisabled = sliceStart === 0 ;
118
+ const nextDisabled = sliceEnd >= entries . length ;
118
119
119
- const prevDisabled = sliceStart === 0 ;
120
- const nextDisabled = sliceEnd >= entries . length ;
120
+ container . components . push ( Divider ( ) ) ;
121
121
122
- container . components . push ( Divider ( ) ) ;
122
+ if ( ! prevDisabled || ! nextDisabled ) {
123
+ container . components . push ( ActionRow ( [
124
+ TextButton ( "←" , "prev" , { disabled : prevDisabled } ) ,
125
+ TextButton ( "→" , "next" , { disabled : nextDisabled } ) ,
126
+ ] ) ) ;
127
+ }
123
128
124
- if ( ! prevDisabled || ! nextDisabled ) {
125
- container . components . push ( ActionRow ( [
126
- TextButton ( "←" , "prev" , { disabled : prevDisabled } ) ,
127
- TextButton ( "→" , "next" , { disabled : nextDisabled } ) ,
128
- ] ) ) ;
129
+ container . components . push ( Text ( "-# Optional options are surrounded with []." ) ) ;
129
130
}
130
131
131
- container . components . push ( Text ( "-# Optional options are surrounded with []." ) ) ;
132
-
133
132
return {
134
133
components : [ container ] ,
135
134
async componentHandler ( context , customID , values ) {
136
135
if ( context . originalUserID !== context . user . id )
137
136
return ;
138
137
139
- if ( customID === "prev" )
140
- await context . edit ( renderCommandListPage ( context , { plugin : state . plugin , entries, page : state . page - 1 } ) ) ;
141
- else if ( customID === "next" )
142
- await context . edit ( renderCommandListPage ( context , { plugin : state . plugin , entries, page : state . page + 1 } ) ) ;
143
- else if ( customID === "plugin" ) {
138
+ if ( customID === "prev" ) {
139
+ await context . edit ( renderCommandListPage ( context , {
140
+ plugin : state . plugin ,
141
+ entries,
142
+ page : state . page - 1 ,
143
+ } ) ) ;
144
+ } else if ( customID === "next" ) {
145
+ await context . edit ( renderCommandListPage ( context , {
146
+ plugin : state . plugin ,
147
+ entries,
148
+ page : state . page + 1 ,
149
+ } ) ) ;
150
+ } else if ( customID === "plugin" ) {
144
151
if ( values ?. length !== 1 )
145
152
throw new Error ( "Selected plugin not present" ) ;
146
153
147
- await context . edit ( renderCommandListPage ( context , { plugin : values [ 0 ] ! , page : 0 } ) ) ;
154
+ await context . edit ( renderCommandListPage ( context , {
155
+ plugin : values [ 0 ] ! ,
156
+ page : 0 ,
157
+ } ) ) ;
148
158
}
149
159
} ,
150
160
} ;
0 commit comments