From 4d7ae5576a02be3981367815b5e89ef415628645 Mon Sep 17 00:00:00 2001 From: Tim Smart Date: Thu, 27 Apr 2023 00:41:15 +1200 Subject: [PATCH] feat: prefill edit title modal --- src/AutoThreads.ts | 30 +++++++++++++++++++----------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/src/AutoThreads.ts b/src/AutoThreads.ts index 535ae81..a37e009 100644 --- a/src/AutoThreads.ts +++ b/src/AutoThreads.ts @@ -120,17 +120,25 @@ const make = Effect.gen(function* ($) { const edit = Ix.messageComponent( Ix.idStartsWith("edit_"), checkPermissions(() => - Effect.succeed( - Ix.r({ - type: Discord.InteractionCallbackType.MODAL, - data: { - custom_id: "edit", - title: "Edit title", - components: UI.singleColumn([ - UI.textInput({ custom_id: "title", label: "New title" }), - ]), - }, - }), + pipe( + Ix.Interaction, + Effect.flatMap(ix => channels.get(ix.guild_id!, ix.channel_id!)), + Effect.map(channel => + Ix.r({ + type: Discord.InteractionCallbackType.MODAL, + data: { + custom_id: "edit", + title: "Edit title", + components: UI.singleColumn([ + UI.textInput({ + custom_id: "title", + label: "New title", + value: channel.name!, + }), + ]), + }, + }), + ), ), ), )