@@ -186,14 +186,31 @@ export default async (bot: DiscordBot): Promise<void> => {
186186 } ) ;
187187 break ;
188188 case "everything" :
189- //await ctx.update({ components: [] });
189+ const msg = ctx . message ;
190+ // so far we only have github so...
191+ const [ , owner , repo , ref ] =
192+ / h t t p s ? : \/ \/ g i t h u b .c o m \/ (?< owner > \S + ) \/ (?< repo > \S + ) \/ (?< sha > \S + ) / . exec (
193+ msg . embeds [ msg . embeds . length - 1 ] . url ?? ""
194+ ) || [ ] ;
195+
196+ const res = await (
197+ await bot . container . getService ( "Github" )
198+ ) . octokit . rest . repos . getCommit ( { owner, repo, ref } ) ;
199+ const files = res . data . files ?. flatMap ( f => f . filename ) ;
200+
201+ if ( ! files || files . length === 0 ) {
202+ await ctx . reply ( "no files found for refreshing :( ... aborting" ) ;
203+ return ;
204+ }
205+
190206 await ctx . reply (
191207 `<@${ ctx . user . id } > updating and refreshing files on ${ where
192208 . map ( s =>
193209 s . discord . ready ? `<@${ s . discord . user ?. id } >` : `#${ s . config . id } `
194210 )
195211 . join ( ) } ...`
196212 ) ;
213+
197214 await Promise . all (
198215 where . map ( async server => {
199216 const reply = await ctx . fetchReply ( ) ;
@@ -209,10 +226,6 @@ export default async (bot: DiscordBot): Promise<void> => {
209226 ( await channel . messages . fetch ( reply ) ) . react ( "📥" ) ;
210227 } ) ;
211228
212- const msg = ctx . message ;
213- const files = msg . embeds
214- . flatMap ( e => e . fields )
215- . map ( f => [ ...f . value . matchAll ( FIELD_REGEX ) ] . map ( m => m [ 1 ] ) [ 0 ] ) ;
216229 const res = await server . sendLua (
217230 'if not RefreshLua then return false, "RefreshLua missing?" end\n' +
218231 files
0 commit comments