Skip to content

Commit

Permalink
Fix /lc sync subcommand (#46)
Browse files Browse the repository at this point in the history
* wip

* Update api.ts
  • Loading branch information
EthanThatOneKid authored Oct 17, 2023
1 parent 3ac6b70 commit bfa4295
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 31 deletions.
7 changes: 0 additions & 7 deletions api/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,10 +108,3 @@ export function makeOnListen(
function makeInviteURL(applicationID: string) {
return `https://discord.com/api/oauth2/authorize?client_id=${applicationID}&scope=applications.commands`;
}

fetch(
"http://127.0.0.1:8080/webhook?season_id=01H8T4MM00BQHHK7VTTEJE1WAS&webhook_url=https://discord.com/api/webhooks/1128189891847667712/jUq5uK9dzM4V99fsj8Y6b8tBiZx_idMB5DAMKAPJQ4rTbEiqoy7ah2qUpORWyfaHGl4l",
{
method: "POST",
},
).then((res) => res.json()).then(console.log).catch(console.error);
64 changes: 40 additions & 24 deletions main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,29 +24,45 @@ async function main() {
kv,
lcClient,
);
const r = api.makeAPIRouter(
DISCORD_APPLICATION_ID,
DISCORD_PUBLIC_KEY,
DISCORD_CHANNEL_ID,
DISCORD_WEBHOOK_URL,
WEBHOOK_TOKEN,
lcClient,
leaderboardClient,
);
try {
const r = api.makeAPIRouter(
DISCORD_APPLICATION_ID,
DISCORD_PUBLIC_KEY,
DISCORD_CHANNEL_ID,
DISCORD_WEBHOOK_URL,
WEBHOOK_TOKEN,
lcClient,
leaderboardClient,
);

await Router.serve(
{
port: PORT,
onListen: api.makeOnListen(
PORT,
DISCORD_APPLICATION_ID,
DISCORD_TOKEN,
),
},
r,
)
.finished
.finally(() => {
kv.close();
});
await Router.serve(
{
port: PORT,
onListen: api.makeOnListen(
PORT,
DISCORD_APPLICATION_ID,
DISCORD_TOKEN,
),
},
r,
)
.finished
.finally(() => {
kv.close();
});
} catch (error) {
// TODO: Resolve this error.
//
// Task start deno run -A --unstable main.ts
// - Discord application information: https://discord.com/developers/applications/1130004756153253960/
// - Interaction endpoint: http://127.0.0.1:8080/
// - Invite LC-Dailies to your server: http://127.0.0.1:8080/invite
// - Latest season: http://127.0.0.1:8080/seasons/latest
// SyntaxError: Unexpected token 'O', "OK" is not valid JSON
// at parse (<anonymous>)
// at packageData (ext:deno_fetch/22_body.js:369:14)
// at consumeBody (ext:deno_fetch/22_body.js:246:12)
// at eventLoopTick (ext:core/01_core.js:183:11)
console.log(error);
}
}

0 comments on commit bfa4295

Please sign in to comment.