@@ -92,7 +92,7 @@ export const instantiateServer = async(
9292 await camperChan . octokit . rest . pulls . createReview ( {
9393 body :
9494 action === "labeled"
95- // eslint-disable-next-line stylistic/max-len -- It's a string.
95+ // eslint-disable-next-line stylistic/max-len -- It's a string.
9696 ? "This PR has been marked as DO NOT MERGE. When you are ready to merge it, remove the label and I'll unblock the PR."
9797 // eslint-disable-next-line stylistic/max-len -- It's a string.
9898 : "This PR has been unmarked as DO NOT MERGE. You may now merge this PR." ,
@@ -144,145 +144,155 @@ export const instantiateServer = async(
144144 await response . status ( 500 ) . send ( "No secret provided." ) ;
145145 return ;
146146 }
147- const secretHeader = request . headers [ "x-appeal-secret" ] ;
147+ const secretHeader = request . headers . Authorization ;
148148 if ( typeof secretHeader !== "string" ) {
149149 await response .
150150 status ( 400 ) .
151- send ( `Invalid value ${ String ( secretHeader ) } for X-Appeal-Secret ` ) ;
151+ send ( `Invalid value ${ String ( secretHeader ) } for Authorization ` ) ;
152152 return ;
153153 }
154154 if ( secretHeader !== appealSecret ) {
155155 await response . status ( 401 ) . send ( "Failed to verify appeal secret." ) ;
156156 return ;
157157 }
158158 // eslint-disable-next-line @typescript-eslint/consistent-type-assertions -- I'll make a type guard at some point.
159- const { body } = request as { body : Appeal } ;
160- const [ appeal ] = body . items ;
161- if ( ! appeal ) {
159+ const { body } = request as { body : Array < Appeal > } ;
160+ if ( body . length === 0 ) {
162161 await response . status ( 400 ) . send ( "No appeal data provided." ) ;
163162 return ;
164163 }
165- // It's valid, so send an ok response immediately
166- await response . status ( 200 ) . send ( "OK~!" ) ;
167- logHandler . log (
168- "info" ,
169- `New appeal received from ${ appeal . Username } (${ appeal [ "User ID" ] } )` ,
170- ) ;
164+ await Promise . all (
165+ body . map ( async ( appeal ) => {
166+ // It's valid, so send an ok response immediately
167+ await response . status ( 200 ) . send ( "OK~!" ) ;
168+ logHandler . log (
169+ "info" ,
170+ `New appeal received from ${ appeal . Username } (${ appeal . Discord_ID } )` ,
171+ ) ;
171172
172- await fetch (
173- "https://discord.com/api/v10/channels/987408145863307334/messages" ,
174- {
175- body : JSON . stringify ( {
176- components : [
177- {
178- content : "# NEW BAN APPEAL" ,
179- type : 10 ,
180- } ,
181- {
182- // eslint-disable-next-line @typescript-eslint/naming-convention -- Discord API name.
183- accent_color : null ,
184- components : [
173+ await fetch (
174+ "https://discord.com/api/v10/channels/987408145863307334/messages" ,
175+ {
176+ body : JSON . stringify ( {
177+ components : [
185178 {
186- content : "**User Name and ID** " ,
179+ content : "# NEW BAN APPEAL " ,
187180 type : 10 ,
188181 } ,
189182 {
190- content : `${ appeal . Username } (${ appeal [ "User ID" ] } )` ,
191- type : 10 ,
183+ // eslint-disable-next-line @typescript-eslint/naming-convention -- Discord API name.
184+ accent_color : null ,
185+ components : [
186+ {
187+ content : "**User Name and ID**" ,
188+ type : 10 ,
189+ } ,
190+ {
191+ content : `${ appeal . Username } (${ appeal . Discord_ID } )` ,
192+ type : 10 ,
193+ } ,
194+ ] ,
195+ spoiler : false ,
196+ type : 17 ,
192197 } ,
193- ] ,
194- spoiler : false ,
195- type : 17 ,
196- } ,
197- {
198- // eslint-disable-next-line @typescript-eslint/naming-convention -- Discord API name.
199- accent_color : null ,
200- components : [
201198 {
202- content : "**I have read and will follow Code of Conduct**" ,
203- type : 10 ,
199+ // eslint-disable-next-line @typescript-eslint/naming-convention -- Discord API name.
200+ accent_color : null ,
201+ components : [
202+ {
203+ content :
204+ "**I have read and will follow Code of Conduct**" ,
205+ type : 10 ,
206+ } ,
207+ {
208+ content : String ( appeal . Code_of_Conduct ) ,
209+ type : 10 ,
210+ } ,
211+ ] ,
212+ spoiler : false ,
213+ type : 17 ,
204214 } ,
205215 {
206- content : String ( appeal [ "Code of Conduct" ] ) ,
207- type : 10 ,
216+ // eslint-disable-next-line @typescript-eslint/naming-convention -- Discord API name.
217+ accent_color : null ,
218+ components : [
219+ {
220+ content : "**Why were you banned?**" ,
221+ type : 10 ,
222+ } ,
223+ {
224+ content : appeal . Reason ,
225+ type : 10 ,
226+ } ,
227+ ] ,
228+ spoiler : false ,
229+ type : 17 ,
208230 } ,
209- ] ,
210- spoiler : false ,
211- type : 17 ,
212- } ,
213- {
214- // eslint-disable-next-line @typescript-eslint/naming-convention -- Discord API name.
215- accent_color : null ,
216- components : [
217231 {
218- content : "**Why were you banned?**" ,
219- type : 10 ,
232+ // eslint-disable-next-line @typescript-eslint/naming-convention -- Discord API name.
233+ accent_color : null ,
234+ components : [
235+ {
236+ content : "**Was the ban fair? Why or why not?**" ,
237+ type : 10 ,
238+ } ,
239+ {
240+ content : appeal . Fairness ,
241+ type : 10 ,
242+ } ,
243+ ] ,
244+ spoiler : false ,
245+ type : 17 ,
220246 } ,
221247 {
222- content : appeal . Reason ,
223- type : 10 ,
248+ // eslint-disable-next-line @typescript-eslint/naming-convention -- Discord API name.
249+ accent_color : null ,
250+ components : [
251+ {
252+ content : "**How will your behaviour improve?**" ,
253+ type : 10 ,
254+ } ,
255+ {
256+ content : appeal . Improvement ,
257+ type : 10 ,
258+ } ,
259+ ] ,
260+ spoiler : false ,
261+ type : 17 ,
224262 } ,
225263 ] ,
226- spoiler : false ,
227- type : 17 ,
228- } ,
229- {
264+ flags : 32_768 ,
265+ } ) ,
266+ headers : {
230267 // eslint-disable-next-line @typescript-eslint/naming-convention -- Discord API name.
231- accent_color : null ,
232- components : [
233- {
234- content : "**Was the ban fair? Why or why not?**" ,
235- type : 10 ,
236- } ,
237- {
238- content : appeal . Fair ,
239- type : 10 ,
240- } ,
241- ] ,
242- spoiler : false ,
243- type : 17 ,
244- } ,
245- {
268+ "Authorization" : `Bot ${ process . env . TOKEN ?? "" } ` ,
246269 // eslint-disable-next-line @typescript-eslint/naming-convention -- Discord API name.
247- accent_color : null ,
248- components : [
249- {
250- content : "**How will your behaviour improve?**" ,
251- type : 10 ,
252- } ,
253- {
254- content : appeal . Improve ,
255- type : 10 ,
256- } ,
257- ] ,
258- spoiler : false ,
259- type : 17 ,
270+ "Content-Type" : "application/json" ,
271+ } ,
272+ method : "POST" ,
273+ } ,
274+ ) .
275+ // eslint-disable-next-line max-nested-callbacks -- Necessary to handle the nested callback.
276+ then ( ( responseInner ) => {
277+ if ( ! responseInner . ok ) {
278+ throw new Error (
279+ `Failed to send appeal message: ${ responseInner . statusText } ` ,
280+ ) ;
281+ }
282+ } ) .
283+ catch (
284+ // eslint-disable-next-line max-nested-callbacks -- Necessary to handle the nested callback.
285+ ( error : unknown ) => {
286+ logHandler . error ( JSON . stringify ( error ) ) ;
287+ return void errorHandler (
288+ camperChan ,
289+ "send appeal message" ,
290+ error ,
291+ ) ;
260292 } ,
261- ] ,
262- flags : 32_768 ,
263- } ) ,
264- headers : {
265- // eslint-disable-next-line @typescript-eslint/naming-convention -- Discord API name.
266- "Authorization" : `Bot ${ process . env . TOKEN ?? "" } ` ,
267- // eslint-disable-next-line @typescript-eslint/naming-convention -- Discord API name.
268- "Content-Type" : "application/json" ,
269- } ,
270- method : "POST" ,
271- } ,
272- ) .
273- then ( ( responseInner ) => {
274- if ( ! responseInner . ok ) {
275- throw new Error (
276- `Failed to send appeal message: ${ responseInner . statusText } ` ,
277293 ) ;
278- }
279- } ) .
280- catch (
281- ( error : unknown ) => {
282- logHandler . error ( JSON . stringify ( error ) ) ;
283- return void errorHandler ( camperChan , "send appeal message" , error ) ;
284- } ,
285- ) ;
294+ } ) ,
295+ ) ;
286296 } ) ;
287297
288298 server . listen ( { port : 1443 } , ( error ) => {
0 commit comments