···
text: "yes, looks good!",
122
+
value: password as string,
action_id: "make-account",
···
141
-
slackApp.action("make-account", async ({ context }) => {
142
-
if (context?.respond)
143
-
await context.respond({
144
-
response_type: "ephemeral",
145
-
text: `great! your account has been created :yay:\n\nsign in at <https://waka.hackclub.com/login|hackatime> with your username \`${context.userId}\` and the password you just set up!`,
141
+
slackApp.action("make-account", async ({ context, payload }) => {
142
+
if (!context?.respond) return;
143
+
if (!context.client.users) return;
146
+
await context.client.users.info({ user: context.userId as string })
152
+
user.real_name || user.profile?.display_name || "Anonymous Hacker";
154
+
// @ts-expect-error
155
+
const password = payload?.actions[0].value;
157
+
const signup: { created: boolean; api_key: string } = await fetch(
158
+
"https://waka.hackclub.com/signup",
162
+
"Content-Type": "application/x-www-form-urlencoded",
163
+
Authorization: `Bearer ${process.env.HACKATIME_API_KEY}`,
165
+
body: new URLSearchParams({
166
+
location: user.tz as string,
167
+
username: context.userId as string,
169
+
email: user.profile?.email || "",
170
+
password: password || "",
171
+
password_repeat: password || "",
174
+
).then((res) => res.json());
176
+
await context.respond({
177
+
response_type: "ephemeral",
178
+
text: "great! your account has been created :yay:",
184
+
text: "great! your account has been created :yay:",
187
+
{ type: "divider" },
192
+
text: `you can now log in to the <https://waka.hackclub.com/login|Hackatime dashboard> with your username \`${context.userId}\` and password \`${password}\` :3c:`,
200
+
text: `your api key for the Hackatime API is \`${signup.api_key}\``,
slackApp.action("bad-info", async ({ context }) => {