Skip to content

Commit

Permalink
Improve debug
Browse files Browse the repository at this point in the history
  • Loading branch information
hugoalh committed Sep 8, 2024
1 parent a20602d commit db19212
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions mod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ const exfetch: ExFetch = new ExFetch({
const splitterNewLine = /\r?\n/g;
const splitterCommonDelimiter = /,|\r?\n/g;
console.log("Parse input.");
writeDebug(`Environment Variables:\n${Object.entries(Deno.env.toObject()).map(([key, value]: [string, string]): string => {
writeDebug(`Environment Variables:\n\t${Object.entries(Deno.env.toObject()).map(([key, value]: [string, string]): string => {
return `${key} = ${value}`;
}).join("\n")}`);
}).join("\n\t")}`);
try {
const truncateEnable: boolean = getInputBoolean("truncate_enable", { defaultValue: true });
const stringTruncator: StringTruncator | undefined = truncateEnable ? new StringTruncator(128, {
Expand Down Expand Up @@ -153,7 +153,6 @@ try {
requestPayload.poll = poll;
}
const requestPayloadStringify: string = JSON.stringify(requestPayload);
writeDebug(`Payload: ${requestPayloadStringify}`);
const requestHeaders: Headers = new Headers();
const requestBody: BodyInit = ((): BodyInit => {
if (
Expand All @@ -163,9 +162,13 @@ try {
requestHeaders.set("Content-Type", "multipart/form-data");
const result: FormData = (typeof files === "undefined") ? new FormData() : files;
result.append("payload_json", requestPayloadStringify);
writeDebug(`Body:\n\t${Array.from(result.entries(),([key,value]:[string, FormDataEntryValue])=>{
return `${key} = ${value}`;
}).join("\n\t")}`);
return result;
}
requestHeaders.set("Content-Type", "application/json");
writeDebug(`Body: ${requestPayloadStringify}`);
return requestPayloadStringify;
})();
console.log(`Post network request to Discord.`);
Expand Down

0 comments on commit db19212

Please sign in to comment.