Exemple #1
0
        private async Task SendCommandResponse(SlashCommand command, IList <Block> msgBlocks)
        {
            var message = new SlashCommandResponse()
            {
                Message = new Message
                {
                    Blocks  = msgBlocks,
                    Channel = command.ChannelId,
                    AsUser  = false,
                },
                ResponseType = ResponseType.InChannel
            };

            // Add information about command caller
            var callerInfo = new PlainText($"Command from: {command.UserName}.");

            if (message.Message.Blocks.Last() is ContextBlock ctx)
            {
                ctx.Elements.Add(callerInfo);
            }
            else
            {
                message.Message.Blocks.Add(new ContextBlock()
                {
                    Elements = new List <IContextElement>()
                    {
                        callerInfo
                    }
                });
            }

            await slack.Respond(command, message);
        }
 public static Task Respond(this ISlackApiClient client, InteractionRequest request, MessageResponse response, CancellationToken?cancellationToken = null) =>
 client.Respond(request.ResponseUrl, new MessageUpdateResponse(response), cancellationToken);
 public static Task Respond(this ISlackApiClient client, SlashCommand slashCommand, SlashCommandResponse response, CancellationToken?cancellationToken = null) =>
 client.Respond(slashCommand.ResponseUrl, new SlashCommandMessageResponse(response), cancellationToken);